* [gentoo-catalyst] [PATCH] Remove some troublesome trailing slashes from paths
2014-01-11 19:43 [gentoo-catalyst] Start bringing consistent format to paths Brian Dolbec
@ 2014-01-11 19:43 ` Brian Dolbec
2014-01-12 2:58 ` [gentoo-catalyst] " W. Trevor King
0 siblings, 1 reply; 3+ messages in thread
From: Brian Dolbec @ 2014-01-11 19:43 UTC (permalink / raw
To: gentoo-catalyst; +Cc: Brian Dolbec
Change the docstring to warn to use a proper path join function.
Fix a relative path bug after removing the above slash
by moving the "."
---
modules/generic_stage_target.py | 28 +++++++++++++++-------------
modules/livecd_stage2_target.py | 4 +++-
modules/stage2_target.py | 8 ++++++--
targets/support/functions.sh | 4 ++--
4 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3d66231..a5b52b0 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -331,8 +331,9 @@ class generic_stage_target(generic_target):
"/kerncache/"+self.settings["target_subpath"]+"/")
def set_target_path(self):
- self.settings["target_path"]=normpath(self.settings["storedir"]+\
- "/builds/"+self.settings["target_subpath"]+".tar.bz2")
+ self.settings["target_path"] = normpath(self.settings["storedir"] +
+ "/builds/" + self.settings["target_subpath"].rstrip('/') +
+ ".tar.bz2")
if "AUTORESUME" in self.settings\
and os.path.exists(self.settings["autoresume_path"]+\
"setup_target_path"):
@@ -417,8 +418,9 @@ class generic_stage_target(generic_target):
self.settings["source_path"]=normpath(self.settings["storedir"]+\
"/tmp/"+self.settings["source_subpath"]+"/")
else:
- self.settings["source_path"]=normpath(self.settings["storedir"]+\
- "/builds/"+self.settings["source_subpath"]+".tar.bz2")
+ self.settings["source_path"] = normpath(self.settings["storedir"] +
+ "/builds/" + self.settings["source_subpath"].rstrip("/") +
+ ".tar.bz2")
if os.path.isfile(self.settings["source_path"]):
# XXX: Is this even necessary if the previous check passes?
if os.path.exists(self.settings["source_path"]):
@@ -431,8 +433,8 @@ class generic_stage_target(generic_target):
print "\tIf this is not desired, remove this directory or turn off"
print "\tseedcache in the options of catalyst.conf the source path"
print "\twill then be "+\
- normpath(self.settings["storedir"]+"/builds/"+\
- self.settings["source_subpath"]+".tar.bz2\n")
+ normpath(self.settings["storedir"] + "/builds/" +
+ self.settings["source_subpath"].rstrip("/") + ".tar.bz2\n")
def set_dest_path(self):
if "root_path" in self.settings:
@@ -446,9 +448,9 @@ class generic_stage_target(generic_target):
"/root/*", self.settings["portdir"]]
def set_snapshot_path(self):
- self.settings["snapshot_path"]=normpath(self.settings["storedir"]+\
+ self.settings["snapshot_path"] = normpath(self.settings["storedir"] +
"/snapshots/" + self.settings["snapshot_name"] +
- self.settings["snapshot"] + ".tar.xz")
+ self.settings["snapshot"].rstrip("/") + ".tar.xz")
if os.path.exists(self.settings["snapshot_path"]):
self.settings["snapshot_path_hash"]=\
@@ -457,7 +459,7 @@ class generic_stage_target(generic_target):
else:
self.settings["snapshot_path"]=normpath(self.settings["storedir"]+\
"/snapshots/" + self.settings["snapshot_name"] +
- self.settings["snapshot"] + ".tar.bz2")
+ self.settings["snapshot"].rstrip("/") + ".tar.bz2")
if os.path.exists(self.settings["snapshot_path"]):
self.settings["snapshot_path_hash"]=\
@@ -468,18 +470,18 @@ class generic_stage_target(generic_target):
if "SNAPCACHE" in self.settings:
self.settings["snapshot_cache_path"]=\
normpath(self.settings["snapshot_cache"]+"/"+\
- self.settings["snapshot"]+"/")
+ 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):
diff --git a/modules/livecd_stage2_target.py b/modules/livecd_stage2_target.py
index 5be8fd2..c74c16d 100644
--- a/modules/livecd_stage2_target.py
+++ b/modules/livecd_stage2_target.py
@@ -33,7 +33,9 @@ class livecd_stage2_target(generic_stage_target):
file_locate(self.settings, ["cdtar","controller_file"])
def set_source_path(self):
- self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
+ self.settings["source_path"] = normpath(self.settings["storedir"] +
+ "/builds/" + self.settings["source_subpath"].rstrip("/") +
+ ".tar.bz2")
if os.path.isfile(self.settings["source_path"]):
self.settings["source_path_hash"]=generate_hash(self.settings["source_path"])
else:
diff --git a/modules/stage2_target.py b/modules/stage2_target.py
index 6083e2b..803ec59 100644
--- a/modules/stage2_target.py
+++ b/modules/stage2_target.py
@@ -19,7 +19,9 @@ class stage2_target(generic_stage_target):
if "SEEDCACHE" in self.settings and os.path.isdir(normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")):
self.settings["source_path"]=normpath(self.settings["storedir"]+"/tmp/"+self.settings["source_subpath"]+"/tmp/stage1root/")
else:
- self.settings["source_path"]=normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2")
+ self.settings["source_path"] = normpath(self.settings["storedir"] +
+ "/builds/" + self.settings["source_subpath"].rstrip("/") +
+ ".tar.bz2")
if os.path.isfile(self.settings["source_path"]):
if os.path.exists(self.settings["source_path"]):
# XXX: Is this even necessary if the previous check passes?
@@ -28,7 +30,9 @@ class stage2_target(generic_stage_target):
print "Source path set to "+self.settings["source_path"]
if os.path.isdir(self.settings["source_path"]):
print "\tIf this is not desired, remove this directory or turn of seedcache in the options of catalyst.conf"
- print "\tthe source path will then be "+normpath(self.settings["storedir"]+"/builds/"+self.settings["source_subpath"]+".tar.bz2\n")
+ print "\tthe source path will then be " + \
+ normpath(self.settings["storedir"] + "/builds/" + \
+ self.settings["source_subpath"].restrip("/") + ".tar.bz2\n")
# XXX: How do these override_foo() functions differ from the ones in
# generic_stage_target and why aren't they in stage3_target?
diff --git a/targets/support/functions.sh b/targets/support/functions.sh
index 80e371c..3245862 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}
@@ -33,7 +33,7 @@ exec_in_chroot(){
chmod +x ${chroot_path}/${destdir}/${file_name}
echo "Running ${file_name} in chroot ${chroot_path}"
- ${clst_CHROOT} ${chroot_path} ${destdir}/${file_name} || exit 1
+ ${clst_CHROOT} ${chroot_path} .${destdir}/${file_name} || exit 1
delete_from_chroot ${destdir}/${file_name}
delete_from_chroot ${destdir}/chroot-functions.sh
--
1.8.3.2
^ permalink raw reply related [flat|nested] 3+ messages in thread