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
=== modified file 'bin/usb-creator-helper'
--- bin/usb-creator-helper 2014-09-02 20:12:12 +0000
+++ bin/usb-creator-helper 2015-02-25 07:51:13 +0000
@@ -190,17 +190,45 @@
190 'bs=512', 'count=62', 'seek=1', 'conv=sync'])190 'bs=512', 'count=62', 'seek=1', 'conv=sync'])
191 else:191 else:
192 if syslinux_legacy and find_on_path('syslinux-legacy'):192 if syslinux_legacy and find_on_path('syslinux-legacy'):
193 syslinux_var = "syslinux-legacy"
193 syslinux_exe = "syslinux-legacy"194 syslinux_exe = "syslinux-legacy"
194 syslinux_bin = "/usr/lib/syslinux-legacy/mbr.bin"195 syslinux_bin = "/usr/lib/syslinux-legacy/mbr.bin"
195 else:196 else:
197 syslinux_var = "syslinux"
196 syslinux_exe = "syslinux"198 syslinux_exe = "syslinux"
197 syslinux_bin = "/usr/lib/syslinux/mbr/mbr.bin"199 syslinux_bin = "/usr/lib/syslinux/mbr/mbr.bin"
198 if not os.path.exists(syslinux_bin):200 if not os.path.exists(syslinux_bin):
199 syslinux_bin = "/usr/lib/syslinux/mbr.bin"201 syslinux_bin = "/usr/lib/syslinux/mbr.bin"
202 squashfs_mnt = ''
203 target_mounts = obj.get_filesystem().get_cached_property('MountPoints').get_bytestring_array()
204 if len(target_mounts) > 0:
205 target_mnt = target_mounts[0]
206 squashfs_img = os.path.join(target_mnt, 'casper',
207 'filesystem.squashfs')
208 if os.path.exists(squashfs_img):
209 # Mount the squashfs so we are possible to install
210 # syslinux & mbr.bin from it.
211 squashfs_mnt = self.MountISO(squashfs_img)
212 if squashfs_mnt:
213 for mbrbin in [
214 os.path.join(squashfs_mnt, 'usr', 'lib',
215 syslinux_var, 'mbr.bin'),
216 os.path.join(squashfs_mnt, 'usr', 'lib',
217 syslinux_var, 'mbr', 'mbr.bin'),
218 os.path.join(squashfs_mnt, 'usr', 'lib',
219 syslinux_var.upper(), 'mbr.bin'),
220 ]:
221 if os.path.exists(mbrbin):
222 syslinux_exe = os.path.join(squashfs_mnt, 'usr',
223 'bin', syslinux_var)
224 syslinux_bin = mbrbin
225 break
200 popen([syslinux_exe, '-f', device])226 popen([syslinux_exe, '-f', device])
201 # Write the syslinux MBR.227 # Write the syslinux MBR.
202 popen(['dd', 'if=%s' % syslinux_bin, 'of=%s' % parent_file,228 popen(['dd', 'if=%s' % syslinux_bin, 'of=%s' % parent_file,
203 'bs=446', 'count=1', 'conv=sync'])229 'bs=446', 'count=1', 'conv=sync'])
230 if squashfs_mnt:
231 self.UnmountFile(squashfs_mnt)
204232
205 part = obj.get_partition()233 part = obj.get_partition()
206 if part:234 if part:

Subscribers

People subscribed via source and target branches

to all changes: