Gentoo Archives: gentoo-portage-dev

From: Daniel Barkalow <barkalow@××××××××.org>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH] Replace --ask with --pretend if operation not allowed
Date: Tue, 14 Nov 2006 23:42:19
Message-Id: Pine.LNX.4.64.0611141823220.9789@iabervon.org
1 If some operation requires root or portage access, and the user doesn't
2 have it, and the --ask option is enabled, replace it with --pretend
3 instead of aborting with an error.
4
5 Also rearranges the test for required privs to eliminate the duplication
6 of the consequences, which are not more than 2 lines.
7
8 Applies to current trunk.
9
10 Signed-off-by: Daniel Barkalow <barkalow@××××××××.org>
11
12 Index: bin/emerge
13 ===================================================================
14 --- bin/emerge (revision 5050)
15 +++ bin/emerge (working copy)
16 @@ -4571,15 +4571,17 @@
17 # We've already allowed "--version" and "--help" above.
18 if "--pretend" not in myopts and \
19 myaction not in ("search","info"):
20 - if portage.secpass >= 1:
21 - if "--fetchonly" not in myopts and \
22 - "--fetch-all-uri" not in myopts and \
23 - myaction not in ("metadata", "regen"):
24 + if portage.secpass < 1 or \
25 + ("--fetchonly" not in myopts and \
26 + "--fetch-all-uri" not in myopts and \
27 + myaction not in ("metadata", "regen")):
28 + if "--ask" in myopts:
29 + myopts["--pretend"] = True
30 + del myopts["--ask"]
31 + print "root access would be required... adding --pretend to options."
32 + else:
33 print "emerge: root access required."
34 sys.exit(1)
35 - else:
36 - print "emerge: root access required."
37 - sys.exit(1)
38
39 disable_emergelog = False
40 for x in ("--pretend", "--fetchonly", "--fetch-all-uri"):
41 --
42 gentoo-portage-dev@g.o mailing list

Replies