Gentoo Archives: gentoo-portage-dev

From: Alec Warner <warnera6@×××××××.edu>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] portage config cleanup bits
Date: Thu, 26 Jan 2006 15:40:49
Message-Id: 43D8ED3C.6060606@egr.msu.edu
In Reply to: [gentoo-portage-dev] [PATCH] portage config cleanup bits by Alec Warner
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 *bump*
5
6 Alec Warner wrote:
7 > config has two sets of environment + use stuff.
8 >
9 > one is called configlist, the other configdict. They are essentially
10 > copies of each other, and since for me dicts with named keys are easier,
11 > plus the old code was written crappily and is hard for me to follow,
12 > nuked that also.
13 >
14 > Also nuked config.backupenv, since it's in configdict anyway.
15 >
16 > Please test this, it works here, want to make sure there are no kinks,
17 > specifically with backupenv.
18
19 - ------------------------------------------------------------------------
20
21 - --- portage.py 2006-01-15 00:08:06.170717008 -0500
22 +++ - 2006-01-15 00:22:00.597106000 -0500
23 @@ -931,17 +931,8 @@
24 self.use_defs = copy.deepcopy(clone.use_defs)
25 self.usemask = copy.deepcopy(clone.usemask)
26
27 - - self.configlist = copy.deepcopy(clone.configlist)
28 - - self.configlist[-1] = os.environ.copy()
29 - - self.configdict = { "globals": self.configlist[0],
30 - - "defaults": self.configlist[1],
31 - - "conf": self.configlist[2],
32 - - "pkg": self.configlist[3],
33 - - "auto": self.configlist[4],
34 - - "backupenv": self.configlist[5],
35 - - "env": self.configlist[6] }
36 + self.configdict = copy.deepcopy(clone.configdict)
37 self.profiles = copy.deepcopy(clone.profiles)
38 - - self.backupenv = copy.deepcopy(clone.backupenv)
39 self.pusedict = copy.deepcopy(clone.pusedict)
40 self.categories = copy.deepcopy(clone.categories)
41 self.pkeywordsdict = copy.deepcopy(clone.pkeywordsdict)
42 @@ -980,11 +971,8 @@
43 }
44
45 self.usemask=[]
46 - - self.configlist=[]
47 - - self.backupenv={}
48 # back up our incremental variables:
49 self.configdict={}
50 - - # configlist will contain: [ globals, defaults, conf, pkg, auto,
51 backupenv (incrementals), origenv ]
52
53 # The symlink might not exist or might not be a symlink.
54 try:
55 @@ -1043,8 +1031,7 @@
56 writemsg("!!! Incorrect multiline literals can cause this. Do not
57 use them.\n")
58 writemsg("!!! Errors in this file should be reported on
59 bugs.gentoo.org.\n")
60 sys.exit(1)
61 - - self.configlist.append(self.mygcfg)
62 - - self.configdict["globals"]=self.configlist[-1]
63 + self.configdict["globals"] = self.mygcfg
64
65 self.mygcfg = {}
66 if self.profiles:
67 @@ -1062,8 +1049,7 @@
68 writemsg("!!! not then please report this to bugs.gentoo.org and,
69 if possible, a dev\n")
70 writemsg("!!! on #gentoo (irc.freenode.org)\n")
71 sys.exit(1)
72 - - self.configlist.append(self.mygcfg)
73 - - self.configdict["defaults"]=self.configlist[-1]
74 + self.configdict["defaults"]=self.mygcfg
75
76 try:
77 # XXX: Should depend on root?
78 @@ -1078,28 +1064,32 @@
79 sys.exit(1)
80
81
82 - - self.configlist.append(self.mygcfg)
83 - - self.configdict["conf"]=self.configlist[-1]
84 + self.configdict["conf"]=self.mygcfg
85
86 - - self.configlist.append({})
87 - - self.configdict["pkg"]=self.configlist[-1]
88 + self.configdict["pkg"]={}
89
90 #auto-use:
91 - - self.configlist.append({})
92 - - self.configdict["auto"]=self.configlist[-1]
93 + self.configdict["auto"]={}
94
95 #backup-env (for recording our calculated incremental variables:)
96 - - self.backupenv = os.environ.copy()
97 - - self.configlist.append(self.backupenv) # XXX Why though?
98 - - self.configdict["backupenv"]=self.configlist[-1]
99 + self.configdict["backupenv"]=os.environ.copy() # XXX Why though? (
100 ferringb? )
101
102 - - self.configlist.append(os.environ.copy())
103 - - self.configdict["env"]=self.configlist[-1]
104 + ### backupenv maybe required to be a clone, and not just a reference
105 + ### the old code did value copy we do a reference here
106 + self.configdict["env"]=self.configdict["backupenv"]
107
108
109 # make lookuplist for loading package.*
110 - - self.lookuplist=self.configlist[:]
111 - - self.lookuplist.reverse()
112 + # This may look like USE_ORDER, it has nothing to do with it.
113 + # Instead this is the way that __getitem__ lookups are performed
114 + # So env first, then backupenv, the auto, pkg, conf, defaults...etc.
115 + self.lookuplist=[self.configdict["env"],
116 + self.configdict["backupenv"],
117 + self.configdict["auto"],
118 + self.configdict["pkg"],
119 + self.configdict["conf"],
120 + self.configdict["defaults"],
121 + self.configdict["globals"]]
122
123 if os.environ.get("PORTAGE_CALLER","") == "repoman":
124 # repoman shouldn't use local settings.
125 @@ -1197,8 +1187,14 @@
126 else:
127 self.pprovideddict[mycatpkg]=[x]
128
129 - - self.lookuplist=self.configlist[:]
130 - - self.lookuplist.reverse()
131 + # make lookuplist for loading package.*
132 + self.lookuplist=[self.configdict["env"],
133 + self.configdict["backupenv"],
134 + self.configdict["auto"],
135 + self.configdict["pkg"],
136 + self.configdict["conf"],
137 + self.configdict["defaults"],
138 + self.configdict["globals"]]
139
140 useorder=self["USE_ORDER"]
141 if not useorder:
142 @@ -1216,7 +1212,7 @@
143 self.uvlist[0:0]=[self.configdict[x]]
144
145 self.configdict["env"]["PORTAGE_GID"]=str(portage_gid)
146 - - self.backupenv["PORTAGE_GID"]=str(portage_gid)
147 + self.configdict["backupenv"]["PORTAGE_GID"]=str(portage_gid)
148
149 if self.has_key("PORT_LOGDIR") and not self["PORT_LOGDIR"]:
150 # port_logdir is defined, but empty. this causes a traceback in
151 doebuild.
152 @@ -1301,17 +1297,17 @@
153
154 def backup_changes(self,key=None):
155 if key and self.configdict["env"].has_key(key):
156 - - self.backupenv[key] = copy.deepcopy(self.configdict["env"][key])
157 + self.configdict["backupenv"][key] =
158 copy.deepcopy(self.configdict["env"][key])
159 else:
160 raise KeyError, "No such key defined in environment: %s" % key
161
162 def reset(self,keeping_pkg=0,use_cache=1):
163 "reset environment to original settings"
164 - - for x in self.configlist[-1].keys():
165 - - if x not in self.backupenv.keys():
166 - - del self.configlist[-1][x]
167 + for x in self.configdict["env"].keys():
168 + if x not in self.configdict["backupenv"].keys():
169 + del self.configdict["env"][x]
170
171 - - self.configdict["env"].update(self.backupenv)
172 + self.configdict["env"].update(self.configdict["backupenv"])
173
174 self.modifiedkeys = []
175 if not keeping_pkg:
176 @@ -1409,7 +1405,8 @@
177 else:
178 self.configdict["auto"]["USE"]=""
179 else:
180 - - mydbs=self.configlist[:-1]
181 + #Abuse the order of lookuplist to emulate old behavior
182 + mydbs=self.lookuplist[:-1]
183
184 myflags=[]
185 for curdb in mydbs:
186 @@ -1442,13 +1439,13 @@
187
188 myflags.sort()
189 #store setting in last element of configlist, the original environment:
190 - - self.configlist[-1][mykey]=string.join(myflags," ")
191 + self.configdict["env"][mykey]=string.join(myflags," ")
192 del myflags
193
194 #cache split-up USE var in a global
195 usesplit=[]
196
197 - - for x in string.split(self.configlist[-1]["USE"]):
198 + for x in string.split(self.configdict["env"]["USE"]):
199 if x not in self.usemask:
200 usesplit.append(x)
201
202 @@ -1466,7 +1463,7 @@
203 if self.configdict["defaults"]["ARCH"] not in usesplit:
204 usesplit.insert(0,self.configdict["defaults"]["ARCH"])
205
206 - - self.configlist[-1]["USE"]=string.join(usesplit," ")
207 + self.configdict["env"]["USE"]=string.join(usesplit," ")
208
209 self.already_in_regenerate = 0
210
211 @@ -1585,21 +1582,7 @@
212 match = x[mykey]
213 break
214
215 - - if 0 and match and mykey in ["PORTAGE_BINHOST"]:
216 - - # These require HTTP Encoding
217 - - try:
218 - - import urllib
219 - - if urllib.unquote(match) != match:
220 - - writemsg("Note: %s already contains escape codes." % (mykey))
221 - - else:
222 - - match = urllib.quote(match)
223 - - except SystemExit, e:
224 - - raise
225 - - except:
226 - - writemsg("Failed to fix %s using urllib, attempting to continue.\n"
227 % (mykey))
228 - - pass
229 - -
230 - - elif mykey == "CONFIG_PROTECT_MASK":
231 + if mykey == "CONFIG_PROTECT_MASK":
232 match += " /etc/env.d"
233
234 return match
235 -----BEGIN PGP SIGNATURE-----
236 Version: GnuPG v1.4.2 (GNU/Linux)
237 Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
238
239 iQIVAwUBQ9jtO2zglR5RwbyYAQK0qA/9El45GCDx/0mt8G3vwfqz9yPbf3qUSQXd
240 Ve8SapcBRrp+8u2ve2FZbuxIkBer59QGY6k/bK2+Yr08fpo82p4wmbl0i1gtwcTB
241 yPrrAaGYoqf5mLiW8JvMDk9cI0A0jAVnswxnZwae+Rc4kDot9y2IeP+g7CqDZy/J
242 khiJPXBSJoky/+HP9uTKIs5LCNcepuhF9yEUXYE2rux/OB5izIzHrsJ1RhHxYiMT
243 SHtyiFp8TDYJiOr8V676WX9+H9iV1b9kc966QeMKEfIwfvqms6gTwGwYWlXK4QUS
244 19j/hzPU9N9xG9I3raLVZlP4i8vxgd4li8uNnCunIKMncON/6ZmMRB/gbVAxeH+D
245 6eVEf6yAaHT5V64/c8qNAO9xHWntq0eg9ZkEkUGryVVTmchklZyx0OgxF4TAb14o
246 ySFtedwVW++aU17mepuGjrG2nyZ8QX/n+egprd5e9as9kTUdprkiVntp4Skb2UI7
247 xCMWBi2DXh4HSft4NKlPvVRBhfmo0w5fsIIJtw/HDijIzOamPM6wePVPBSLrDYqQ
248 fzCHzw++eKXPVwMajozJdD7cJtjYu2BFnqplyP8z50R8g8oiV4WCpt8OfsrwVm7i
249 X6jNJyPruY2Xjq/z3sgKVJb4tLAN5h6y/ZX3J10TRbsSrTnqMzz+9XBv4y7/PbSm
250 A4IUOohQysE=
251 =IKnv
252 -----END PGP SIGNATURE-----
253 --
254 gentoo-portage-dev@g.o mailing list