diff --git a/liveusb-creator b/liveusb-creator index e110e07..e638b56 100755 --- a/liveusb-creator +++ b/liveusb-creator @@ -31,6 +31,8 @@ def parse_args(): help='Use the "safe, slow and stupid" bootloader') parser.add_option('-n', '--noverify', dest='noverify', action='store_true', help='Skip checksum verification') + parser.add_option('-l', '--label', dest='customlabel', action='store', type='string', + help='Specify a custom label for the disk',metavar='LABEL') parser.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Output extra debugging messages') return parser.parse_args() # (opts, args) diff --git a/liveusb/creator.py b/liveusb/creator.py index ea9ef67..23d8f73 100755 --- a/liveusb/creator.py +++ b/liveusb/creator.py @@ -77,7 +77,7 @@ class LiveUSBCreator(object): """ raise NotImplementedError - def verifyFilesystem(self): + def verifyFilesystem(self, customlabel=False): """ Verify the filesystem of our device, setting the volume label if necessary. If something is not right, this method throws a @@ -331,19 +331,18 @@ class LinuxLiveUSBCreator(LiveUSBCreator): shutil.rmtree(self.dest) self.dest = None - def verifyFilesystem(self): + def verifyFilesystem(self, customlabel=False): if self.fstype not in ('vfat', 'msdos', 'ext2', 'ext3'): raise LiveUSBError("Unsupported filesystem: %s" % self.fstype) if self.drives[self.drive]['label']: self.label = self.drives[self.drive]['label'] else: - self.log.info("Setting label on %s to %s" % (self.drive,self.label)) + self.log.info("Setting label on %s to %s" % (self.drive, (customlabel or self.label))) try: if self.fstype in ('vfat', 'msdos'): - p = self.popen('/sbin/dosfslabel %s %s' % (self.drive, - self.label)) + p = self.popen('dosfslabel %s %s' % (self.drive, (customlabel or self.label))) else: - p = self.popen('/sbin/e2label %s %s' % (self.drive, self.label)) + p = self.popen('e2label %s %s' % (self.drive, (customlabel or self.label))) except LiveUSBError, e: self.log.error("Unable to change volume label: %s" % str(e)) self.label = None @@ -429,7 +428,7 @@ class WindowsLiveUSBCreator(LiveUSBCreator): if not len(self.drives): raise LiveUSBError("Unable to find any removable devices") - def verifyFilesystem(self, force=False): + def verifyFilesystem(self, force=False, customlabel=False): import win32api, win32file, pywintypes try: vol = win32api.GetVolumeInformation(self.drive) @@ -443,8 +442,8 @@ class WindowsLiveUSBCreator(LiveUSBCreator): self.fstype = 'vfat' if vol[0] == '': try: - win32file.SetVolumeLabel(self.drive, self.label) - self.log.info("Set label on %s to %s" % (self.drive,self.label)) + win32file.SetVolumeLabel(self.drive, (customlabel or self.label)) + self.log.info("Set label on %s to %s" % (self.drive, (customlabel or self.label))) except pywintypes.error, e: self.log.warning("Unable to SetVolumeLabel: " + str(e)) self.label = None diff --git a/liveusb/gui.py b/liveusb/gui.py index 0e6bb05..20c05ff 100755 --- a/liveusb/gui.py +++ b/liveusb/gui.py @@ -134,10 +134,10 @@ class LiveUSBThread(QtCore.QThread): now = datetime.now() try: self.status("Verifying filesystem...") - self.live.verifyFilesystem() + self.live.verifyFilesystem(customlabel=self.parent.opts.customlabel) if not self.live.uuid and not self.live.label: self.status("Error: Cannot set the label or obtain " - "the UUID of your device. Unable to continue.") + "the UUID of your device. Unable to continue.") self.live.checkFreeSpace()