Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
On Fri, 17 Nov 2006, Marius Mauch wrote: > I prefer to have one way to do things, and the system for variables > worked quite well so far. Adding CLI overrides on top of that seems not > only redundant to me but also potentially confusing (which vars have CLI > overrides? where in the incremental stack does the override fit in?). > Add that to the already overloaded option system. This particular option clearly can't participate in the incremental stack at all, because it controls which set of config files you read the entire incremental stack out of. So that's not an issue. > Besides, if you need this feature on a somewhat regular base it seems > easier to me to just export the var once instead of specifying the > option on the command line all the time (ok, using DEFAULT_OPTS avoids > that, but then you have the same issues you listed above). config_root is useful primarily when there are multiple configurations that you use. Exporting it in your environment would be profoundly confusing, because then you have different shells that build the same packages differently, with no indication of what's going on. You'd surely end up installing qtopia on your workstation or firefox on your pda. To update your workstation you do: % emerge -pvutDN world To update your pda disk image you do: % emerge --config-root=/etc/pda -pvutDN world -Daniel *This .sig left intentionally blank* -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Marius Mauch wrote: > And last but not least a CLI option is bound to emerge, but this feature can > also be useful for other tools. Checking an env var in the config class would > enable it implicitly for all users of portage.py, without it everyone would > have to basically duplicate the relevant code from emerge. I suppose we can make the env variable an optional fallback if the config_root parameter is unspecified in the config constructor call, but we can't make the env variable mandatory. In order to properly support $ROOT, we need to have at least 2 independent config instances with separate values of PORTAGE_CONFIGROOT. That way, when building packages targeted at $ROOT, build time dependencies that need to be merged to / get an independent config (which may be completely different from that used for $ROOT). Zac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFXcse/ejvha5XGaMRAsxcAKDgSQf+sqpQtSI+G+CjGjj92j0p2wCfUY/s p6y+l8nhMLHcWXtji502QPA= =eWND -END PGP SIGNATURE- -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
On Thu, 16 Nov 2006 15:43:48 -0800 Zac Medico <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Marius Mauch wrote: > > On Thu, 16 Nov 2006 09:33:05 -0800 > > Zac Medico <[EMAIL PROTECTED]> wrote: > > > >> Sure, that's one way to solve that particular problem. However, I feel > >> that command line options are more aesthetically appealing than environment > >> variables (maybe it's just me). > >> > >> Zac > > > > It's just you ;) > > > > Marius > > Do you honestly prefer environment variables over command line options? I > prefer command line options because they are part of a clearly defined > interface. With environment variables, the interface may not be clearly > defined and it's easy for variables to accidentally leak in, affecting > internals in unexpected ways. > > Zac I prefer to have one way to do things, and the system for variables worked quite well so far. Adding CLI overrides on top of that seems not only redundant to me but also potentially confusing (which vars have CLI overrides? where in the incremental stack does the override fit in?). Add that to the already overloaded option system. Besides, if you need this feature on a somewhat regular base it seems easier to me to just export the var once instead of specifying the option on the command line all the time (ok, using DEFAULT_OPTS avoids that, but then you have the same issues you listed above). And last but not least a CLI option is bound to emerge, but this feature can also be useful for other tools. Checking an env var in the config class would enable it implicitly for all users of portage.py, without it everyone would have to basically duplicate the relevant code from emerge. I'm not generally against using CLI options for passing in arguments, but in this case I think it's wrong. Marius -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Marius Mauch wrote: > On Thu, 16 Nov 2006 09:33:05 -0800 > Zac Medico <[EMAIL PROTECTED]> wrote: > >> Sure, that's one way to solve that particular problem. However, I feel >> that command line options are more aesthetically appealing than environment >> variables (maybe it's just me). >> >> Zac > > It's just you ;) > > Marius Do you honestly prefer environment variables over command line options? I prefer command line options because they are part of a clearly defined interface. With environment variables, the interface may not be clearly defined and it's easy for variables to accidentally leak in, affecting internals in unexpected ways. Zac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFXPey/ejvha5XGaMRAvjSAJ423GW15OqFPscOk5Sn2AoE1XfGtACgzNrb AMCDoRVXqpSRn/fnIxTSN8A= =CFbR -END PGP SIGNATURE- -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
On Thu, 16 Nov 2006 09:33:05 -0800 Zac Medico <[EMAIL PROTECTED]> wrote: > Sure, that's one way to solve that particular problem. However, I feel > that command line options are more aesthetically appealing than environment > variables (maybe it's just me). > > Zac It's just you ;) Marius -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simon Stelling wrote: > Daniel Barkalow wrote: >> Allow PORTAGE_CONFIGROOT to be set as a command-line option. It can be >> annoying to get environment variables to emerge, particularly when you >> need sudo and you only want the environment variable some of the time. > > I think it would be better to solve the problem with sudo at its root: > > /etc/sudoers has the following: > > # Reset environment by default > Defaultsenv_reset > > Commenting that out reverts this annoying behaviour and "fixes" all > kinds of "bugs". > Sure, that's one way to solve that particular problem. However, I feel that command line options are more aesthetically appealing than environment variables (maybe it's just me). Zac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFXKDQ/ejvha5XGaMRApmwAKCLKtAUJNWOrfrtws++KGiw0ip16ACg3n8x u0eJkhZkbldVPjYGiQlqaKY= =ELM+ -END PGP SIGNATURE- -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
Daniel Barkalow wrote: Allow PORTAGE_CONFIGROOT to be set as a command-line option. It can be annoying to get environment variables to emerge, particularly when you need sudo and you only want the environment variable some of the time. I think it would be better to solve the problem with sudo at its root: /etc/sudoers has the following: # Reset environment by default Defaultsenv_reset Commenting that out reverts this annoying behaviour and "fixes" all kinds of "bugs". -- Kind Regards, Simon Stelling Gentoo/AMD64 Developer -- gentoo-portage-dev@gentoo.org mailing list
Re: [gentoo-portage-dev] [PATCH] --config-root command-line option
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Daniel Barkalow wrote: > Allow PORTAGE_CONFIGROOT to be set as a command-line option. It can be > annoying to get environment variables to emerge, particularly when you > need sudo and you only want the environment variable some of the time. I've been wanting to do something like this, especially since I've added optparse support to emerge. I'll review you patches and see about merging them. Thanks again! Zac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFFXBqS/ejvha5XGaMRAsegAJ9hdWOYW2n6z4+TEOsSkbW5fKLQJQCfQy59 UQC5cTKLC6GyJ1SxJvr0UUs= =w3CV -END PGP SIGNATURE- -- gentoo-portage-dev@gentoo.org mailing list
[gentoo-portage-dev] [PATCH] --config-root command-line option
Allow PORTAGE_CONFIGROOT to be set as a command-line option. It can be annoying to get environment variables to emerge, particularly when you need sudo and you only want the environment variable some of the time. Also cleans up parsing of options which have to be parsed before the command line that includes EMERGE_DEFAULT_OPTS is assembled. Signed-off-by: Daniel Barkalow <[EMAIL PROTECTED]> Index: bin/emerge === --- bin/emerge (revision 5054) +++ bin/emerge (working copy) @@ -4193,6 +4193,26 @@ sys.stderr.write("!!! '%s' or '%s'\n\n" % (action1, action2)) sys.exit(1) +def parse_early_opts(cmdline): + early={} + normal=[] + for i in cmdline: + isearly = False + if i in ["--ignore-default-opts"]: + isearly = True + for opt in ["--config-root"]: + if i.startswith(opt + "="): + isearly = True + if isearly: + if "=" in i: + idx = i.index("=") + early[i[:idx]] = i[idx+1:] + else: + early[i]=True + else: + normal.append(i) + return early, normal + def parse_opts(tmpcmdline): myaction=None myopts = {} @@ -4286,10 +4306,12 @@ sys.exit(9) del myroot, mysettings -def load_emerge_config(trees=None): +def load_emerge_config(trees=None, config_root=None): kwargs = {} for k, envvar in (("config_root", "PORTAGE_CONFIGROOT"), ("target_root", "ROOT")): kwargs[k] = os.environ.get(envvar, "/") + if config_root: + kwargs["config_root"] = config_root trees = portage.create_trees(trees=trees, **kwargs) settings = trees["/"]["vartree"].settings @@ -4389,12 +4411,19 @@ def emerge_main(): # Portage needs to ensure a sane umask for the files it creates. os.umask(022) - settings, trees, mtimedb = load_emerge_config() + + earlyopts, normalopts = parse_early_opts(sys.argv[1:]) + + config_root_opt = None + if "--config-root" in earlyopts: + config_root_opt = earlyopts["--config-root"] + + settings, trees, mtimedb = load_emerge_config(config_root=config_root_opt) portdb = trees[settings["ROOT"]]["porttree"].dbapi if portage.global_updates(settings, trees, mtimedb["updates"]): mtimedb.commit() # Reload the whole config from scratch. - settings, trees, mtimedb = load_emerge_config(trees=trees) + settings, trees, mtimedb = load_emerge_config(trees=trees, config_root=config_root_opt) portdb = trees[settings["ROOT"]]["porttree"].dbapi ldpath_mtimes = mtimedb["ldpath"] @@ -4414,9 +4443,9 @@ nocolor() tmpcmdline = [] - if "--ignore-default-opts" not in sys.argv: + if "--ignore-default-opts" not in earlyopts: tmpcmdline.extend(settings["EMERGE_DEFAULT_OPTS"].split()) - tmpcmdline.extend(sys.argv[1:]) + tmpcmdline.extend(normalopts) myaction, myopts, myfiles = parse_opts(tmpcmdline) for myroot in trees: -- gentoo-portage-dev@gentoo.org mailing list