From: Brian Dolbec <dolsen@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: Re: [gentoo-catalyst] [PATCH 5/6] modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary
Date: Sat, 28 Dec 2013 22:01:02 -0800 [thread overview]
Message-ID: <1388296862.24088.47.camel@big_daddy.dol-sen.ca> (raw)
In-Reply-To: <CAAr7Pr8ZrXARZK2+1-G9o8Z-3RiEto9aC70DH30j1msTv5Wa1g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 7657 bytes --]
On Sat, 2013-12-28 at 21:26 -0800, Alec Warner wrote:
> On Sat, Dec 28, 2013 at 5:57 PM, Brian Dolbec <dolsen@gentoo.org>
>
>
> I've avoided commenting on + in strings, as my understanding was that
> we were not doing style fixups in these CLs. I would argue that in
> general, any time you use string + string in python, you are doing it
> wrong (e.g. your code is not 'pythonic')
>
>
> You can use
>
>
> "%s:%s" % (string1, string2) or ":".join(string1, string2)
>
>
> Either are fine, and are nominally better than string + string +
> string.
>
>
Actually string + string is faster than "%s%s" %(string1, string2) for
simple string adition like this example. However %s substitution
performs better for larger multiples which occur many, many times
throughout the code. So, yes we should clean this up after the current
rewrite code is merged in one form or another.
>
>
>
> 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"] + src)
> + cmd = "mount -t devfs
> none " + target
> + retval=os.system(cmd)
>
>
> "because the code use to do it" aside, is there some compelling reason
> to not use subprocess.Popen here? os.system is probably the worst
> syscall you can use. It spawns a shell, it will select things like
> './mount' over '/usr/bin/mount' because you failed to specify the full
> path to the binary, its not clear what environment the shell is using.
>
>
> Even something like:
>
>
> import subprocess
> retval = subprocess.call(cmd.split())
>
>
> would likely avoid these problems unless you are relying on shell
> expansion in cmd?
>
>
>
Yes, I have changed the primary chroot run from the old cloned portage
spawn()'s to using subprocess.Popen. Coming to you in a future commit
waiting it's turn here. I have not yet tackled these os.system() calls.
These changes just moved the string addition out of the function call as
a preparation for it's replacement.
There is no shortage of things that need fixing...
There are lots more uses of os.system() below...
>
>
> else:
> - retval =
> os.system("mount_nullfs " + src + " " +
> -
> self.settings["chroot_path"] + src)
> + cmd = "mount_nullfs "
> + src + " " + target
> + retval=os.system(cmd)
> else:
> if src == "tmpfs":
> if "var_tmpfs_portage"
> in self.settings:
> -
> retval=os.system("mount -t tmpfs -o size="+\
> -
> self.settings["var_tmpfs_portage"]+"G "+src+" "+\
> -
> self.settings["chroot_path"]+x)
> + cmd = "mount
> -t tmpfs -o size=" + \
> +
> self.settings["var_tmpfs_portage"] + "G " + \
> + src +
> " " + target
> +
> retval=os.system(cmd)
> else:
> - retval =
> os.system("mount --bind " + src + " " +
> -
> self.settings["chroot_path"] + src)
> + cmd = "mount --bind "
> + src + " " + target
> + #print "bind(); cmd
> =", cmd
> + retval=os.system(cmd)
> if retval!=0:
> self.unbind()
> raise CatalystError,"Couldn't
> bind mount " + src
> @@ -935,26 +962,25 @@ 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 +
> self.mountmap[x]):
> + target = normpath(mypath +
> self.target_mounts[x])
> + if not os.path.exists(target):
> continue
>
> - if not ismount(mypath +
> self.mountmap[x]):
> + if not ismount(target):
> continue
>
> - retval=os.system("umount "+\
> - os.path.join(mypath,
> self.mountmap[x].lstrip(os.path.sep)))
> + retval=os.system("umount " + target)
>
> if retval!=0:
> - warn("First attempt to
> unmount: " + mypath +
> - self.mountmap[x] +"
> failed.")
> + warn("First attempt to
> unmount: " + target + " failed.")
> warn("Killing any pids still
> running in the chroot")
>
> self.kill_chroot_pids()
>
> - retval2 = os.system("umount "
> + mypath + self.mountmap[x])
> + retval2 = os.system("umount "
> + target)
> if retval2!=0:
> ouch=1
> - warn("Couldn't umount
> bind mount: " + mypath + self.mountmap[x])
> + warn("Couldn't umount
> bind mount: " + target)
>
> if "SNAPCACHE" in self.settings and x
> == "/usr/portage":
> try:
> diff --git a/modules/stage1_target.py
> b/modules/stage1_target.py
> index aa43926..1e0d874 100644
> --- a/modules/stage1_target.py
> +++ b/modules/stage1_target.py
> @@ -88,8 +88,9 @@ class stage1_target(generic_stage_target):
>
> os.makedirs(self.settings["stage_path"]+"/proc")
>
> # alter the mount mappings to bind mount proc
> onto it
> - self.mounts.append("/tmp/stage1root/proc")
> - self.mountmap["/tmp/stage1root/proc"]="/proc"
> + self.mounts.append("stage1root/proc")
> + self.target_mounts["stage1root/proc"] =
> "/tmp/stage1root/proc"
> + self.mountmap["stage1root/proc"]="/proc"
>
> def register(foo):
> foo.update({"stage1":stage1_target})
> --
> 1.8.3.2
>
>
>
>
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 620 bytes --]
next prev parent reply other threads:[~2013-12-29 6:01 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-29 1:57 [gentoo-catalyst] Patches to fix rebased patches already applied to current master Brian Dolbec
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 1/6] modules/generic_stage_target.py: USE portdir, distdir,... instead of paths for keys Brian Dolbec
2013-12-29 2:16 ` W. Trevor King
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 2/6] Fix a missed self.settings["repo_name"] migration Brian Dolbec
2013-12-29 2:19 ` W. Trevor King
2013-12-29 5:08 ` Brian Dolbec
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 3/6] Add "local_overlay" to configdefaults Brian Dolbec
2013-12-29 2:24 ` W. Trevor King
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 4/6] Fix a missed self.mounts key change from a path as key Brian Dolbec
2013-12-29 2:30 ` W. Trevor King
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 5/6] modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary Brian Dolbec
2013-12-29 2:49 ` W. Trevor King
2013-12-29 3:52 ` W. Trevor King
2013-12-29 4:58 ` Brian Dolbec
2013-12-31 2:54 ` [gentoo-catalyst] mounts changes was: " Brian Dolbec
2013-12-31 3:06 ` [gentoo-catalyst] Re: mounts changes W. Trevor King
2014-01-01 6:05 ` [gentoo-catalyst] mounts changes was: [PATCH 5/6] modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary Jorge Manuel B. S. Vicetto
2014-01-01 18:53 ` W. Trevor King
2014-01-02 2:50 ` Jorge Manuel B. S. Vicetto
2013-12-29 5:02 ` [gentoo-catalyst] " Brian Dolbec
2013-12-29 5:26 ` Alec Warner
2013-12-29 6:01 ` Brian Dolbec [this message]
2013-12-29 1:57 ` [gentoo-catalyst] [PATCH 6/6] Set mountmap["icecream"] from settings for now Brian Dolbec
2013-12-29 2:53 ` W. Trevor King
2013-12-29 3:00 ` W. Trevor King
2013-12-30 1:50 ` [gentoo-catalyst] Patches to fix rebased patches already applied to current master. Version-2 Brian Dolbec
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 1/6] modules/generic_stage_target.py: Use portdir, distdir,... instead of paths for keys Brian Dolbec
2013-12-30 3:54 ` W. Trevor King
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 2/6] Fix a missed self.settings["repo_name"] migration Brian Dolbec
2013-12-30 3:58 ` W. Trevor King
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 3/6] Fixes commit 463d98f (modules/generic_stage_target.py: Use a 'local_overlay' setting instead of hard-coding '/usr/local/portage', 2012-12-19).Add "local_overlay" to configdefaults Brian Dolbec
2013-12-30 4:02 ` W. Trevor King
2013-12-30 5:32 ` Brian Dolbec
2013-12-30 6:35 ` W. Trevor King
2013-12-30 6:48 ` Brian Dolbec
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 4/6] Fix mounts and mountmap port_logdir code block Brian Dolbec
2013-12-30 4:09 ` W. Trevor King
2013-12-30 5:46 ` Brian Dolbec
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 5/6] modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary Brian Dolbec
2013-12-30 4:16 ` W. Trevor King
2013-12-30 1:50 ` [gentoo-catalyst] [PATCH 6/6] Set mountmap["icecream"] from settings for now Brian Dolbec
2013-12-30 4:19 ` W. Trevor King
2013-12-30 3:33 ` [gentoo-catalyst] Patches to fix rebased patches already applied to current master. Version-2 W. Trevor King
2014-01-03 4:16 ` [PATCH v3 0/6] "Re: " Brian Dolbec
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 1/6] modules/generic_stage_target.py: Use portdir, distdir, ... instead of paths for keys Brian Dolbec
2014-01-03 4:30 ` [gentoo-catalyst] " W. Trevor King
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 2/6] Fix a missed self.settings["repo_name"] migration Brian Dolbec
2014-01-03 4:33 ` W. Trevor King
2014-01-03 4:53 ` [gentoo-catalyst] [PATCH v4 1/1] " Brian Dolbec
2014-01-03 5:02 ` Brian Dolbec
2014-01-03 5:09 ` [gentoo-catalyst] [PATCH v5 " Brian Dolbec
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 3/6] Add "local_overlay" to configdefaults Brian Dolbec
2014-01-03 4:36 ` W. Trevor King
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 4/6] Fix mounts and mountmap port_logdir code block Brian Dolbec
2014-01-03 4:40 ` W. Trevor King
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 5/6] modules/generic_stage_target.py, modules/stage1_target.py: Add a target_mounts dictionary Brian Dolbec
2014-01-03 4:47 ` W. Trevor King
2014-01-03 6:08 ` W. Trevor King
2014-01-03 6:55 ` Brian Dolbec
2014-01-03 4:16 ` [gentoo-catalyst] [PATCH v3 6/6] Set mountmap["icecream"] from settings for now Brian Dolbec
2014-01-03 4:48 ` W. Trevor King
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=1388296862.24088.47.camel@big_daddy.dol-sen.ca \
--to=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