Merge lp://staging/~ev/ubiquity/use_biggest_free into lp://staging/ubiquity

Proposed by Evan
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~ev/ubiquity/use_biggest_free
Merge into: lp://staging/ubiquity
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~ev/ubiquity/use_biggest_free
Reviewer Review Type Date Requested Status
Ubuntu Installer Team Pending
Review via email: mp+5608@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Evan (ev) wrote :

This branch adds support for displaying the "Use the largest continuous free space" option in the partition bars. Previously ubiquity would create a single Ubuntu partition that filled the entire drive when this option was selected.

It does not add the functionality to the KDE frontend, but does account for changes to base.py and components/partman.py in the KDE frontend.

3227. By Evan

Add support for use_biggest_free in the KDE partition bars.

Revision history for this message
Evan (ev) wrote :

I've now added support in the KDE frontend partition bars, but in the process noticed a major regression. The current code does not preserve partition ordering.

3228. By Evan

Fix incorrect partition ordering by getting rid of the dictionary keyed on partition IDs and move partition IDs into the partition tuple.

Revision history for this message
Evan (ev) wrote :

I think this is ready to go. I've taken care of the partition order problem and tested a number of partition and disk configurations and options (resize, multiple disks, etc) with the GTK frontend and it held up well, short of bug 362334, but that's unrelated to this code.

3229. By Evan

