~ldunn/usb-creator/usb-creator-fix-645818

« back to all changes in this revision

Viewing changes to usbcreator/install.py

  • Committer: Colin Watson
  • Date: 2010-09-06 15:14:19 UTC
  • Revision ID: cjwatson@canonical.com-20100906151419-a9ce9p7jdzegexuz
Use python-debian for Ubuntu release version comparison.

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
        # Mangle the configuration files based on the options we've selected.
237
237
        import glob
238
238
        import lsb_release
 
239
        try:
 
240
            from debian import debian_support
 
241
        except ImportError:
 
242
            from debian_bundle import debian_support
239
243
        for filename in glob.iglob(os.path.join(self.target, 'syslinux', '*.cfg')):
240
244
            if os.path.basename(filename) == 'gfxboot.cfg':
241
245
                continue
242
246
            f = None
243
247
            target_os_ver = None
244
 
            our_os_ver = float(lsb_release.get_distro_information()['RELEASE'])
245
 
            
 
248
            our_os_ver = debian_support.Version(
 
249
                lsb_release.get_distro_information()['RELEASE'])
 
250
 
246
251
            if os.path.exists(os.path.join(self.target, '.disk', 'info')):
247
252
                with open(os.path.join(self.target, '.disk', 'info'),'r') as f:
248
253
                    contents = f.readline().split()
249
254
                if len(contents) > 2:
250
 
                    try:
251
 
                        target_os_ver = float(contents[1])
252
 
                    except ValueError:
253
 
                        pass
254
 
                    #might be a point release
255
 
                    if not target_os_ver:
256
 
                        try:
257
 
                            target_os_ver = float(contents[1].rpartition('.')[0])
258
 
                        except ValueError:
259
 
                            pass
 
255
                    target_os_ver = debian_support.Version(contents[1])
260
256
            try:
261
257
                f = open(filename, 'r')
262
258
                label = ''
277
273
                        #OS version specific mangles
278
274
                        #The syntax in syslinux changed with the version
279
275
                        #shipping in Ubuntu 10.10
280
 
                        elif target_os_ver and our_os_ver and \
281
 
                                                    target_os_ver != our_os_ver:
 
276
                        elif (target_os_ver and our_os_ver and
 
277
                              target_os_ver != our_os_ver):
 
278
                            lucid = debian_support.Version('10.04')
 
279
                            maverick = debian_support.Version('10.10')
282
280
                            #10.10 or newer image, burning on 10.04 or lower
283
 
                            if command.lower() == 'ui' and \
284
 
                                                    our_os_ver <= 10.04 and \
285
 
                                                    target_os_ver >= 10.10:
 
281
                            if (command.lower() == 'ui' and
 
282
                                our_os_ver <= lucid and
 
283
                                target_os_ver >= maverick):
286
284
                                line.remove('ui')
287
285
                            #10.04 or earlier image, burning on 10.10 or higher
288
286
                            #Currently still broke.
289
 
                            #elif command.lower() == 'gfxboot' and \
290
 
                            #                        our_os_ver >= 10.10 and \
291
 
                            #                        target_os_ver <= 10.04:
 
287
                            #elif (command.lower() == 'gfxboot' and
 
288
                            #      our_os_ver >= maverick and
 
289
                            #      target_os_ver <= lucid):
292
290
                            #    line.insert(0, 'ui')
293
 
                            
 
291
 
294
292
                    to_write.append(' '.join(line) + '\n')
295
293
                f.close()
296
294
                f = open(filename, 'w')