~usb-creator-hackers/usb-creator/trunk

« back to all changes in this revision

Viewing changes to bin/usb-creator-helper

  • Committer: Mathieu Trudel-Lapierre
  • Date: 2015-03-10 15:24:32 UTC
  • mfrom: (460.1.2 usb-creator.lp1325801v3)
  • Revision ID: mathieu.trudel-lapierre@canonical.com-20150310152432-5396hf7sydsuveo5
Find and use the syslinux from the source squashfs. (LP: #1325801)

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
                   'bs=512', 'count=62', 'seek=1', 'conv=sync'])
191
191
        else:
192
192
            if syslinux_legacy and find_on_path('syslinux-legacy'):
 
193
                syslinux_var = "syslinux-legacy"
193
194
                syslinux_exe = "syslinux-legacy"
194
195
                syslinux_bin = "/usr/lib/syslinux-legacy/mbr.bin"
195
196
            else:
 
197
                syslinux_var = "syslinux"
196
198
                syslinux_exe = "syslinux"
197
199
                syslinux_bin = "/usr/lib/syslinux/mbr/mbr.bin"
198
200
                if not os.path.exists(syslinux_bin):
199
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
226
            popen([syslinux_exe, '-f', device])
201
227
            # Write the syslinux MBR.
202
228
            popen(['dd', 'if=%s' % syslinux_bin, 'of=%s' % parent_file,
203
229
                   'bs=446', 'count=1', 'conv=sync'])
 
230
            if squashfs_mnt:
 
231
                self.UnmountFile(squashfs_mnt)
204
232
 
205
233
        part = obj.get_partition()
206
234
        if part: