* [gentoo-catalyst] Catalyst tree move code changes. [4 of 4]
@ 2013-01-08 0:01 Brian Dolbec
2013-01-08 1:42 ` Anthony G. Basile
0 siblings, 1 reply; 2+ messages in thread
From: Brian Dolbec @ 2013-01-08 0:01 UTC (permalink / raw
To: gentoo-catalyst@lists.gentoo.org
[-- Attachment #1.1: Type: text/plain, Size: 205 bytes --]
Remove self.mounts and self.mountmap's use of paths for keys and paths.
Migrate more hardcoded paths to use settings.
--
Brian Dolbec <brian.dolbec@gmail.com>
--
Brian Dolbec <dolsen@gentoo.org>
[-- Attachment #1.2: 0004-Remove-self.mounts.self.mountmap-use-of-paths-for-keys.Migrate-more-settings.patch --]
[-- Type: text/x-patch, Size: 12329 bytes --]
From 45a504d83e6fd41becfb422788b8539bd6375d06 Mon Sep 17 00:00:00 2001
From: Brian Dolbec <dolsen@gentoo.org>
Date: Wed, 19 Dec 2012 18:56:04 -0800
Subject: [PATCH] Remove self.mounts and self.mountmap's use of paths for keys
and paths. Migrate more hardcoded paths to use settings.
---
modules/generic_stage_target.py | 116 ++++++++++++++++++++--------------------
1 file changed, 59 insertions(+), 57 deletions(-)
diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py
index 3597680..44256fc 100644
--- a/modules/generic_stage_target.py
+++ b/modules/generic_stage_target.py
@@ -174,16 +174,16 @@ class generic_stage_target(generic_target):
""" Setup our mount points """
if self.settings.has_key("SNAPCACHE"):
- self.mounts=["/proc","/dev","/usr/portage","/usr/portage/distfiles","/var/tmp/portage"]
- self.mountmap={"/proc":"/proc","/dev":"/dev","/dev/pts":"/dev/pts",\
- "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\
- "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
+ self.mounts=["proc", "dev", 'portdir', 'distdir', 'port_tmpdir']
+ self.mountmap={"proc":"proc", "dev":"/dev", "pts":"/dev/pts",
+ "portdir":self.settings["snapshot_cache_path"]+"/" + self.settings["repo_name"],
+ "distdir":self.settings["distdir"],"port_tmpdir":"tmpfs"}
else:
- self.mounts=["/proc","/dev","/usr/portage/distfiles","/var/tmp/portage"]
- self.mountmap={"/proc":"/proc","/dev":"/dev","/dev/pts":"/dev/pts",\
- "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
+ self.mounts=["proc","dev", "distdir", "port_tmpdir"]
+ self.mountmap={"proc":"/proc", "dev":"/dev", "pts":"/dev/pts",
+ "distdir":self.settings["distdir"], "port_tmpdir":"tmpfs"}
if os.uname()[0] == "Linux":
- self.mounts.append("/dev/pts")
+ self.mounts.append("pts")
self.set_mounts()
@@ -195,16 +195,15 @@ class generic_stage_target(generic_target):
self.set_pkgcache_path()
print "Location of the package cache is "+\
self.settings["pkgcache_path"]
- self.mounts.append("/usr/portage/packages")
- self.mountmap["/usr/portage/packages"]=\
- self.settings["pkgcache_path"]
+ self.mounts.append("packagedir")
+ self.mountmap["packagedir"] = self.settings["pkgcache_path"]
if self.settings.has_key("KERNCACHE"):
self.set_kerncache_path()
print "Location of the kerncache is "+\
self.settings["kerncache_path"]
- self.mounts.append("/tmp/kerncache")
- self.mountmap["/tmp/kerncache"]=self.settings["kerncache_path"]
+ self.mounts.append("kerncache")
+ self.mountmap["kerncache"]=self.settings["kerncache_path"]
if self.settings.has_key("CCACHE"):
if os.environ.has_key("CCACHE_DIR"):
@@ -216,20 +215,20 @@ class generic_stage_target(generic_target):
raise CatalystError,\
"Compiler cache support can't be enabled (can't find "+\
ccdir+")"
- self.mounts.append("/var/tmp/ccache")
- self.mountmap["/var/tmp/ccache"]=ccdir
+ self.mounts.append("ccache")
+ self.mountmap["ccache"]=ccdir
""" for the chroot: """
self.env["CCACHE_DIR"]="/var/tmp/ccache"
if self.settings.has_key("ICECREAM"):
- self.mounts.append("/var/cache/icecream")
- self.mountmap["/var/cache/icecream"]="/var/cache/icecream"
+ self.mounts.append("icecream")
+ self.mountmap["icecream"]="/var/cache/icecream"
self.env["PATH"]="/usr/lib/icecc/bin:"+self.env["PATH"]
if self.settings.has_key("port_logdir"):
- self.mounts.append("/var/log/portage")
- self.mountmap["/var/log/portage"]=self.settings["port_logdir"]
- self.env["PORT_LOGDIR"]="/var/log/portage"
+ self.mounts.append("port_logdir")
+ self.mountmap["port_logdir"]=self.settings["port_logdir"]
+ self.env["PORT_LOGDIR"]=self.settings["port_logdir"]
self.env["PORT_LOGDIR_CLEAN"]='find "${PORT_LOGDIR}" -type f ! -name "summary.log*" -mtime +30 -delete'
def override_cbuild(self):
@@ -406,11 +405,12 @@ class generic_stage_target(generic_target):
def set_cleanables(self):
self.settings["cleanables"]=["/etc/resolv.conf","/var/tmp/*","/tmp/*",\
- "/root/*","/usr/portage"]
+ "/root/*", self.settings["portdir"]]
def set_snapshot_path(self):
self.settings["snapshot_path"]=normpath(self.settings["storedir"]+\
- "/snapshots/portage-"+self.settings["snapshot"]+".tar.xz")
+ "/snapshots/" + self.settings["snapshot_name"] +
+ self.settings["snapshot"]+".tar.xz")
if os.path.exists(self.settings["snapshot_path"]):
self.settings["snapshot_path_hash"]=\
@@ -612,21 +612,21 @@ class generic_stage_target(generic_target):
return
for x in self.mounts:
- if not os.path.exists(mypath+x):
+ if not os.path.exists(mypath + self.mountmap[x]):
continue
- if ismount(mypath+x):
+ if ismount(mypath +self.mountmap[x]):
""" Something is still mounted "" """
try:
- print x+" is still mounted; performing auto-bind-umount...",
+ print self.mountmap[x] + " is still mounted; performing auto-bind-umount...",
""" Try to umount stuff ourselves """
self.unbind()
- if ismount(mypath+x):
- raise CatalystError, "Auto-unbind failed for "+x
+ if ismount(mypath + self.mountmap[x]):
+ raise CatalystError, "Auto-unbind failed for " + self.mountmap[x]
else:
print "Auto-unbind successful..."
except CatalystError:
- raise CatalystError, "Unable to auto-unbind "+x
+ raise CatalystError, "Unable to auto-unbind " + self.mountmap[x]
def unpack(self):
unpack=True
@@ -784,7 +784,7 @@ class generic_stage_target(generic_target):
print "Valid snapshot cache, skipping unpack of portage tree..."
unpack=False
else:
- destdir=normpath(self.settings["chroot_path"]+"/usr/portage")
+ destdir=normpath(self.settings["chroot_path"] + self.settings["portdir"])
cleanup_errmsg="Error removing existing snapshot directory."
cleanup_msg=\
"Cleaning up existing portage tree (This can take a long time)..."
@@ -798,7 +798,7 @@ class generic_stage_target(generic_target):
if self.settings.has_key("AUTORESUME") \
and os.path.exists(self.settings["chroot_path"]+\
- "/usr/portage/") \
+ self.settings["portdir"]) \
and os.path.exists(self.settings["autoresume_path"]\
+"unpack_portage") \
and self.settings["snapshot_path_hash"] == snapshot_hash:
@@ -845,7 +845,7 @@ class generic_stage_target(generic_target):
cmd("rm -f "+self.settings["chroot_path"]+"/etc/portage/make.profile",\
"Error zapping profile link",env=self.env)
cmd("mkdir -p "+self.settings["chroot_path"]+"/etc/portage/")
- cmd("ln -sf ../../usr/portage/profiles/"+\
+ cmd("ln -sf ../.." + self.settings["portdir"] + "/profiles/"+\
self.settings["target_profile"]+" "+\
self.settings["chroot_path"]+"/etc/portage/make.profile",\
"Error creating profile link",env=self.env)
@@ -865,16 +865,16 @@ class generic_stage_target(generic_target):
touch(self.settings["autoresume_path"]+"setup_confdir")
def portage_overlay(self):
- """ We copy the contents of our overlays to /usr/local/portage """
+ """ We copy the contents of our overlays to local_overlay setting """
if self.settings.has_key("portage_overlay"):
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
print "Copying overlay dir " +x
cmd("mkdir -p "+self.settings["chroot_path"]+\
- "/usr/local/portage",\
+ self.settings["local_overlay"],\
"Could not make portage_overlay dir",env=self.env)
cmd("cp -R "+x+"/* "+self.settings["chroot_path"]+\
- "/usr/local/portage",\
+ self.settings["local_overlay"],\
"Could not copy portage_overlay",env=self.env)
def root_overlay(self):
@@ -894,7 +894,7 @@ class generic_stage_target(generic_target):
def bind(self):
for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"]+x):
+ if not os.path.exists(self.settings["chroot_path"] + self.mountmap[x]):
os.makedirs(self.settings["chroot_path"]+x,0755)
if not os.path.exists(self.mountmap[x]):
@@ -902,27 +902,28 @@ class generic_stage_target(generic_target):
os.makedirs(self.mountmap[x],0755)
src=self.mountmap[x]
- if self.settings.has_key("SNAPCACHE") and x == "/usr/portage":
+ if self.settings.has_key("SNAPCACHE") and x == "portdir":
self.snapshot_lock_object.read_lock()
if os.uname()[0] == "FreeBSD":
if src == "/dev":
- retval=os.system("mount -t devfs none "+\
- self.settings["chroot_path"]+x)
+ retval=os.system("mount -t devfs none " +
+ self.settings["chroot_path"] + src)
else:
- retval=os.system("mount_nullfs "+src+" "+\
- self.settings["chroot_path"]+x)
+ retval=os.system("mount_nullfs " + src + " " +
+ self.settings["chroot_path"] + src)
else:
if src == "tmpfs":
if self.settings.has_key("var_tmpfs_portage"):
- retval=os.system("mount -t tmpfs -o size="+\
- self.settings["var_tmpfs_portage"]+"G "+src+" "+\
- self.settings["chroot_path"]+x)
+ retval=os.system("mount -t tmpfs -o size=" +
+ self.settings["var_tmpfs_portage"] + "G " +
+ src + " " + self.settings["chroot_path"] +
+ self.settings["port_tmp_dir"])
else:
- retval=os.system("mount --bind "+src+" "+\
- self.settings["chroot_path"]+x)
+ retval=os.system("mount --bind " + src + " " +
+ self.settings["chroot_path"] + src)
if retval!=0:
self.unbind()
- raise CatalystError,"Couldn't bind mount "+src
+ raise CatalystError,"Couldn't bind mount " + src
def unbind(self):
ouch=0
@@ -931,27 +932,28 @@ class generic_stage_target(generic_target):
myrevmounts.reverse()
""" Unmount in reverse order for nested bind-mounts """
for x in myrevmounts:
- if not os.path.exists(mypath+x):
+ if not os.path.exists(mypath + self.mountmap[x]):
continue
- if not ismount(mypath+x):
+ if not ismount(mypath + self.mountmap[x]):
continue
retval=os.system("umount "+\
- os.path.join(mypath,x.lstrip(os.path.sep)))
+ os.path.join(mypath, self.mountmap[x].lstrip(os.path.sep)))
if retval!=0:
- warn("First attempt to unmount: "+mypath+x+" failed.")
+ warn("First attempt to unmount: " + mypath +
+ self.mountmap[x] +" failed.")
warn("Killing any pids still running in the chroot")
self.kill_chroot_pids()
- retval2=os.system("umount "+mypath+x)
+ retval2=os.system("umount " + mypath + self.mountmap[x])
if retval2!=0:
ouch=1
- warn("Couldn't umount bind mount: "+mypath+x)
+ warn("Couldn't umount bind mount: " + mypath + self.mountmap[x])
- if self.settings.has_key("SNAPCACHE") and x == "/usr/portage":
+ if self.settings.has_key("SNAPCACHE") and x == "portdir":
try:
"""
It's possible the snapshot lock object isn't created yet.
@@ -1065,7 +1067,7 @@ class generic_stage_target(generic_target):
""" Setup the portage overlay """
if self.settings.has_key("portage_overlay"):
- myf.write('PORTDIR_OVERLAY="/usr/local/portage"\n')
+ myf.write('PORTDIR_OVERLAY="%s"\n' % self.settings["local_overlay"])
myf.close()
cmd("cp "+self.settings["chroot_path"]+"/etc/portage/make.conf "+\
@@ -1111,9 +1113,9 @@ class generic_stage_target(generic_target):
"Could not replace /etc/hosts",env=self.env)
""" Remove our overlay """
- if os.path.exists(self.settings["chroot_path"]+"/usr/local/portage"):
- cmd("rm -rf "+self.settings["chroot_path"]+"/usr/local/portage",\
- "Could not remove /usr/local/portage",env=self.env)
+ if os.path.exists(self.settings["chroot_path"] + self.settings["local_overlay"]):
+ cmd("rm -rf " + self.settings["chroot_path"] + self.settings["local_overlay"],
+ "Could not remove " + self.settings["local_overlay"], env=self.env)
cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\
"/etc/portage/make.conf",\
"Could not remove PORTDIR_OVERLAY from make.conf",env=self.env)
--
1.8.0
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-catalyst] Catalyst tree move code changes. [4 of 4]
2013-01-08 0:01 [gentoo-catalyst] Catalyst tree move code changes. [4 of 4] Brian Dolbec
@ 2013-01-08 1:42 ` Anthony G. Basile
0 siblings, 0 replies; 2+ messages in thread
From: Anthony G. Basile @ 2013-01-08 1:42 UTC (permalink / raw
To: gentoo-catalyst
On 01/07/2013 07:01 PM, Brian Dolbec wrote:
> Remove self.mounts and self.mountmap's use of paths for keys and paths.
> Migrate more hardcoded paths to use settings.
I didn't get patch 3 of 4.
--
Anthony G. Basile, Ph. D.
Chair of Information Technology
D'Youville College
Buffalo, NY 14201
(716) 829-8197
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-08 2:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 0:01 [gentoo-catalyst] Catalyst tree move code changes. [4 of 4] Brian Dolbec
2013-01-08 1:42 ` Anthony G. Basile
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox