Merge lp:~yuningdodo/usb-creator/usb-creator.lp1159016-mangle-grub into lp:usb-creator

Proposed by Yu Ning
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 463
Merged at revision: 463
Proposed branch: lp:~yuningdodo/usb-creator/usb-creator.lp1159016-mangle-grub
Merge into: lp:usb-creator
Diff against target: 62 lines (+38/-0)
1 file modified
usbcreator/install.py (+38/-0)
To merge this branch: bzr merge lp:~yuningdodo/usb-creator/usb-creator.lp1159016-mangle-grub
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
Review via email: mp+250267@code.launchpad.net

Description of the change

* usbcreator/install.py: adjust grub configurations, otherwise the persistent mode can't be enabled with UEFI BIOS. (LP: #1159016)

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks reasonable, I'll do some testing and let you know how well it goes.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Looks good to me, approved. I'll merge this tomorrow (unless someone beats me to it) since it's getting late.

review: Approve
Revision history for this message
Yu Ning (yuningdodo) wrote :

Thank you very much

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'usbcreator/install.py'
2--- usbcreator/install.py 2013-01-28 12:44:46 +0000
3+++ usbcreator/install.py 2015-02-19 07:39:13 +0000
4@@ -324,6 +324,42 @@
5 f.close()
6 self.check()
7
8+ def mangle_grub(self):
9+ logging.debug('mangle_grub')
10+ self.progress_message(_('Modifying grub configuration...'))
11+
12+ # Mangle the configuration files based on the options we've selected.
13+ import glob
14+ to_append = ' cdrom-detect/try-usb=true noprompt'
15+ if self.persist != 0:
16+ to_append += ' persistent'
17+ for filename in glob.iglob(os.path.join(self.target,
18+ 'boot', 'grub', '*.cfg')):
19+ f = None
20+ try:
21+ f = open(filename, 'r')
22+ to_write = []
23+ for line in f.readlines():
24+ tokens = line.strip().split()
25+ if tokens and tokens[0] == 'linux' \
26+ and 'boot=casper' in tokens \
27+ and 'integrity-check' not in tokens:
28+ line = line.rstrip('\r\n') + to_append + '\n'
29+ to_write.append(line)
30+ f.close()
31+ f = open(filename, 'w')
32+ f.writelines(to_write)
33+ except (KeyboardInterrupt, SystemExit):
34+ raise
35+ except:
36+ # TODO evand 2009-07-28: Fail? Warn?
37+ logging.exception('Unable to add persistence support to %s:' %
38+ filename)
39+ finally:
40+ if f:
41+ f.close()
42+ self.check()
43+
44 def create_persistence(self):
45 logging.debug('create_persistence')
46 if self.persist != 0:
47@@ -527,6 +563,7 @@
48 else:
49 self.install_bootloader()
50 self.mangle_syslinux()
51+ self.mangle_grub()
52
53 self.create_persistence()
54 self.sync()
55@@ -623,6 +660,7 @@
56 else:
57 self.install_bootloader()
58 self.mangle_syslinux()
59+ self.mangle_grub()
60
61 self.create_persistence()
62 self.sync()

Subscribers

People subscribed via source and target branches

to all changes: