Re: [gentoo-portage-dev] [PATCH] Add emerge --autounmask-continue option (bug 582624)

2016-07-01 Thread Zac Medico
On 07/01/2016 03:29 AM, Alexander Berntsen wrote:
> The patch itself looks OK, but I think that this option is a bad idea
> and design, and that the extra complexity isn't warranted. I know
> users have asked for something similar several times, but thankfully
> the users aren't the developers.

It's an extremely useful option in certain contexts (especially
continuous integration). I have a wrapper script that does this, but
it's tricky to emulate this behavior with existing options, since
without it there's no way to know whether or not the dependency
calculation was completely successful (then you have to check if an
config changes were made, apply them, and waste time repeating the
dependency calculation all over again without knowing whether or not it
will succeed).

The patch is really much less complex than I had imagined before I
started writing it. I expect it to be quite maintainable.

> But if you genuinely think this is a good idea, and someone else on
> the team does too, I won't oppose it. We should make sure that we
> strongly discourage its usage for regular users. Perhaps your
> suggested manpage addition already does -- I don't know.

Yeah, I think the warning message that I've put in the man patch is
pretty good:

> This option is intended to be used only with great caution,
> since it is possible for it to make nonsensical configuration
> changes which may lead to system breakage. Therefore, it is
> advisable to use ---ask together with this option.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH] Add emerge --autounmask-continue option (bug 582624)

2016-07-01 Thread Francesco Riosa
Hi,
  thanks for your continuous work, just an implementation detail, it may be
possible to avoid a new option reusing the current autounmask one?

instead of
--autounmask [ y | n ]
--autounmask-only [ y | n ]
--autounmask-write [ y | n ]
--autounmask-continue [ y | n ]

something like:
--autounmask [ y | n | only | write | continue]

especially if these options make no sense used together


2016-07-01 12:29 GMT+02:00 Alexander Berntsen :

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA512
>
> The patch itself looks OK, but I think that this option is a bad idea
> and design, and that the extra complexity isn't warranted. I know
> users have asked for something similar several times, but thankfully
> the users aren't the developers.
>
> But if you genuinely think this is a good idea, and someone else on
> the team does too, I won't oppose it. We should make sure that we
> strongly discourage its usage for regular users. Perhaps your
> suggested manpage addition already does -- I don't know.
> - --
> Alexander
> berna...@gentoo.org
> https://secure.plaimi.net/~alexander
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2
>
> iQIcBAEBCgAGBQJXdkX1AAoJENQqWdRUGk8BYbUQAM6EcIv7/2PpOM/ETY6zlZM3
> hHH6X4ZofiMJCaXN+xoppFhJ6+d9851VlMS98r7lTPe4BiMlcjXELkb9ukgHJG2S
> PJtRRo79MlTIH3WB3q7Se+ZIkvtTjikVLKRQgxir5i6UxXgOZgp0ucYguvtnU2U5
> 79bAxXaUwbqt7o51FfR42J+xWjlfKl36cKsbkMCthNzTyGD/eX8L6wHjkphPhZ9I
> hxMdmRKs9eKV6EOIDc5ZP55B3+NBeLo5VXZSylZurrwlkGyFhFFUUnIXRkX/Xod5
> 3Tgk980KrqDwuhZ1tT7Jug8x+uOHYrugZzL9AW/T91ACp9kut2gXYhXATufHXHT4
> 6vCm9BCNwqMQh3GkQCVQEhY1P3okFdR1SXZuzjiSpfbzkZjyIJ1o/Vj/X5/gq+SC
> CWQBgIyoW9hVvIQqHbfnoEewfXhwFpvknl7R8DeWiCZbX462Gjn5dQ4KKZHlQrLk
> nDtvHKmX6aXC7ElQsRMagZ5HevfcU2h4uYbYorkaipNskMFMeGBT5j85jK3Nu9C9
> 0XX6GD+djYDd0L4hk0h6Kb30PZu5p5Y9HIQdia0tspwUDsbSsOdJe/vNYQMNy50z
> Oke0arfNJEY5KfILV5QS1ShkX/2Ot+tZtDsPsEZKMidK5hYZcyeAHQ0MmVLLikkj
> CtWAcVXmHmOz3HH6tVTY
> =buhT
> -END PGP SIGNATURE-
>
>


[gentoo-portage-dev] [PATCH] Add emerge --autounmask-continue option (bug 582624)

