Remove some troublesome trailing slashes from paths
authorBrian Dolbec <dolsen@gentoo.org>
Sun, 12 Jan 2014 04:53:12 +0000 (20:53 -0800)
committerBrian Dolbec <dolsen@gentoo.org>
Sun, 12 Jan 2014 20:48:14 +0000 (12:48 -0800)
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
targets/support/functions.sh

index 3d66231f9900450581da05b804617de7d69c6540..89b891bb0d411b718a73e3cc9ccc3a5edae18364 100644 (file)
@@ -466,20 +466,20 @@ class generic_stage_target(generic_target):
 
        def set_snapcache_path(self):
                if "SNAPCACHE" in self.settings:
 
        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):
                """
                        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"]+\
                """
                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):
                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=\
 
                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
                        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:
                        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:
                                myf.write(self.settings["snapshot_path_hash"])
                                myf.close()
                        else:
index 80e371ccfa7e9b4af52f79a30c68d5fd24a973dd..c8757d453cefd67c453dd4914d380dfe6141d422 100755 (executable)
@@ -20,7 +20,7 @@ exec_in_chroot(){
 # and executes it.
        local file_name=$(basename ${1})
        local subdir=${2}
 # 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}
 
        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 "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}
        ${clst_CHROOT} ${chroot_path} ${destdir}/${file_name} || exit 1
 
        delete_from_chroot ${destdir}/${file_name}