Add LP bug reference.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2009-04-15 15:08:14 +0000
3+++ debian/changelog 2009-04-16 09:32:32 +0000
4@@ -3,6 +3,10 @@
5 [ Evan Dandrea ]
6 * Fix a crash when in OEM mode. Child widgets are members of the
7 self.userinterface list (LP: #361668).
8+ * Add support for displaying the "Use the largest continuous free space"
9+ option in the partition bars. Previously ubiquity would create a single
10+ Ubuntu partition that filled the entire drive when this option was
11+ selected.
12
13 [ Colin Watson ]
14 * Fix stripping of '=dev=' from device names when creating partition bars
15
16=== modified file 'ubiquity/components/partman.py'
17--- ubiquity/components/partman.py 2009-04-02 10:55:16 +0000
18+++ ubiquity/components/partman.py 2009-04-15 18:51:15 +0000
19@@ -359,6 +359,8 @@
20 self.description('partman-auto/text/resize_use_free')
21 self.manual_desc = \
22 self.description('partman-auto/text/custom_partitioning')
23+ self.biggest_free_desc = \
24+ self.description('partman-auto/text/use_biggest_free')
25 self.extra_options = {}
26 if choices:
27 self.auto_state = [0, None]
28@@ -384,21 +386,20 @@
29 except ValueError:
30 pass
31 regain_privileges()
32- # {'/dev/sda' : [ ('/dev/sda1', 24973243297), ('free', 23492732) ], '/dev/sdb' : .., }
33+ # {'/dev/sda' : { '32256-2352430079' : ('/dev/sda1', 24973242), ...
34 parted = parted_server.PartedServer()
35 layout = {}
36 for disk in parted.disks():
37 parted.select_disk(disk)
38- ret = []
39+ ret = {}
40 total = 0
41 for partition in parted.partitions():
42- print 'partition: %s' % str(partition)
43 size = int(partition[2])
44 if partition[4] == 'free':
45 dev = 'free'
46 else:
47 dev = partition[5]
48- ret.append((dev, size))
49+ ret[partition[1]] = (dev, size)
50 layout[disk] = ret
51
52 self.frontend.set_disk_layout(layout)
53@@ -407,61 +408,33 @@
54 # Set up translation mappings to avoid debian-installer
55 # specific text ('Guided -').
56 self.translation_mappings = {}
57- tmp = self.some_device_desc
58- self.some_device_desc = \
59- self.description('ubiquity/text/use_device')
60- self.translation_mappings[self.some_device_desc] = tmp
61- try:
62- choices[choices.index(tmp)] = self.some_device_desc
63- except ValueError:
64- pass
65- if tmp in self.extra_options:
66- t = self.extra_options[tmp]
67- del self.extra_options[tmp]
68- self.extra_options[self.some_device_desc] = t
69+ def map_trans(di_string, ubiquity_string):
70+ ubiquity_string = self.description(ubiquity_string)
71+ self.translation_mappings[ubiquity_string] = di_string
72+ try:
73+ choices[choices.index(di_string)] = ubiquity_string
74+ except ValueError:
75+ pass
76+ if di_string in self.extra_options:
77+ t = self.extra_options[di_string]
78+ del self.extra_options[di_string]
79+ self.extra_options[ubiquity_string] = t
80+ return ubiquity_string
81+
82+ self.some_device_desc = map_trans(self.some_device_desc, 'ubiquity/text/use_device')
83+ self.biggest_free_desc = map_trans(self.biggest_free_desc, 'ubiquity/text/biggest_free')
84+ self.resize_desc = map_trans(self.resize_desc, 'ubiquity/text/resize_use_free')
85+ self.manual_desc = map_trans(self.manual_desc, 'ubiquity/text/custom_partitioning')
86
87- tmp = self.description('partman-auto/text/use_biggest_free')
88- biggest_free = \
89- self.description('ubiquity/text/biggest_free')
90- self.translation_mappings[biggest_free] = tmp
91- try:
92- choices[choices.index(tmp)] = biggest_free
93- except ValueError:
94- pass
95- if tmp in self.extra_options:
96- t = self.extra_options[tmp]
97- del self.extra_options[tmp]
98- self.extra_options[biggest_free] = t
99-
100- tmp = self.resize_desc
101- self.resize_desc = \
102- self.description('ubiquity/text/resize_use_free')
103- self.translation_mappings[self.resize_desc] = tmp
104- try:
105- choices[choices.index(tmp)] = self.resize_desc
106- except ValueError:
107- pass
108- if tmp in self.extra_options:
109- t = self.extra_options[tmp]
110- del self.extra_options[tmp]
111- self.extra_options[self.resize_desc] = t
112-
113- tmp = self.manual_desc
114- self.manual_desc = \
115- self.description('ubiquity/text/custom_partitioning')
116- self.translation_mappings[self.manual_desc] = tmp
117- try:
118- choices[choices.index(tmp)] = self.manual_desc
119- except ValueError:
120- pass
121- if tmp in self.extra_options:
122- t = self.extra_options[tmp]
123- del self.extra_options[tmp]
124- self.extra_options[self.manual_desc] = t
125+ biggest_free = self.find_script(menu_options, 'biggest_free')
126+ if biggest_free:
127+ biggest_free = biggest_free[0][1]
128+ biggest_free = self.split_devpart(biggest_free)[1]
129+ self.extra_options[self.biggest_free_desc] = biggest_free
130
131 self.frontend.set_autopartition_choices(
132- choices, self.extra_options,
133- self.resize_desc, self.manual_desc)
134+ choices, self.extra_options, self.resize_desc,
135+ self.manual_desc, self.biggest_free_desc)
136
137 elif question == 'partman-auto/select_disk':
138 if self.auto_state is not None:
139
140=== modified file 'ubiquity/frontend/base.py'
141--- ubiquity/frontend/base.py 2009-04-02 10:55:16 +0000
142+++ ubiquity/frontend/base.py 2009-04-15 17:11:06 +0000
143@@ -318,10 +318,12 @@
144 pass
145
146 def set_autopartition_choices(self, choices, extra_options,
147- resize_choice, manual_choice):
148+ resize_choice, manual_choice,
149+ biggest_free_choice):
150 """Set available autopartitioning choices."""
151 self.resize_choice = resize_choice
152 self.manual_choice = manual_choice
153+ self.biggest_free_choice = biggest_free_choice
154
155 def get_autopartition_choice(self):
156 """Get the selected autopartitioning choice."""
157
158=== modified file 'ubiquity/frontend/gtk_ui.py'
159--- ubiquity/frontend/gtk_ui.py 2009-04-15 13:18:19 +0000
160+++ ubiquity/frontend/gtk_ui.py 2009-04-16 08:14:40 +0000
161@@ -1285,7 +1285,6 @@
162 element.set_sensitive(False)
163
164 if widget.get_active():
165- choice = unicode(widget.get_label(), 'utf-8', 'replace')
166 self.action_bar.remove_all()
167 self.action_bar.resize = -1
168 if choice == self.manual_choice:
169@@ -1293,12 +1292,19 @@
170 self.release_color)
171 elif choice == self.resize_choice:
172 for k in self.disk_layout:
173- for p in self.disk_layout[k]:
174+ for p in self.disk_layout[k].itervalues():
175 if self.resize_path in p:
176 self.before_bar.remove_all()
177 self.create_bar(k)
178- self.create_bar(k, resize_bar=True)
179+ self.create_bar(k, type=choice)
180 break
181+ elif choice == self.biggest_free_choice:
182+ for k in self.disk_layout:
183+ if self.biggest_free_id in self.disk_layout[k].keys():
184+ self.before_bar.remove_all()
185+ self.create_bar(k)
186+ self.create_bar(k, type=choice)
187+ break
188 else:
189 # Use entire disk.
190 self.action_bar.add_segment_rgb(get_release_name(), -1, \
191@@ -1567,13 +1573,13 @@
192 def set_disk_layout(self, layout):
193 self.disk_layout = layout
194
195- def create_bar(self, disk, resize_bar=False):
196- if resize_bar:
197+ def create_bar(self, disk, type=None):
198+ if type:
199 b = self.action_bar
200 else:
201 b = self.before_bar
202 ret = []
203- for part in self.disk_layout[disk]:
204+ for part in self.disk_layout[disk].itervalues():
205 if part[0].startswith('/'):
206 t = find_in_os_prober(part[0])
207 if t and t != 'swap':
208@@ -1587,10 +1593,12 @@
209 s = self.get_string('ubiquity/text/part_auto_comment_many')
210 self.part_auto_comment_label.set_text(s)
211 i = 0
212- for part in self.disk_layout[disk]:
213+ for key, part in self.disk_layout[disk].iteritems():
214 dev = part[0]
215 size = part[1]
216- if dev == 'free':
217+ if type == self.biggest_free_choice and key == self.biggest_free_id:
218+ b.add_segment_rgb(get_release_name(), size, self.release_color)
219+ elif dev == 'free':
220 b.add_segment_rgb("Free Space", size, b.remainder_color)
221 else:
222 if dev in self.dev_colors:
223@@ -1599,7 +1607,7 @@
224 c = self.auto_colors[i]
225 self.dev_colors[dev] = c
226 b.add_segment_rgb(dev, size, c)
227- if dev == self.resize_path and resize_bar:
228+ if dev == self.resize_path and type == self.resize_choice:
229 self.action_bar.add_segment_rgb(get_release_name(), -1,
230 self.release_color)
231 i = (i + 1) % len(self.auto_colors)
232@@ -1613,7 +1621,7 @@
233 if '(%s)' % disk not in extra:
234 continue
235 l = []
236- for part, size in self.disk_layout[k]:
237+ for part, size in self.disk_layout[k].itervalues():
238 if part == 'free':
239 continue
240 ret = find_in_os_prober(part)
241@@ -1630,9 +1638,11 @@
242 self.format_warnings[extra] = txt
243
244 def set_autopartition_choices (self, choices, extra_options,
245- resize_choice, manual_choice):
246+ resize_choice, manual_choice,
247+ biggest_free_choice):
248 BaseFrontend.set_autopartition_choices(self, choices, extra_options,
249- resize_choice, manual_choice)
250+ resize_choice, manual_choice,
251+ biggest_free_choice)
252
253 if resize_choice in choices:
254 self.resize_min_size, self.resize_max_size, \
255@@ -1642,6 +1652,8 @@
256 self.action_bar.set_min(self.resize_min_size)
257 self.action_bar.set_max(self.resize_max_size)
258 self.action_bar.set_device(self.resize_path)
259+ if biggest_free_choice in choices:
260+ self.biggest_free_id = extra_options[biggest_free_choice]
261
262 for child in self.autopartition_choices_vbox.get_children():
263 self.autopartition_choices_vbox.remove(child)
264@@ -1658,13 +1670,11 @@
265 firstbutton = button
266 self.autopartition_choices_vbox.add(button)
267
268- if choice in extra_options:
269+ if choice in extra_options and choice != biggest_free_choice:
270 alignment = gtk.Alignment(xscale=1, yscale=1)
271 alignment.set_padding(0, 0, 12, 0)
272
273- if choice == resize_choice:
274- pass
275- elif choice != manual_choice:
276+ if choice not in [resize_choice, manual_choice]:
277 extra_combo = gtk.combo_box_new_text()
278 vbox = gtk.VBox(spacing=6)
279 alignment.add(vbox)
280
281=== modified file 'ubiquity/frontend/kde_ui.py'
282--- ubiquity/frontend/kde_ui.py 2009-04-15 13:18:19 +0000
283+++ ubiquity/frontend/kde_ui.py 2009-04-16 09:43:09 +0000
284@@ -1206,9 +1206,11 @@
285 self.disk_layout = layout
286
287 def set_autopartition_choices (self, choices, extra_options,
288- resize_choice, manual_choice):
289+ resize_choice, manual_choice,
290+ biggest_free_choice):
291 BaseFrontend.set_autopartition_choices(self, choices, extra_options,
292- resize_choice, manual_choice)
293+ resize_choice, manual_choice,
294+ biggest_free_choice)
295
296 children = self.userinterface.autopartition_frame.children()
297 for child in children:
298@@ -1285,7 +1287,7 @@
299 frame = None
300
301 # if we have more information about the choice
302- if choice in extra_options:
303+ if choice in extra_options and choice != biggest_free_choice:
304 # label for the before device
305 dev = None
306
307@@ -1333,7 +1335,7 @@
308 after_bar.addPartition(p[6], int(p[2]), int(p[0]), p[4], p[5])
309
310 after_bar.setResizePartition(resize_path,
311- min_size, max_size, orig_size, 'Kubuntu')
312+ min_size, max_size, orig_size, get_release_name())
313
314 before_frame.setVisible(True)
315 after_frame.setVisible(True)
316@@ -1392,10 +1394,11 @@
317 for p in disks[dev]:
318 before_bar.addPartition(p[6], int(p[2]), p[0], p[4], p[5])
319
320+ release_name = get_release_name()
321 if before_bar.diskSize > 0:
322- after_bar.addPartition('', before_bar.diskSize, '', '', 'Kubuntu')
323+ after_bar.addPartition('', before_bar.diskSize, '', '', release_name)
324 else:
325- after_bar.addPartition('', 1, '', '', 'Kubuntu')
326+ after_bar.addPartition('', 1, '', '', release_name)
327
328 before_frame.setVisible(False)
329 after_frame.setVisible(False)
330
331=== modified file 'ubiquity/frontend/noninteractive.py'
332--- ubiquity/frontend/noninteractive.py 2009-02-07 16:49:01 +0000
333+++ ubiquity/frontend/noninteractive.py 2009-04-15 18:49:32 +0000
334@@ -277,11 +277,11 @@
335 pass
336
337 def set_autopartition_choices(self, choices, extra_options,
338- resize_choice, manual_choice):
339+ resize_choice, manual_choice,
340+ biggest_free_choice):
341 """Set available autopartitioning choices."""
342- self.resize_choice = resize_choice
343- self.manual_choice = manual_choice
344- #print '*** set_autopartition_choices: manual_choice: %s' % manual_choice
345+ BaseFrontend.set_autopartition_choices(self, choices, extra_options,
346+ resize_choice, manual_choice, biggest_free_choice)
347
348 def get_autopartition_choice(self):
349 """Get the selected autopartitioning choice."""

Subscribers

People subscribed via source and target branches

to status/vote changes: