See the link for comments on the addition to portage. Checking dependancies the second time is redundant if nothing changes between emerge -p and emerge. This kills time on small machines. It would be very nice if we could have a situation like in TGL's post. This could be enabled in make.conf perhaps? Reproducible: Always Steps to Reproduce: 1. emerge -p <something> 2. emerge <something> 3. Actual Results: Dependencies are checked twice, this is redundant.
Created attachment 24638 [details, diff] Patch to emerge to implement --ask (-a) switch Option name: --ask (short form -a) Example output: ======== # emerge -av app-office/dia2code These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild N ] app-office/dia-0.92.2 +gnome +png +python 2,719 kB [ebuild N ] app-office/dia2code-0.8.1 69 kB Total size of downloads: 2,789 kB OVERLAY: *1:/usr/local/portage Do you want me to merge these packages? [Yes/No] n Quitting. ======== Note: patch is against portage 2.0.50_pre21
Created attachment 24640 [details, diff] Patch to emergehelp.py Options: --ask (-a short option) before performing the merge, display what ebuilds and tbz2s will be installed, in the same format as when using --pretend; then ask whether to continue with the merge or abort. Using --ask is more efficient than using --pretend and then executing the same command without --pretend, as dependencies will only need to be calculated once.
Make the input code a getyn function, and make sure that your choice of modes doesn't preclude a control-c or a control-z from applying.
Created attachment 24824 [details, diff] Implementing comment 3 I wasn't sure what file the getYN style function ought to go in, so I just put it at the beginning of emerge. I'll split it out if you tell me where it should go. Ctrl+Z is not explicitly handled, so it behaves as expected. Ctrl+C is caught (try: ... except KeyboardInterrupt) and handled with sys.exit(1), which I think is roughly correct behaviour.
To clarify: sys.exit(1) on Ctrl+C is OK as portage is not at that stage doing anything that needs to be cleaned up. Basically I wanted to avoid a stack trace as issuing Ctrl+C at a prompt should be expected user behaviour. If other code wants to use my function and needs to clean up, it can catch SystemExit.
Created attachment 24837 [details, diff] ask-mode.patch Hi Ed, I was offline this last few days, so i've also implemented --ask on my side. Sounds like a duplicate, but I thought you may be interrested to see this version. Some differences are: - you've made a big "--ask" case in emerge, whereas i've put some ask for confirmation at various places, in general where there where already some pretend code. Don't know what is better: your approach is more local and your messages are pertinent depending on which action is to be confirmed, whereas is shorter. I don't really have a preference. - your version catch sigint whereas mine relies on the existing handler, which i think is better, but as you explained it's not a big issue. But mine doesn't behave well on ctrl+z (i had not thought of that before reading Nick's comment... and it may be a bigger issue.) - my version takes care of "depclean" whereas yours doesn't. But yours accepts "fetchonly" whereas mine doesn't. I've not tested your version yet, but looking at the code it seems maybe more polished than mine. And I've not tested mine much, it was just an half a battery hack in the train, so maybe the best would be to use your version, but add it support for depclean. What do you think?
Created attachment 24870 [details, diff] More changes: now supports depclean, sync, inject I think our handling of where to ask for confirmation is actually fairly similar. The only real difference is the decision of whether to use a generic or specific prompts; the code structure follows directly; anyway, it's 2 calls to the ask function vs. 3. Regarding the input part, I'm not particularly experienced with Python so I went for the simplest solution. Personally I'm not a fan of input routines that only take a single character; for the sake of consistency and being able to edit a response I much prefer readline-style input handling, at which point using raw_input() is pretty much forced. I've added in depclean support as you suggested, and also sync (giving the server address) and inject.
Created attachment 24872 [details, diff] Check for terminal Using TGL's code - thanks.
I'm currently using your last submitted patch, and I like it. It definitly has my vote :) Thanks.
Created attachment 24953 [details, diff] Fix crash when --clean results in empty list I can't believe I missed this. I've changed `depending on the return value of the unmerge() function' to `adding "--pretend" to myopts when the users says no' as this seems better logic and prevents the crash in an intelligent way.
Created attachment 24964 [details, diff] ask_vs_clean.patch This is just your last update rediffed as a fix for _pre22.
Created attachment 24974 [details, diff] Patch to man page (copy from emergehelp.py + formatting) Thanks and thanks again. As atonement, here's the patch to the man page. Sorry!
Created attachment 25191 [details, diff] clean_vs_ask_bis.patch Here is a small 2.0.50 fix for this traceback: Do you want me to unmerge these packages? [Yes/No] n Traceback (most recent call last): File "/usr/bin/emerge", line 2451, in ? if 1==unmerge(myaction, myfiles): File "/usr/bin/emerge", line 1917, in unmerge __main__.myopts+=["--pretend"] NameError: global name '__main__' is not defined
Created attachment 25285 [details, diff] Patch to handle blockers properly Patch against portage 2.0.50 Outputs the following message: !!! Error: The above package list contains packages which cannot be installed !!! on the same system. !!! Please resolve blockers and then re-run emerge. Current behaviour is to display the '--ask' prompt even though 'y' results in the 'blocking packages' error.
*** Bug 41293 has been marked as a duplicate of this bug. ***
Fixed in CVS about comment #13, #14 and bug 41293.
*** Bug 43226 has been marked as a duplicate of this bug. ***
*** Bug 44071 has been marked as a duplicate of this bug. ***
This has been released for quite some time...
This bug is not fixed. emerge unmerge <whateverpackage> -a still crash if you asnwer "no". Cf. Comment #13 From TGL
Using portage-2.0.50-r9 # emerge unmerge gedit -a >>> These are the packages that I would unmerge: app-editors/gedit selected: 2.6.2 protected: none omitted: none >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. Do you want me to unmerge these packages? [Yes/No] n Traceback (most recent call last): File "/usr/bin/emerge", line 2366, in ? if 1==unmerge(myaction, myfiles): File "/usr/bin/emerge", line 1833, in unmerge __main__.myopts+=["--pretend"] NameError: global name '__main__' is not defined
Ahh... .50-r9, not .51. Another one for .50-r10 is needed.
Brian : not sure what you meant but not corrected in 50-r10. do you mean it will be corrected only with 51 ?
Fixed in portage-2.0.51-r3 (on amd64).
Created attachment 51553 [details, diff] --ask turns to --pretend for non-root user This patch simply changes the "--ask" option into "--pretend" if the user is not root. It also displays a polite message regarding this fact. Currently, emerge --ask foo will merely say: emerge: root access required.
--ask feature is stabled already. Regarding making it a non-root first run, ... no. :) There is a seperate bug about building pkgs w/ privs dropped, till that's done, --ask should be root only. Besides that, converting --ask to --pretend if the user is non-root isn't what the user asked for- they asked for --ask. :)