2016-07-01 Thread Zac Medico
This option will cause emerge to automatically apply autounmask changes
to configuration files, and continue to execute the specified command.
If the dependency calculation is not entirely successful, then emerge
will simply abort without modifying any configuration files.

This sort of behavior can be very useful in a continuous integration
setting, where the emerge invocation might be inside of a container that
is later discarded (so there is no threat of negative consequences).
It's also safe for general use, when combined with the --ask option.

X-Gentoo-Bug: 582624
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=582624
---
 man/emerge.1| 14 +-
 pym/_emerge/actions.py  | 28 ++--
 pym/_emerge/depgraph.py | 28 
 pym/_emerge/main.py |  9 +
 pym/portage/tests/emerge/test_simple.py |  5 +
 5 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/man/emerge.1 b/man/emerge.1
index bfa2f73..40be14f 100644
--- a/man/emerge.1
+++ b/man/emerge.1
@@ -1,4 +1,4 @@
-.TH "EMERGE" "1" "Feb 2016" "Portage VERSION" "Portage"
+.TH "EMERGE" "1" "Jul 2016" "Portage VERSION" "Portage"
 .SH "NAME"
 emerge \- Command\-line interface to the Portage system
 .SH "SYNOPSIS"
@@ -361,6 +361,18 @@ the specified configuration file(s), or enable the
 \fBEMERGE_DEFAULT_OPTS\fR variable may be used to
 disable this option by default in \fBmake.conf\fR(5).
 .TP
+.BR "\-\-autounmask\-continue [ y | n ]"
+Automatically apply autounmask changes to configuration
+files, and continue to execute the specified command. If
+the dependency calculation is not entirely successful, then
+emerge will simply abort without modifying any configuration
+files.
+\fBWARNING:\fR
+This option is intended to be used only with great caution,
+since it is possible for it to make nonsensical configuration
+changes which may lead to system breakage. Therefore, it is
+advisable to use \fB\-\-ask\fR together with this option.
+.TP
 .BR "\-\-autounmask\-only [ y | n ]"
 Instead of doing any package building, just unmask
 packages and generate package.use settings as necessary
diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
index 2ca7902..ff22687 100644
--- a/pym/_emerge/actions.py
+++ b/pym/_emerge/actions.py
@@ -96,8 +96,22 @@ if sys.hexversion >= 0x300:
 else:
_unicode = unicode
 
-def action_build(settings, trees, mtimedb,
-   myopts, myaction, myfiles, spinner):
+def action_build(emerge_config, trees=DeprecationWarning,
+   mtimedb=DeprecationWarning, myopts=DeprecationWarning,
+   myaction=DeprecationWarning, myfiles=DeprecationWarning, spinner=None):
+
+   if not isinstance(emerge_config, _emerge_config):
+   warnings.warn("_emerge.actions.action_build() now expects "
+   "an _emerge_config instance as the first parameter",
+   DeprecationWarning, stacklevel=2)
+   emerge_config = load_emerge_config(
+   action=myaction, args=myfiles, trees=trees, opts=myopts)
+   adjust_configs(emerge_config.opts, emerge_config.trees)
+
+   settings, trees, mtimedb = emerge_config
+   myopts = emerge_config.opts
+   myaction = emerge_config.action
+   myfiles = emerge_config.args
 
if '--usepkgonly' not in myopts:
old_tree_timestamp_warn(settings['PORTDIR'], settings)
@@ -327,6 +341,11 @@ def action_build(settings, trees, mtimedb,
display_missing_pkg_set(root_config, e.value)
return 1
 
+   if success and mydepgraph.need_config_reload():
+   load_emerge_config(emerge_config=emerge_config)
+   adjust_configs(emerge_config.opts, emerge_config.trees)
+   settings, trees, mtimedb = emerge_config
+
if "--autounmask-only" in myopts:
mydepgraph.display_problems()
return 0
@@ -3230,10 +3249,7 @@ def run_action(emerge_config):
except OSError:
writemsg("Please install eselect to use 
this feature.\n",
noiselevel=-1)
-   retval = action_build(emerge_config.target_config.settings,
-   emerge_config.trees, 
emerge_config.target_config.mtimedb,
-   emerge_config.opts, emerge_config.action,
-   emerge_config.args, spinner)
+   retval = action_build(emerge_config, spinner=spinner)
post_emerge(emerge_config.action, emerge_config.opts,
emerge_config.args, emerge_config.target_config.root,
emerge_config.trees, 
emerge_config.target_config.mtimedb, retval)
diff --git a/pym/_emerge/depgraph.py