Merge lp:~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux into lp:usb-creator

Proposed by Yu Ning
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 462
Merged at revision: 467
Proposed branch: lp:~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux
Merge into: lp:usb-creator
Diff against target: 49 lines (+28/-0)
1 file modified
bin/usb-creator-helper (+28/-0)
To merge this branch: bzr merge lp:~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Approve
usb-creator hackers Pending
Review via email: mp+250877@code.launchpad.net

Description of the change

Find and use the syslinux from the source squashfs. (LP: #1325801)

This patch can fix the bug in below cases (not a full list, only what I've tested):
* host: ubuntu 14.04; target: ubuntu 14.04;
* host: ubuntu 14.04; target: ubuntu 14.10;
* host: ubuntu 14.04; target: ubuntu 13.10;
* host: ubuntu 14.10; target: ubuntu 14.10;
* host: ubuntu 14.10; target: ubuntu 14.04;
* host: ubuntu 14.10; target: ubuntu 13.10;

This patch won't work in below cases, but at least it won't make things worse, it just keep the original behavior:
* target: debian-7.7.0-amd64-netinst.iso: no squashfs at all
* target: xubuntu 14.10: syslinux not pre-installed into squashfs

As long as there is syslinux pre-installed in the ISO this patch will take effect; and when there is no syslinux pre-installed, it won't change anything.

One thing to mention is that the patch adds one parameter to the dbus method InstallBootloader(), so it will break API compatibility. However it maybe possible to do the job w/o this parameter. I'll keep working on it.

To post a comment you must log in.
462. By Yu Ning

Mount the squashfs from the usbstick instead of the CDROM/ISO, so we don't need to break the API compability.

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

Updated, now we'll mount the squashfs on the usbstick instead of the CDROM/ISO, so we don't need to break the API compatibility.

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

Looks good, approve.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/usb-creator-helper'
2--- bin/usb-creator-helper 2014-09-02 20:12:12 +0000
3+++ bin/usb-creator-helper 2015-02-25 07:51:13 +0000
4@@ -190,17 +190,45 @@
5 'bs=512', 'count=62', 'seek=1', 'conv=sync'])
6 else:
7 if syslinux_legacy and find_on_path('syslinux-legacy'):
8+ syslinux_var = "syslinux-legacy"
9 syslinux_exe = "syslinux-legacy"
10 syslinux_bin = "/usr/lib/syslinux-legacy/mbr.bin"
11 else:
12+ syslinux_var = "syslinux"
13 syslinux_exe = "syslinux"
14 syslinux_bin = "/usr/lib/syslinux/mbr/mbr.bin"
15 if not os.path.exists(syslinux_bin):
16 syslinux_bin = "/usr/lib/syslinux/mbr.bin"
17+ squashfs_mnt = ''
18+ target_mounts = obj.get_filesystem().get_cached_property('MountPoints').get_bytestring_array()
19+ if len(target_mounts) > 0:
20+ target_mnt = target_mounts[0]
21+ squashfs_img = os.path.join(target_mnt, 'casper',
22+ 'filesystem.squashfs')
23+ if os.path.exists(squashfs_img):
24+ # Mount the squashfs so we are possible to install
25+ # syslinux & mbr.bin from it.
26+ squashfs_mnt = self.MountISO(squashfs_img)
27+ if squashfs_mnt:
28+ for mbrbin in [
29+ os.path.join(squashfs_mnt, 'usr', 'lib',
30+ syslinux_var, 'mbr.bin'),
31+ os.path.join(squashfs_mnt, 'usr', 'lib',
32+ syslinux_var, 'mbr', 'mbr.bin'),
33+ os.path.join(squashfs_mnt, 'usr', 'lib',
34+ syslinux_var.upper(), 'mbr.bin'),
35+ ]:
36+ if os.path.exists(mbrbin):
37+ syslinux_exe = os.path.join(squashfs_mnt, 'usr',
38+ 'bin', syslinux_var)
39+ syslinux_bin = mbrbin
40+ break
41 popen([syslinux_exe, '-f', device])
42 # Write the syslinux MBR.
43 popen(['dd', 'if=%s' % syslinux_bin, 'of=%s' % parent_file,
44 'bs=446', 'count=1', 'conv=sync'])
45+ if squashfs_mnt:
46+ self.UnmountFile(squashfs_mnt)
47
48 part = obj.get_partition()
49 if part:

Subscribers

People subscribed via source and target branches

to all changes: