From 405fb754c25ca41a3797a3eeaddc581d778217e0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 20 Nov 2006 08:29:10 +0000 Subject: Enable PORTAGE_CONFIGROOT to be set via an new --config-root option. Thanks to Daniel Barkalow for the initial patch (submitted on the gentoo-portage-dev mailing list). svn path=/main/trunk/; revision=5107 --- bin/emerge | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/emerge b/bin/emerge index b99d897da..9f3d38670 100755 --- a/bin/emerge +++ b/bin/emerge @@ -4197,7 +4197,7 @@ def multiple_actions(action1, action2): sys.stderr.write("!!! '%s' or '%s'\n\n" % (action1, action2)) sys.exit(1) -def parse_opts(tmpcmdline): +def parse_opts(tmpcmdline, silent=False): myaction=None myopts = {} myfiles=[] @@ -4206,6 +4206,10 @@ def parse_opts(tmpcmdline): longopt_aliases = {"--cols":"--columns", "--skip-first":"--skipfirst"} argument_options = { + "--config-root": { + "help":"specify the location for portage configuration files", + "action":"store" + }, "--color": { "help":"enable or disable color output", "type":"choice", @@ -4272,7 +4276,9 @@ def parse_opts(tmpcmdline): myfiles.append(x) if "--nocolor" in myopts: - print "*** Deprecated use of '--nocolor', use '--color=n' instead." + if not silent: + sys.stderr.write("*** Deprecated use of '--nocolor', " + \ + "use '--color=n' instead.\n") del myopts["--nocolor"] myopts["--color"] = "n" @@ -4391,6 +4397,14 @@ def adjust_config(myopts, settings): settings.backup_changes("NOCOLOR") def emerge_main(): + # This first pass is just for options that need to be known as early as + # possible, such as --config-root. They will be parsed again later, + # together with EMERGE_DEFAULT_OPTS (which may vary depending on the + # the value of --config-root). + myaction, myopts, myfiles = parse_opts(sys.argv[1:], silent=True) + if "--config-root" in myopts: + os.environ["PORTAGE_CONFIGROOT"] = myopts["--config-root"] + # Portage needs to ensure a sane umask for the files it creates. os.umask(022) settings, trees, mtimedb = load_emerge_config() -- cgit v1.2.3-1-g7c22