Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 39865 - Option to interactivly emerge (if do emerge -p ask for confirmation do emerge as one command)
Summary: Option to interactivly emerge (if do emerge -p ask for confirmation do emerge...
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Portage team
URL: http://forums.gentoo.org/viewtopic.ph...
Whiteboard:
Keywords:
: 41293 43226 44071 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-01-30 03:58 UTC by Anthony Metcalf
Modified: 2005-02-27 23:47 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to emerge to implement --ask (-a) switch (emerge.patch,2.80 KB, patch)
2004-01-30 07:10 UTC, Ed Catmur
Details | Diff
Patch to emergehelp.py (emergehelp.py.patch,2.39 KB, patch)
2004-01-30 07:13 UTC, Ed Catmur
Details | Diff
Implementing comment 3 (portage-2.0.50_pre21-emerge-ask-emerge.patch,3.43 KB, patch)
2004-02-02 12:13 UTC, Ed Catmur
Details | Diff
ask-mode.patch (ask-mode.patch,6.46 KB, patch)
2004-02-02 14:39 UTC, TGL
Details | Diff
More changes: now supports depclean, sync, inject (portage-2.0.50_pre21-emerge-ask-emerge.patch,5.97 KB, patch)
2004-02-02 20:34 UTC, Ed Catmur
Details | Diff
Check for terminal (portage-2.0.50_pre21-emerge-ask-emerge.patch,6.95 KB, patch)
2004-02-02 21:02 UTC, Ed Catmur
Details | Diff
Fix crash when --clean results in empty list (portage-2.0.50_pre21-emerge-ask-emerge.patch,6.63 KB, patch)
2004-02-04 11:45 UTC, Ed Catmur
Details | Diff
ask_vs_clean.patch (edfix.patch,1.02 KB, patch)
2004-02-04 15:52 UTC, TGL
Details | Diff
Patch to man page (copy from emergehelp.py + formatting) (portage-2.0.50_pre21-emerge-ask-emerge.1.patch,787 bytes, patch)
2004-02-04 17:00 UTC, Ed Catmur
Details | Diff
clean_vs_ask_bis.patch (clean_vs_ask_bis.patch,649 bytes, patch)
2004-02-08 07:14 UTC, TGL
Details | Diff
Patch to handle blockers properly (portage-2.0.50-emerge-ask-blockers-emerge.patch,697 bytes, patch)
2004-02-09 12:28 UTC, Ed Catmur
Details | Diff
--ask turns to --pretend for non-root user (ask2pretend.patch,629 bytes, patch)
2005-02-18 15:31 UTC, Brad Grzesiak
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Metcalf 2004-01-30 03:58:59 UTC
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.
Comment 1 Ed Catmur 2004-01-30 07:10:02 UTC
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
Comment 2 Ed Catmur 2004-01-30 07:13:43 UTC
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.
Comment 3 Nicholas Jones (RETIRED) gentoo-dev 2004-02-01 13:13:15 UTC
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.
Comment 4 Ed Catmur 2004-02-02 12:13:05 UTC
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.
Comment 5 Ed Catmur 2004-02-02 12:19:45 UTC
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.
Comment 6 TGL 2004-02-02 14:39:48 UTC
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?
Comment 7 Ed Catmur 2004-02-02 20:34:04 UTC
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.
Comment 8 Ed Catmur 2004-02-02 21:02:51 UTC
Created attachment 24872 [details, diff]
Check for terminal

Using TGL's code - thanks.
Comment 9 TGL 2004-02-03 09:18:08 UTC
I'm currently using your last submitted patch, and I like it. It definitly has my vote :) 
Thanks.
Comment 10 Ed Catmur 2004-02-04 11:45:57 UTC
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.
Comment 11 TGL 2004-02-04 15:52:11 UTC
Created attachment 24964 [details, diff]
ask_vs_clean.patch

This is just your last update rediffed as a fix for _pre22.
Comment 12 Ed Catmur 2004-02-04 17:00:59 UTC
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!
Comment 13 TGL 2004-02-08 07:14:42 UTC
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
Comment 14 Ed Catmur 2004-02-09 12:28:48 UTC
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.
Comment 15 SpanKY gentoo-dev 2004-02-11 17:51:50 UTC
*** Bug 41293 has been marked as a duplicate of this bug. ***
Comment 16 Masatomo Nakano (RETIRED) gentoo-dev 2004-02-11 21:21:49 UTC
Fixed in CVS about comment #13, #14 and bug 41293.
Comment 17 Masatomo Nakano (RETIRED) gentoo-dev 2004-02-28 14:26:31 UTC
*** Bug 43226 has been marked as a duplicate of this bug. ***
Comment 18 Masatomo Nakano (RETIRED) gentoo-dev 2004-04-09 17:18:38 UTC
*** Bug 44071 has been marked as a duplicate of this bug. ***
Comment 19 Brian Harring (RETIRED) gentoo-dev 2004-08-16 10:40:39 UTC
This has been released for quite some time...
Comment 20 Christophe 2004-08-16 11:09:17 UTC
This bug is not fixed. emerge unmerge <whateverpackage> -a still crash if you asnwer "no".

Cf. Comment #13 From TGL
Comment 21 Christophe 2004-08-16 11:12:09 UTC
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
Comment 22 Brian Harring (RETIRED) gentoo-dev 2004-08-16 15:30:33 UTC
Ahh... .50-r9, not .51.
Another one for .50-r10 is needed.
Comment 23 Christophe 2004-08-25 08:35:44 UTC
Brian : not sure what you meant but not corrected in 50-r10.
do you mean it will be corrected only with 51 ?
Comment 24 Christophe 2004-11-29 12:55:34 UTC
Fixed in portage-2.0.51-r3 (on amd64).
Comment 25 Brad Grzesiak 2005-02-18 15:31:24 UTC
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.
Comment 26 Brian Harring (RETIRED) gentoo-dev 2005-02-27 23:47:46 UTC
--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. :)