Gentoo Archives: gentoo-portage-dev

From: jb benoit <benoitj@×××××.fr>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] Display of keyword in emerge : code proposal
Date: Fri, 18 Nov 2005 18:14:25
Message-Id: 437E19B9.8040909@esiee.fr
1 Hello,
2 I'm a newcomer here.
3
4 The subject deal here was originaly posted here :
5 http://forums.gentoo.org/viewtopic-t-403287.html
6
7 I have always wanted to display the keywords involved when you emerge a
8 package.
9 Per exemple, i want to know if the xchat-2.6.0 i'll emerge is a stable
10 version, an unstable or a hard-masked one.
11
12 I have already posted a feature request, but people said it was too
13 difficult.
14 So I decided to make it work myself.
15
16
17 Here is the output of the current portage :
18 *Code:*
19 #emerge portage initng -pv
20
21 These are the packages that I would merge, in order:
22
23 Calculating dependencies ...done!
24
25 [ebuild U ] sys-apps/portage-2.1.0_alpha20050718 [2.0.51.22-r3]
26 -build 456 kB
27 [ebuild U ] sys-apps/initng-0.4.2 [0.4.0] 0 kB [1]
28
29 Total size of downloads: 456 kB
30 Portage overlays:
31 [1] /usr/local/portage
32
33
34
35 My version :
36 *Code:*
37 #./emerge initng portage -pv
38
39 These are the packages that I would merge, in order:
40
41 Calculating dependencies ...done!
42 [ebuild U ] sys-apps/initng-0.4.2 [0.4.0] 0 kB [1] ~x86
43 [ebuild U ] sys-apps/portage-2.1.0_alpha20050718 [2.0.51.22-r3]
44 -build 456 kB ~x86 ~M
45
46 Total size of downloads: 456 kB
47 Portage overlays:
48 [1] /usr/local/portage
49
50
51
52 So you know that you are going to emerge a development version, and
53 another which is a hard masked one.
54 My code take near 30 lines, so i think it can be easely cheked.
55
56 So here is the code :
57 for /usr/lib/portage/pym/portage.py
58 *Code:*
59
60 $ diff -Naur portage.py.sav portage.py
61 --- portage.py.sav 2005-11-17 15:32:20.000000000 +0100
62 +++ portage.py 2005-11-17 15:15:24.000000000 +0100
63 @@ -3866,6 +3866,42 @@
64 pmaskfile.close()
65 return None
66
67 +def getprintablemaskingstatus(mycpv):
68 +
69 + #checking
70 + global portdb
71 + mysplit = catpkgsplit(mycpv)
72 + if not mysplit:
73 + raise ValueError("invalid CPV: %s" % mycpv)
74 + if not portdb.cpv_exists(mycpv):
75 + raise KeyError("CPV %s does not exist" % mycpv)
76 + mycp=mysplit[0]+"/"+mysplit[1]
77 +
78 + #gathering data
79 + mygroups = portdb.aux_get(mycpv, ["KEYWORDS"])[0].split()
80 + myarch = settings["ARCH"]
81 + maskdict=settings.pmaskdict
82 +
83 + rValue=[]
84 + test=0
85 +
86 + # keyword chercking
87 + for gp in mygroups:
88 + if gp=="~"+myarch:
89 + kmask="~"+myarch
90 + rValue.append(kmask)
91 + test = 1
92 +
93 + # package.mask checking
94 + if test == 1:
95 + if maskdict.has_key(mycp):
96 + for x in maskdict[mycp]:
97 + if mycpv in portdb.xmatch("match-all", x):
98 + rValue.append("~M")
99 +
100 + return rValue
101 +
102 +
103 def getmaskingstatus(mycpv):
104 global portdb
105 mysplit = catpkgsplit(mycpv)
106
107
108
109 for /usr/bin/emerge :
110 *Code:*
111
112 $ diff -Naur /usr/bin/emerge emerge
113 --- /usr/bin/emerge 2005-11-17 15:16:31.000000000 +0100
114 +++ emerge 2005-11-17 15:11:48.000000000 +0100
115 @@ -1625,7 +1625,14 @@
116
117 display_overlays=True
118 else:
119 verboseadd += "[No
120 ebuild?]"
121 -
122 +
123 + # keywords display
124 + status =
125 portage.getprintablemaskingstatus(x[2])
126 + if status:
127 + for keywords in status:
128 +
129 verboseadd+=teal(keywords+" ")
130 +
131 +
132 xs=portage.pkgsplit(x[2])
133 if xs[2]=="r0":
134 xs[2]=""
135
136
137
138 I'm working with : sys-apps/portage-2.0.51.22-r3
139
140 Nota: the display of the arch is only available when emerge is called
141 with the -v option
142
143 I'll be pleased to hear your though about, and to know if this can be
144 merged in portage.
145 Thanxs

Replies