From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 59EE713827E for ; Sat, 14 Dec 2013 15:03:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 72CA7E0B98; Sat, 14 Dec 2013 15:03:52 +0000 (UTC) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D2FC2E0B98 for ; Sat, 14 Dec 2013 15:03:51 +0000 (UTC) Received: by mail-pa0-f43.google.com with SMTP id bj1so1201172pad.30 for ; Sat, 14 Dec 2013 07:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-type; bh=9dAuM4HdvM38IKTJzYQgOhpaRdvuNpuAhYLQ8ZWl9zE=; b=Wq7WM2DjBTvQ+bvdwE7/NedfrffKqxlTrMqY8XlLTGj8RDFdcV6bBr6+FWOQHq8YOT eKs38/KdsNyNrSSfvizKcSlif5U9ZltclDB29aW0/PA2WsEEvrrtNtxN4r5WYGlwv8YU MAjWx9K2nF0BBo0iDWQxSFLwqoRcoBcg4jDaZJ+bkGUNnU7H60ZGZmAAbtqB9ZYkPv9S OfGNqwFhv1qMep9VqX/GNO8UpOyiYQvhFtzeAIOQxqadScfgPoWpil+KrnZO0RoDqMXX f3BHwmMi64+UZzPbaTtVR4T4Zkir/mqIFbzmTPNPqVJYMVhKRcrcgpNo4iM05GvQVg3e Zj5g== X-Received: by 10.66.14.41 with SMTP id m9mr9856243pac.123.1387033430662; Sat, 14 Dec 2013 07:03:50 -0800 (PST) Received: from moiraine.localnet ([50.126.105.238]) by mx.google.com with ESMTPSA id oc9sm12931621pbb.10.2013.12.14.07.03.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Dec 2013 07:03:49 -0800 (PST) From: Dylan Baker To: gentoo-catalyst@lists.gentoo.org Cc: Brian Dolbec Subject: Re: [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths. Date: Sat, 14 Dec 2013 06:51:45 -0800 Message-ID: <3834721.6I8o79ffCh@moiraine> User-Agent: KMail/4.11.4 (Linux/3.12.5; KDE/4.11.4; x86_64; ; ) In-Reply-To: <1386990436-9198-3-git-send-email-dolsen@gentoo.org> References: <1386990436-9198-1-git-send-email-dolsen@gentoo.org> <1386990436-9198-3-git-send-email-dolsen@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2204778.c7xfY9ZaEu"; micalg="pgp-sha1"; protocol="application/pgp-signature" X-Archives-Salt: df8a17c5-4d4d-4fca-b494-152fd2a46419 X-Archives-Hash: f0775233695fd36f431502a7688a5aab --nextPart2204778.c7xfY9ZaEu Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" On Friday, December 13, 2013 07:07:14 PM Brian Dolbec wrote: > Migrate more hardcoded paths to use settings variables instead. > --- > catalyst | 3 ++ > modules/generic_stage_target.py | 80 > ++++++++++++++++++++--------------------- 2 files changed, 43 > insertions(+), 40 deletions(-) > > diff --git a/catalyst b/catalyst > index 19ec77e..60cea3e 100755 > --- a/catalyst > +++ b/catalyst > @@ -62,8 +62,11 @@ def parse_config(myconfig): > config_file="" > > confdefaults={ > + "distdir": "/usr/portage/distfiles", > "hash_function": "crc32", > + "packagedir": "/usr/portage/packages", > "portdir": "/usr/portage", > + "port_tmpdir": "/var/tmp/portage", > "repo_name": "portage", > "sharedir": "/usr/lib/catalyst", > "snapshot_name": "portage-", > diff --git a/modules/generic_stage_target.py > b/modules/generic_stage_target.py index c2888b6..342c65b 100644 > --- a/modules/generic_stage_target.py > +++ b/modules/generic_stage_target.py > @@ -179,11 +179,11 @@ class generic_stage_target(generic_target): > "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\ > "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"t > mpfs"} 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"} This is work for a seperate patch, but let's kill the self.mounts and replace it's use with self.mountmap.iterkeys() > 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 "KERNCACHE" in self.settings: > 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 "CCACHE" in self.settings: > if "CCACHE_DIR" in os.environ: > @@ -216,8 +215,8 @@ 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" > > @@ -406,7 +405,7 @@ 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"]+\ > @@ -615,21 +614,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]): add a space after the '+' operator > """ 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 > @@ -787,7 +786,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"] + add a space after the '=' operator There's more of this. please look through and add spaces beteen all of the operators, at least on the lines you've touched. This is standard python coding style and adhering to it makes all of our lives easier :) > self.settings["portdir"]) cleanup_errmsg="Error removing existing snapshot > directory." > cleanup_msg=\ > "Cleaning up existing portage tree (This can take a long time)..." > @@ -801,7 +800,7 @@ class generic_stage_target(generic_target): > > if "AUTORESUME" in self.settings \ > 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: > @@ -848,7 +847,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) > @@ -874,10 +873,10 @@ class generic_stage_target(generic_target): > 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): > @@ -897,7 +896,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]): > @@ -909,11 +908,11 @@ class generic_stage_target(generic_target): > 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 "var_tmpfs_portage" in self.settings: > @@ -921,11 +920,11 @@ class generic_stage_target(generic_target): > self.settings["var_tmpfs_portage"]+"G "+src+" "+\ > self.settings["chroot_path"]+x) > 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 > @@ -934,25 +933,26 @@ 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 "SNAPCACHE" in self.settings and x == "/usr/portage": > try: > @@ -1118,9 +1118,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) --nextPart2204778.c7xfY9ZaEu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAABAgAGBQJSrHCBAAoJEAieFpYUBojv0eUIAICpzMEbRVEswZP++n/CrfbK yajH0orbbEPF57s6GrYUVkJo4gJYmrKgEz8EJQLZ/CIV3Vj/AYLQY0L3LjRo788O O8ygs2+k25YhWuy+Y/wDurwGCDlwOyG8aD7tdVikyCMYOBRrCmm2xOSXONCBuNuf uJENtnxDN6H5VpVWhhBpwReJ4ybIFAPK0vnZStw9aaUAX7U7QUmpp0bbKbaa2KSN hNYEDlSgDOMqmLBMI6mUkXcwNZbxrn5hHkqS448TSx+tK/suC85KlsxLm3YznMlV RIM47DIJsOGMbJfflIQSWgxc8AieXMgQODnR+T/9nvzHHdpUQkQLfPixbi4/+vs= =z3Rw -----END PGP SIGNATURE----- --nextPart2204778.c7xfY9ZaEu--