Gentoo Archives: gentoo-commits

From: Wiktor W Brodlo <wiktor@××××××.net>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/anaconda:master commit in: /, liveinst/, iw/
Date: Sun, 03 Jul 2011 19:26:22
Message-Id: 47d5a697d7036a01f2ff772c54b8bf7e54d455cb.wiktor@gentoo
1 commit: 47d5a697d7036a01f2ff772c54b8bf7e54d455cb
2 Author: wiktor w brodlo <wiktor <AT> brodlo <DOT> net>
3 AuthorDate: Sun Jul 3 15:47:06 2011 +0000
4 Commit: Wiktor W Brodlo <wiktor <AT> brodlo <DOT> net>
5 CommitDate: Sun Jul 3 15:47:06 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/anaconda.git;a=commit;h=47d5a697
7
8 mirrorselect
9
10 ---
11 dispatch.py | 3 +-
12 gui.py | 4 +-
13 iw/makeconf_gui.py | 50 ++++++++--------
14 iw/mirrorselect_gui.py | 159 ++++++++++++++++++++++++++++++++++++++++++++++++
15 liveinst/liveinst | 1 +
16 5 files changed, 190 insertions(+), 27 deletions(-)
17
18 diff --git a/dispatch.py b/dispatch.py
19 index 08cc685..073dc2c 100644
20 --- a/dispatch.py
21 +++ b/dispatch.py
22 @@ -96,7 +96,8 @@ installSteps = [
23 ("makeconf", ),
24
25 # Installing the Gentoo Base System
26 - # mirrorselect
27 + ("mirrorselect", ),
28 + #("mirrorselect-sync", ),
29 # profile
30 # use
31
32
33 diff --git a/gui.py b/gui.py
34 index 2a8a62f..d6f3821 100755
35 --- a/gui.py
36 +++ b/gui.py
37 @@ -80,7 +80,9 @@ stepToClass = {
38 "makeconf" : ("makeconf_gui", "MakeconfWindow"),
39
40 # Installing the Gentoo Base System
41 -
42 + ("mirrorselect", ),
43 + #("mirrorselect-sync", ),
44 +
45 # Configuring the Kernel
46 "timezone" : ("timezone_gui", "TimezoneWindow"),
47
48
49 diff --git a/iw/makeconf_gui.py b/iw/makeconf_gui.py
50 index c8a77be..9792021 100644
51 --- a/iw/makeconf_gui.py
52 +++ b/iw/makeconf_gui.py
53 @@ -34,29 +34,29 @@ import gettext
54 _ = lambda x: gettext.ldgettext("anaconda", x)
55
56 class MakeconfWindow(InstallWindow):
57 - def getNext(self):
58 - self.anaconda.makeconf.march = self.march.get_active_text()
59 - self.anaconda.makeconf.opt = self.opt.get_active_text()
60 - self.anaconda.makeconf.pipe = self.pipe.get_active()
61 - self.anaconda.makeconf.jobs = self.jobs.get_value_as_int()
62 - self.anaconda.makeconf.load = self.load.get_value_as_int()
63 - self.anaconda.makeconf.silent = self.silent.get_active()
64 - return None
65 -
66 - def getScreen(self, anaconda):
67 - self.anaconda = anaconda
68 - self.intf = anaconda.intf
69 -
70 - (self.xml, self.align) = gui.getGladeWidget("makeconf.glade", "makeconf_align")
71 -
72 - self.march = self.xml.get_widget("march")
73 - self.opt = self.xml.get_widget("opt")
74 - self.pipe = self.xml.get_widget("pipe")
75 - self.jobs = self.xml.get_widget("jobs")
76 - self.load = self.xml.get_widget("load")
77 - self.silent = self.xml.get_widget("silent")
78 -
79 - # TODO: Get a list of arches available for this installation.
80 -
81 - return self.align
82 + def getNext(self):
83 + self.anaconda.makeconf.march = self.march.get_active_text()
84 + self.anaconda.makeconf.opt = self.opt.get_active_text()
85 + self.anaconda.makeconf.pipe = self.pipe.get_active()
86 + self.anaconda.makeconf.jobs = self.jobs.get_value_as_int()
87 + self.anaconda.makeconf.load = self.load.get_value_as_int()
88 + self.anaconda.makeconf.silent = self.silent.get_active()
89 + return None
90 +
91 + def getScreen(self, anaconda):
92 + self.anaconda = anaconda
93 + self.intf = anaconda.intf
94 +
95 + (self.xml, self.align) = gui.getGladeWidget("makeconf.glade", "makeconf_align")
96 +
97 + self.march = self.xml.get_widget("march")
98 + self.opt = self.xml.get_widget("opt")
99 + self.pipe = self.xml.get_widget("pipe")
100 + self.jobs = self.xml.get_widget("jobs")
101 + self.load = self.xml.get_widget("load")
102 + self.silent = self.xml.get_widget("silent")
103 +
104 + # TODO: Get a list of arches available for this installation.
105 +
106 + return self.align
107
108
109 diff --git a/iw/mirrorselect_gui.py b/iw/mirrorselect_gui.py
110 new file mode 100644
111 index 0000000..564c433
112 --- /dev/null
113 +++ b/iw/mirrorselect_gui.py
114 @@ -0,0 +1,159 @@
115 +#
116 +# mirrorselect_gui.py: gui mirrorselect.
117 +#
118 +# Copyright (C) 2011 wiktor w brodlo
119 +# Copyright (C) 2011 Gentoo Foundation
120 +#
121 +# This program is free software; you can redistribute it and/or modify
122 +# it under the terms of the GNU General Public License as published by
123 +# the Free Software Foundation; either version 2 of the License, or
124 +# (at your option) any later version.
125 +#
126 +# This program is distributed in the hope that it will be useful,
127 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
128 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
129 +# GNU General Public License for more details.
130 +#
131 +# You should have received a copy of the GNU General Public License
132 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
133 +#
134 +
135 +import string
136 +import gtk
137 +import gtk.glade
138 +import gtk.gdk
139 +import gobject
140 +import pango
141 +import sys
142 +import gui
143 +import os
144 +from mirrorselect.mirrorparser3 import MirrorParser3
145 +
146 +from iw_gui import *
147 +
148 +from constants import *
149 +import gettext
150 +_ = lambda x: gettext.ldgettext("anaconda", x)
151 +
152 +class MirrorselectWindow(InstallWindow):
153 + def getNext(self):
154 + self.anaconda.makeconf.march = self.march.get_active_text()
155 + self.anaconda.makeconf.opt = self.opt.get_active_text()
156 + self.anaconda.makeconf.pipe = self.pipe.get_active()
157 + self.anaconda.makeconf.jobs = self.jobs.get_value_as_int()
158 + self.anaconda.makeconf.load = self.load.get_value_as_int()
159 + self.anaconda.makeconf.silent = self.silent.get_active()
160 + return None
161 +
162 + def getScreen(self, anaconda):
163 + self.anaconda = anaconda
164 + self.intf = anaconda.intf
165 +
166 + (self.xml, self.align) = gui.getGladeWidget("mirrorselect.glade", "mirrorselect_align")
167 +
168 + mirrorsf = None
169 +
170 + while mirrorsf == None:
171 + # Try downloading the mirrorlist
172 + mirrorsf = self.downloadMirrorlist()
173 + # if failed,
174 + if mirrorsf == None:
175 + md = gtk.MessageDialog(buttons=gtk.BUTTONS_YES_NO)
176 + md.set_property("title", _("Failed to download mirrorlist"))
177 + md.set_property("text", _("Failed to download the mirror list. Would you like to try again?\nPressing 'No' will abort the installation."))
178 + if md.run() == gtk.RESPONSE_NO:
179 + md.destroy()
180 + InstallControlWindow._doExit([])
181 +
182 + self.xml.get_widget("downloading").destroy()
183 +
184 + mirrors_parsed = self.parseMirrors(mirrorsf)
185 + self.mirrors = self.mirrorList(mirrors_parsed, proto)
186 +
187 + self.table = self.xml.get_widget("mirrors_table")
188 +
189 + addMirrors(self.table, self.mirrors, mirrors_parsed)
190 +
191 + return self.align
192 +
193 + def addMirrors(self, table, mirror_list, mirror_data):
194 + (regions, countries, mirrors) = mirror_list
195 +
196 + for region in regions:
197 + for country in countries:
198 + for mirror in mirrors:
199 + addMirrorRow(table, region, country, mirror, mirror_data[region][country][mirror])
200 +
201 + def addMirrorRow(self, table, region, country, mirror, data):
202 + cols = table.get_property("n-columns")
203 + rows = table.get_property("n-rows")
204 + table.resize(rows+1, cols)
205 +
206 + cb = gtk.CheckButton(label=data["url"], use_underline=False)
207 + name = gtk.Label("%s: %s\n%n" % (region, country, mirror))
208 +
209 + flags_text = data["proto"]
210 + if data["ipv4"] == "y":
211 + flags_text += " ipv4"
212 + if data["ipv6"] == "y":
213 + flags_text += " ipv6"
214 + flags = gtk.Label(flags_text)
215 +
216 + table.attach(cb, 0, 1, rows, rows+1)
217 + table.attach(cb, 1, 2, rows, rows+1)
218 + table.attach(cb, 2, 3, rows, rows+1)
219 +
220 + def downloadMirrorlist(self):
221 + try:
222 + os.system("wget -nc -O /tmp/mirror3.xml %s" % os.environ["PORTAGE_MIRRORLIST_URL"])
223 + f = open("/tmp/mirror3.xml")
224 + except:
225 + return None
226 + return f
227 +
228 + def parseMirrors(self, mirrorlist):
229 + xml = mirrorlist.read()
230 + parser = MirrorParser3()
231 + parser.parse(xml)
232 + tuples = parser.tuples()
233 +
234 + mirrors = {}
235 + for mirror in tuples:
236 + if mirror[1]["region"] not in mirrors:
237 + mirrors[mirror[1]["region"]] = {}
238 + if mirror[1]["country"] not in mirrors[mirror[1]["region"]]:
239 + mirrors[mirror[1]["region"]][mirror[1]["country"]] = {}
240 + mirrors[mirror[1]["region"]][mirror[1]["country"]]["%s (%s)" % (mirror[1]["name"], mirror[1]["proto"])] = \
241 + {"url": mirror[0],
242 + "name": mirror[1]["name"],
243 + "proto": mirror[1]["proto"],
244 + "ipv4": mirror[1]["ipv4"],
245 + "ipv6": mirror[1]["ipv6"]}
246 +
247 + return mirrors
248 +
249 + def mirrorList(self, mirrors_parsed, proto):
250 + region_list = mirrors_parsed.keys()
251 + region_list.sort()
252 + countries = {}
253 + mirrors = {}
254 + mirrors_proto = {}
255 + for region in region_list:
256 + countries[region] = mirrors_parsed[region].keys()
257 + countries[region].sort()
258 + for country in countries[region]:
259 + mirrors[country] = mirrors_parsed[region][country].keys()
260 + mirrors[country].sort()
261 + mirrors_proto[country] = []
262 + for mirror in mirrors[country]:
263 + if proto == "http+ftp":
264 + if mirrors_parsed[region][country][mirror]["proto"] == "http":
265 + mirrors_proto[country].append(mirror)
266 + if mirrors_parsed[region][country][mirror]["proto"] == "ftp":
267 + mirrors_proto[country].append(mirror)
268 + if mirrors_parsed[region][country][mirror]["proto"] == proto:
269 + mirrors_proto[country].append(mirror)
270 + mirrors_proto[country].sort()
271 +
272 + return (region_list, countries, mirrors_proto)
273 +
274
275 diff --git a/liveinst/liveinst b/liveinst/liveinst
276 index 9565af4..aa729ba 100755
277 --- a/liveinst/liveinst
278 +++ b/liveinst/liveinst
279 @@ -41,6 +41,7 @@ export ANACONDA_CHROOTPATH="/mnt/sysimage/.//" # that's a BUG!
280 export ANACONDA_PRODUCTARCH="$(cat /etc/livedvd-release | cut -d' ' -f 3)"
281 export ANACONDA_BUGURL="http://bugs.gentoo.org"
282 export PIXMAPPATH="/usr/share/anaconda/pixmaps"
283 +export PORTAGE_MIRRORLIST_URL="http://www.gentoo.org/main/en/mirrors3.xml"
284
285 function kill_mounts() {
286 # devkit-disks is now mounting lots of stuff. for now, let's just try to unmount it all