From 00790284f858ba31bf38789d1b004ce787c0e564 Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 13 Sep 2009 14:51:58 -0500 Subject: [PATCH] Create catalyst.util.create_tarball() helper function Replace more manual calls to rsync with catalyst.util.rsync() Replace manual calls to 'tar cjf' with catalyst.util.create_tarball() --- ChangeLog | 7 +++++++ modules/catalyst/target/generic_stage.py | 9 ++------- modules/catalyst/target/netboot.py | 3 +-- modules/catalyst/util.py | 10 ++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0380a5f9..e0717661 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,13 @@ # Distributed under the GPL v2 # $Id$ + 13 Sep 2009; Andrew Gaffney + modules/catalyst/target/generic_stage.py, + modules/catalyst/target/netboot.py, modules/catalyst/util.py: + Create catalyst.util.create_tarball() helper function + Replace more manual calls to rsync with catalyst.util.rsync() + Replace manual calls to 'tar cjf' with catalyst.util.create_tarball() + 13 Sep 2009; Andrew Gaffney modules/catalyst/target/snapshot.py, modules/catalyst/util.py: Add catalyst.util.create_tarball() helper function and modify snapshot diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index b9757e8c..eb2f0474 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -726,10 +726,7 @@ class generic_stage_target(generic_target): for x in self.settings["root_overlay"]: if os.path.exists(x): msg("Copying root_overlay: " + x) - cmd("rsync -a "+x+"/ "+\ - self.settings["chroot_path"],\ - "root_overlay: "+x+\ - " copy failed.",env=self.env) + catalyst.util.rsync(x + "/", self.settings["chroot_path"]) def base_dirs(self): pass @@ -1024,9 +1021,7 @@ class generic_stage_target(generic_target): msg("Creating stage tarball...") - cmd("tar cjpf "+self.settings["target_path"]+" -C "+\ - self.settings["stage_path"]+" .",\ - "Couldn't create stage tarball",env=self.env) + catalyst.util.create_tarball(self.settings["target_path"], ".", working_dir=self.settings["stage_path"], keep_perm=True) catalyst.hash.gen_contents_file(self.settings["target_path"], self.settings) catalyst.hash.gen_digest_file(self.settings["target_path"], self.settings) diff --git a/modules/catalyst/target/netboot.py b/modules/catalyst/target/netboot.py index b604d704..9f4f6f92 100644 --- a/modules/catalyst/target/netboot.py +++ b/modules/catalyst/target/netboot.py @@ -99,8 +99,7 @@ class netboot_target(generic_stage_target): if "netboot/overlay" in self.settings: for x in self.settings["netboot/overlay"]: if os.path.exists(x): - cmd("rsync -a "+x+"/ "+\ - self.settings["chroot_path"] + self.settings["merge_path"], "netboot/overlay: "+x+" copy failed.",env=self.env) + catalyst.util.rsync(x + "/", self.settings["chroot_path"] + self.settings["merge_path"]) self.set_autoresume("setup_overlay") def move_kernels(self): diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index b960227a..7efd7ea1 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -257,5 +257,15 @@ def create_tarball(target, src, working_dir=None, keep_perm=False): if retval != 0: raise CatalystError("Could not create tarball '%s'" % (target,)) +def unpack_tarball(src, dest, keep_perm=True): + unpack_cmd = "tar " + if keep_perm: + unpack_cmd += "xjpf " + else: + unpack_cmd += "xjf " + unpack_cmd += src + " -C " + dest + retval = catalyst.spawn.spawn_bash(unpack_cmd) + if retval != 0: + raise CatalystError("Could not unpack tarball '%s'" % (src,)) # vim: ts=4 sw=4 sta noet sts=4 ai -- 2.26.2