[pacman-dev] [PATCH] pmtest: resolve path to scriptlet shell
Dave Reisner
d at falconindy.com
Sun Nov 25 23:05:06 EST 2012
On Sun, Nov 25, 2012 at 05:12:13PM -0500, Dave Reisner wrote:
> In order to support a variety of values for the --with-scriptlet-shell
> configure flag, pmtest has to be aware of what kind of path was passed,
> be it an absolute path or a fragment for a path lookup. For absolute
> paths, leave the path alone. For fragments, search the PATH environment
> var for the resolved path to the binary. In both cases, join the
> resultant path to the root directory defined for the test, not a
> pre-determined bin directory.
>
> Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> ---
> This applies to allan's working branch.
>
> test/pacman/pmtest.py | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/test/pacman/pmtest.py b/test/pacman/pmtest.py
> index b69275b..a644860 100644
> --- a/test/pacman/pmtest.py
> +++ b/test/pacman/pmtest.py
> @@ -103,6 +103,17 @@ def load(self):
> else:
> raise IOError("file %s does not exist!" % self.name)
>
> + def resolve_binary(self, binary):
> + if binary[0] == '/':
Bah, if we're going to bother with os.path.join(), we might as well use
os.path.isabs() here as well. We're plotting to drop support for cygwin,
so this doesn't technically matter a whole lot...
> + return binary
> +
> + for path in os.environ["PATH"].split(':'):
> + resolved = os.path.join(path, binary)
> + if os.path.exists(resolved):
> + return resolved
> +
> + return binary
> +
> def generate(self, pacman):
> print "==> Generating test environment"
>
> @@ -121,13 +132,16 @@ def generate(self, pacman):
> etcdir = os.path.join(self.root, os.path.dirname(util.PACCONF))
> bindir = os.path.join(self.root, "bin")
> sbindir = os.path.join(self.root, "sbin")
> - sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir, sbindir]
> + scriptlet_shell = self.resolve_binary(pacman["scriptlet-shell"])
> + sys_dirs = [dbdir, cachedir, syncdir, tmpdir, logdir, etcdir, bindir,
> + sbindir, os.path.dirname(scriptlet_shell)]
> for sys_dir in sys_dirs:
> if not os.path.isdir(sys_dir):
> vprint("\t%s" % sys_dir[len(self.root)+1:])
> os.makedirs(sys_dir, 0755)
> # Only the dynamically linked binary is needed for fakechroot
> - shutil.copy("/bin/sh", os.path.join(sbindir, pacman["scriptlet-shell"]))
> + if not os.path.samefile("/bin/sh", os.path.join(self.root, scriptlet_shell)):
> + shutil.copy("/bin/sh", os.path.join(self.root, scriptlet_shell))
> shutil.copy(os.path.join(util.SELFPATH, "ldconfig.stub"),
> os.path.join(sbindir, "ldconfig"))
> ld_so_conf = open(os.path.join(etcdir, "ld.so.conf"), "w")
> --
> 1.8.0
>
More information about the pacman-dev
mailing list