From 2718211aa28019b8142ae8efe2eefdbb67b6aedb Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 11 Jan 2014 20:53:12 -0800 Subject: [PATCH] Remove some troublesome trailing slashes from paths Change the docstring to warn to use a proper path join function. Modify the functions.sh output to display the actual command it is about to run. --- modules/generic_stage_target.py | 19 ++++++++++--------- targets/support/functions.sh | 5 +++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index 3d66231f..89b891bb 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -466,20 +466,20 @@ class generic_stage_target(generic_target): def set_snapcache_path(self): if "SNAPCACHE" in self.settings: - self.settings["snapshot_cache_path"]=\ - normpath(self.settings["snapshot_cache"]+"/"+\ - self.settings["snapshot"]+"/") + self.settings["snapshot_cache_path"] = \ + normpath(self.settings["snapshot_cache"] + "/" + + self.settings["snapshot"]) self.snapcache_lock=\ catalyst_lock.LockDir(self.settings["snapshot_cache_path"]) print "Caching snapshot to "+self.settings["snapshot_cache_path"] def set_chroot_path(self): """ - NOTE: the trailing slash is very important! - Things *will* break without it! + NOTE: the trailing slash has been removed + Things *could* break if you don't use a proper join() """ self.settings["chroot_path"]=normpath(self.settings["storedir"]+\ - "/tmp/"+self.settings["target_subpath"]+"/") + "/tmp/"+self.settings["target_subpath"]) self.chroot_lock=catalyst_lock.LockDir(self.settings["chroot_path"]) def set_autoresume_path(self): @@ -807,8 +807,8 @@ class generic_stage_target(generic_target): if "SNAPCACHE" in self.settings: snapshot_cache_hash=\ - read_from_clst(self.settings["snapshot_cache_path"]+\ - "catalyst-hash") + read_from_clst(self.settings["snapshot_cache_path"] + "/" + + "catalyst-hash") destdir=self.settings["snapshot_cache_path"] if "bz2" == self.settings["chroot_path"][-3:]: unpack_cmd="tar -I lbzip2 -xpf "+self.settings["snapshot_path"]+" -C "+destdir @@ -861,7 +861,8 @@ class generic_stage_target(generic_target): cmd(unpack_cmd,unpack_errmsg,env=self.env) if "SNAPCACHE" in self.settings: - myf=open(self.settings["snapshot_cache_path"]+"catalyst-hash","w") + myf=open(self.settings["snapshot_cache_path"] + + "/" + "catalyst-hash","w") myf.write(self.settings["snapshot_path_hash"]) myf.close() else: diff --git a/targets/support/functions.sh b/targets/support/functions.sh index 80e371cc..c8757d45 100755 --- a/targets/support/functions.sh +++ b/targets/support/functions.sh @@ -20,7 +20,7 @@ exec_in_chroot(){ # and executes it. local file_name=$(basename ${1}) local subdir=${2} - local destdir=".${subdir}/tmp" + local destdir="${subdir}/tmp" echo "Copying ${file_name} to ${destdir}" copy_to_chroot ${1} ${destdir} @@ -32,7 +32,8 @@ exec_in_chroot(){ echo "Ensure the file has the executable bit set" chmod +x ${chroot_path}/${destdir}/${file_name} - echo "Running ${file_name} in chroot ${chroot_path}" + echo "Running ${file_name} in chroot:" + echo " ${clst_CHROOT} ${chroot_path} ${destdir}/${file_name}" ${clst_CHROOT} ${chroot_path} ${destdir}/${file_name} || exit 1 delete_from_chroot ${destdir}/${file_name} -- 2.26.2