Yu Ning has proposed merging 
lp:~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux into 
lp:usb-creator.

Requested reviews:
  Mathieu Trudel-Lapierre (mathieu-tl)
  usb-creator hackers (usb-creator-hackers)
Related bugs:
  Bug #1325801 in usb-creator (Ubuntu): "failed to boot from USB disk with 
error: gfxboot.c32: not a COM32R Image boot:"
  https://bugs.launchpad.net/ubuntu/+source/usb-creator/+bug/1325801

For more details, see:
https://code.launchpad.net/~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux/+merge/250877

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.


-- 
Your team usb-creator hackers is requested to review the proposed merge of 
lp:~yuningdodo/usb-creator/usb-creator.lp1325801v3-use-source-syslinux into 
lp:usb-creator.
=== 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:09:25 +0000
@@ -154,10 +154,10 @@
 
 
     # TODO return boolean success
-    @dbus.service.method(USBCREATOR_IFACE, in_signature='sbsb', out_signature='',
+    @dbus.service.method(USBCREATOR_IFACE, in_signature='sbsbs', out_signature='',
                          sender_keyword='sender', connection_keyword='conn')
     def InstallBootloader(self, device, allow_system_internal, grub_location,
-                          syslinux_legacy, sender=None, conn=None):
+                          syslinux_legacy, sourcefs, sender=None, conn=None):
         '''Install a bootloader to the boot code area, either grub or syslinux.
 
            The function takes a partition device file of the form /dev/sda1
@@ -190,13 +190,25 @@
                    'bs=512', 'count=62', 'seek=1', 'conv=sync'])
         else:
             if syslinux_legacy and find_on_path('syslinux-legacy'):
+                syslinux_var = "syslinux-legacy"
                 syslinux_exe = "syslinux-legacy"
                 syslinux_bin = "/usr/lib/syslinux-legacy/mbr.bin"
             else:
+                syslinux_var = "syslinux"
                 syslinux_exe = "syslinux"
                 syslinux_bin = "/usr/lib/syslinux/mbr/mbr.bin"
                 if not os.path.exists(syslinux_bin):
                     syslinux_bin = "/usr/lib/syslinux/mbr.bin"
+            if sourcefs and os.path.isdir(sourcefs):
+                for mbrbin in [
+                        os.path.join(sourcefs, 'usr', 'lib', syslinux_var, 'mbr.bin'),
+                        os.path.join(sourcefs, 'usr', 'lib', syslinux_var, 'mbr', 'mbr.bin'),
+                        os.path.join(sourcefs, 'usr', 'lib', syslinux_var.upper(), 'mbr.bin'),
+                        ]:
+                    if os.path.exists(mbrbin):
+                        syslinux_exe = os.path.join(sourcefs, 'usr', 'bin', syslinux_var)
+                        syslinux_bin = mbrbin
+                        break
             popen([syslinux_exe, '-f', device])
             # Write the syslinux MBR.
             popen(['dd', 'if=%s' % syslinux_bin, 'of=%s' % parent_file,

=== modified file 'usbcreator/backends/base/backend.py'
--- usbcreator/backends/base/backend.py	2014-03-31 14:08:49 +0000
+++ usbcreator/backends/base/backend.py	2015-02-25 07:09:25 +0000
@@ -186,10 +186,15 @@
                 allow_system_internal=False):
         fastboot_mode = self.__class__.__name__ == 'FastbootBackend'
         logging.debug('Starting install thread.')
+        if hasattr(self, 'mounted_sourcefs'):
+            sourcefs = self.mounted_sourcefs
+        else:
+            sourcefs = ''
         self.install_thread = usbcreator.install.install(
             source, target, persist, device=device,
             allow_system_internal=allow_system_internal,
-            fastboot_mode=fastboot_mode)
+            fastboot_mode=fastboot_mode,
+            sourcefs=sourcefs)
         # Connect signals.
         self.install_thread.success = self.success_cb
         self.install_thread.failure = self.failure_cb

=== modified file 'usbcreator/backends/udisks/backend.py'
--- usbcreator/backends/udisks/backend.py	2015-01-17 00:03:17 +0000
+++ usbcreator/backends/udisks/backend.py	2015-02-25 07:09:25 +0000
@@ -1,3 +1,4 @@
+import os
 import dbus
 import logging
 from dbus.mainloop.glib import DBusGMainLoop, threads_init
@@ -335,6 +336,9 @@
             isofile = self.sources[source]['device']
             source = self.helper.MountISO(isofile)
             self.mounted_source = source
+        if os.path.isfile(os.path.join(source, 'casper', 'filesystem.squashfs')):
+            self.mounted_sourcefs = self.helper.MountISO(
+                    os.path.join(source, 'casper', 'filesystem.squashfs'))
 
         dev = self.targets[target]['device']
         if stype == misc.SOURCE_IMG:
@@ -358,6 +362,8 @@
 
     def unmount(self):
         try:
+            if self.mounted_sourcefs:
+                self.helper.UnmountFile(self.mounted_sourcefs)
             if self.mounted_source:
                 self.helper.UnmountFile(self.mounted_source)
         except:

=== modified file 'usbcreator/install.py'
--- usbcreator/install.py	2013-01-28 12:44:46 +0000
+++ usbcreator/install.py	2015-02-25 07:09:25 +0000
@@ -66,7 +66,8 @@
 class install(Thread):
     def __init__(self, source, target, persist, device=None,
                  allow_system_internal=False,
-                 fastboot_mode=False):
+                 fastboot_mode=False,
+                 sourcefs=''):
         Thread.__init__(self)
         self.source = source
         self.target = target
@@ -74,6 +75,7 @@
         self.device = device
         self.allow_system_internal = allow_system_internal
         self.fastboot_mode = fastboot_mode
+        self.sourcefs = sourcefs
         self._stopevent = Event()
         self.progress_thread = None
         logging.debug('install thread source: %s' % source)
@@ -249,6 +251,7 @@
                 obj.InstallBootloader(self.device, self.allow_system_internal,
                                       grub_location,
                                       self.need_syslinux_legacy(),
+                                      self.sourcefs,
                                       dbus_interface='com.ubuntu.USBCreator',
                                       timeout=MAX_DBUS_TIMEOUT)
             except dbus.DBusException:

_______________________________________________
Mailing list: https://launchpad.net/~usb-creator-hackers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~usb-creator-hackers
More help   : https://help.launchpad.net/ListHelp

Reply via email to