=== modified file 'bin/usb-creator-helper' --- a/bin/usb-creator-helper 2015-01-14 04:58:42 +0000 +++ b/bin/usb-creator-helper 2015-01-14 10:53:25 +0000 @@ -148,10 +148,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 @@ -187,9 +187,23 @@ syslinux = 'syslinux-legacy' else: syslinux = 'syslinux' - popen([syslinux, '-f', device]) + mbr_file = None + if sourcefs and os.path.isdir(sourcefs): + for mbrbin in [ + os.path.join(sourcefs, 'usr', 'lib', syslinux, 'mbr.bin'), + os.path.join(sourcefs, 'usr', 'lib', syslinux, 'mbr', 'mbr.bin'), + os.path.join(sourcefs, 'usr', 'lib', syslinux.upper(), 'mbr.bin'), + ]: + if os.path.isfile(mbrbin): + mbr_file = mbrbin + break + if not mbr_file: + # fallback to the host version + mbr_file = os.path.join(os.sep, 'usr', 'lib', syslinux, 'mbr.bin'), + sourcefs = os.sep + popen([os.path.join(sourcefs, 'usr', 'bin', syslinux), '-f', device]) # Write the syslinux MBR. - popen(['dd', 'if=/usr/lib/%s/mbr.bin' % syslinux, 'of=%s' % parent_file, + popen(['dd', 'if=%s' % mbr_file, 'of=%s' % parent_file, 'bs=446', 'count=1', 'conv=sync']) part = obj.get_partition() @@ -266,7 +280,10 @@ self.check_polkit(sender, conn, 'com.ubuntu.usbcreator.mount') import tempfile ret = tempfile.mkdtemp() - device = device.encode('utf-8') + if isinstance(device, dbus.String): + device = device.encode('utf-8') + if isinstance(device, bytes): + device = device.decode('utf-8') popen(['mount', '-r', '-o', 'loop', device, ret]) return ret === modified file 'usbcreator/backends/base/backend.py' --- a/usbcreator/backends/base/backend.py 2015-01-14 04:58:42 +0000 +++ b/usbcreator/backends/base/backend.py 2015-01-14 10:08:40 +0000 @@ -189,7 +189,8 @@ 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=self.sourcefs) # Connect signals. self.install_thread.success = self.success_cb self.install_thread.failure = self.failure_cb === modified file 'usbcreator/backends/udisks/backend.py' --- a/usbcreator/backends/udisks/backend.py 2014-04-01 15:04:39 +0000 +++ b/usbcreator/backends/udisks/backend.py 2015-01-14 10:57:19 +0000 @@ -1,3 +1,4 @@ +import os import dbus import logging from dbus.mainloop.glib import DBusGMainLoop, threads_init @@ -315,6 +316,7 @@ isofile = self.sources[source]['device'] source = self.helper.MountISO(isofile) self.mounted_source = source + self.sourcefs = self.helper.MountISO(os.path.join(source, 'casper', 'filesystem.squashfs')) dev = self.targets[target]['device'] if stype == misc.SOURCE_IMG: @@ -338,6 +340,7 @@ def unmount(self): try: + self.helper.UnmountFile(self.sourcefs) if self.mounted_source: self.helper.UnmountFile(self.mounted_source) except: === modified file 'usbcreator/install.py' --- a/usbcreator/install.py 2015-01-14 04:58:42 +0000 +++ b/usbcreator/install.py 2015-01-14 10:11:01 +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=None): 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: