public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Cc: Brian Dolbec <dolsen@gentoo.org>
Subject: Re: [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths.
Date: Fri, 13 Dec 2013 21:08:59 -0800	[thread overview]
Message-ID: <CAEdQ38FqdgmAADRB-4To+P02Y=Ri6SEVrsF4=PDpEUe2gi2bCA@mail.gmail.com> (raw)
In-Reply-To: <1386990436-9198-3-git-send-email-dolsen@gentoo.org>

On Fri, Dec 13, 2013 at 7:07 PM, Brian Dolbec <dolsen@gentoo.org> wrote:
> Migrate more hardcoded paths to use settings variables instead.

I can't really make any sense of the commit title, and it'd be
preferable to do one path per patch.

> ---
>  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":"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 "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]):
>                                 """ 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"] + 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)
> --
> 1.8.3.2
>
>

There are piles of unrelated changes. :(


  parent reply	other threads:[~2013-12-14  5:09 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-14  3:07 [gentoo-catalyst] rewrite-on-master patches Brian Dolbec
2013-12-14  3:07 ` [gentoo-catalyst] [PATCH 1/4] Add more configured defaults Brian Dolbec
2013-12-14  4:12   ` Rick "Zero_Chaos" Farina
2013-12-14  4:51   ` Matt Turner
2013-12-14 11:54     ` Brian Dolbec
2013-12-14 14:33   ` Dylan Baker
2013-12-14 16:31     ` W. Trevor King
2013-12-15  0:05     ` W. Trevor King
2013-12-14  3:07 ` [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths Brian Dolbec
2013-12-14  4:26   ` Rick "Zero_Chaos" Farina
2013-12-14  5:08   ` Matt Turner [this message]
2013-12-14 11:15     ` Brian Dolbec
2013-12-14 16:37       ` W. Trevor King
2013-12-14 18:05         ` W. Trevor King
2013-12-14 18:44           ` Matt Turner
2013-12-14 22:24             ` [gentoo-catalyst] [PATCH v2 00/21] rewrite-on-master patches (part 1) W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 01/21] modules/tinderbox_target.py: Use 'portdir' instead of hard-coding '/usr/portage' W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 02/21] modules/generic_stage_target.py: " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 03/21] " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 04/21] modules/generic_stage_target.py: Use 'distdir' instead of hard-coding '${PORTAGE}/distfiles' W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 05/21] modules/generic_stage_target.py: Use a 'local_overlay' setting instead of hard-coding '/usr/local/portage' W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 06/21] catalyst: Split confdefaults into line-per-entry W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 07/21] catalyst: Add 'repo_name' default W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 08/21] catalyst: Add 'snapshot_name' default W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 09/21] catalyst: Add 'packagedir' default instead of hard-coding '/usr/portage/packages' W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 10/21] catalyst: Add 'port_tmpdir' default instead of hard-coding '/var/tmp/portage' W. Trevor King
2013-12-15  2:56                 ` Brian Dolbec
2013-12-15  3:07                   ` W. Trevor King
2013-12-15  3:22                     ` W. Trevor King
2013-12-15  4:00                       ` [gentoo-catalyst] [PATCH v3 00/19] rewrite-on-master patches (part 1) W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 01/19] modules/tinderbox_target.py: Use 'portdir' instead of hard-coding '/usr/portage' W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 02/19] modules/generic_stage_target.py: " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 03/19] " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 04/19] modules/generic_stage_target.py: Use 'distdir' instead of hard-coding '${PORTAGE}/distfiles' W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 05/19] modules/generic_stage_target.py: Use a 'local_overlay' setting instead of hard-coding '/usr/local/portage' W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 06/19] catalyst: Split confdefaults into line-per-entry W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 07/19] catalyst: Add 'repo_name' default W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 08/19] catalyst: Add 'snapshot_name' default W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 09/19] catalyst: Add 'packagedir' default instead of hard-coding '/usr/portage/packages' W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 10/19] modules/generic_stage_target.py: Don't use paths as mountmap keys W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 11/19] modules/generic_stage_target.py: Use 'proc' instead of '/proc' as the mountmap key W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 12/19] modules/generic_stage_target.py: Use 'dev' instead of '/dev' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 13/19] modules/generic_stage_target.py: Use 'distdir' instead of '/usr/portage/distfiles' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 14/19] modules/generic_stage_target.py: Use 'port_tmpdir' instead of '/var/tmp/portage' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 15/19] modules/generic_stage_target.py: Use 'devpts' instead of '/dev/pts' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 16/19] modules/generic_stage_target.py: Use 'packagedir' instead of '/usr/portage/packages' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 17/19] modules/generic_stage_target.py: Use 'kerncache' instead of '/tmp/kerncache' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 18/19] modules/generic_stage_target.py: Use 'ccache' instead of '/var/tmp/ccache' " W. Trevor King
2013-12-15  4:00                         ` [gentoo-catalyst] [PATCH v3 19/19] catalst: improve usage() output formatting slightly W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 11/21] modules/generic_stage_target.py: Don't use paths as mountmap keys W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 12/21] modules/generic_stage_target.py: Use 'proc' instead of '/proc' as the mountmap key W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 13/21] modules/generic_stage_target.py: Use 'dev' instead of '/dev' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 14/21] modules/generic_stage_target.py: Use 'distdir' instead of '/usr/portage/distfiles' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 15/21] modules/generic_stage_target.py: Use 'port_tmpdir' instead of '/var/tmp/portage' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 16/21] modules/generic_stage_target.py: Use 'devpts' instead of '/dev/pts' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 17/21] modules/generic_stage_target.py: Use 'packagedir' instead of '/usr/portage/packages' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 18/21] modules/generic_stage_target.py: Use 'kerncache' instead of '/tmp/kerncache' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 19/21] modules/generic_stage_target.py: Use 'ccache' instead of '/var/tmp/ccache' " W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 20/21] catalst: improve usage() output formatting slightly W. Trevor King
2013-12-14 22:24               ` [gentoo-catalyst] [PATCH v2 21/21] catalyst: cleanup long lines W. Trevor King
2013-12-14 22:29               ` [gentoo-catalyst] Re: [PATCH v2 00/21] rewrite-on-master patches (part 1) W. Trevor King
2013-12-14 23:10                 ` W. Trevor King
2013-12-15  0:24               ` [gentoo-catalyst] " Matt Turner
2013-12-15  1:40                 ` W. Trevor King
2013-12-14 14:51   ` [gentoo-catalyst] [PATCH 2/4] Remove self.mounts and self.mountmap's use of paths for keys and paths Dylan Baker
2013-12-14 16:42     ` W. Trevor King
2013-12-14 21:31       ` Dustin C. Hatch
2013-12-14  3:07 ` [gentoo-catalyst] [PATCH 3/4] Adapt commit c52962b6bd2 to use the new configured settings values Brian Dolbec
2013-12-14  4:59   ` Dustin C. Hatch
2013-12-14  6:12     ` Brian Dolbec
2013-12-14 14:54   ` Dylan Baker
2013-12-14 16:07     ` Dylan Baker
2013-12-14 16:22     ` Brian Dolbec
2013-12-14  3:07 ` [gentoo-catalyst] [PATCH 4/4] cleanup long lines, improve usage() output formatting slightly Brian Dolbec
2013-12-14  5:14   ` Matt Turner
2013-12-14  5:22     ` W. Trevor King
2013-12-14  6:21     ` Brian Dolbec
2013-12-14 14:56       ` Dylan Baker
2013-12-14 16:02         ` Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEdQ38FqdgmAADRB-4To+P02Y=Ri6SEVrsF4=PDpEUe2gi2bCA@mail.gmail.com' \
    --to=mattst88@gentoo.org \
    --cc=dolsen@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox