X-Git-Url: http://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=5aea516f9ccc968c62c12f0a1291ebe50e124cc4;hp=bee1012f34422997b39c5025d5355a71dc5ad795;hb=9e7ee70e9e76ab01f9b5ff2ae490236bc0e3c6d2;hpb=3330b400c2a0da7762ca5eccc51503cd460db4ae diff --git a/grml2usb b/grml2usb index bee1012..5aea516 100755 --- a/grml2usb +++ b/grml2usb @@ -12,7 +12,6 @@ This script installs a grml system (either a running system or ISO[s]) to a USB """ -# from __future__ import with_statement from optparse import OptionParser from inspect import isroutine, isclass import datetime, logging, os, re, subprocess, sys, tempfile, time, os.path @@ -21,7 +20,7 @@ import glob import uuid # global variables -PROG_VERSION = "0.9.23" +PROG_VERSION = "0.9.25" MOUNTED = set() # register mountpoints TMPFILES = set() # register tmpfiles DATESTAMP = time.mktime(datetime.datetime.now().timetuple()) # unique identifier for syslinux.cfg @@ -31,7 +30,7 @@ UUID = None def syslinux_warning(option, opt, value, parser): sys.stderr.write("Note: the --syslinux option is deprecated as syslinux " + - "is grml2usb's default. Continuing anyway.\n") + "is grml2usb's default. Continuing anyway.\n") setattr(parser.values, option.dest, True) # if grub option is set, unset syslinux option @@ -361,8 +360,8 @@ menuentry "Boot OS of first partition on first disk" { } """ % {'grml_flavour': grml_flavour, 'local_datestamp': local_datestamp, - 'flavour_filename': grml_flavour.replace('-', ''), - 'uid': UUID, 'bootoptions': bootoptions } ) + 'flavour_filename': grml_flavour.replace('-', ''), + 'uid': UUID, 'bootoptions': bootoptions } ) def generate_flavour_specific_grub2_config(grml_flavour, bootoptions): @@ -626,7 +625,6 @@ def install_grub(device): mount(device, device_mountpoint, "") # If using --grub-mbr then make sure we install grub in MBR instead of PBR - # Thanks to grub2. NOT. if options.grubmbr: logging.debug("Using option --grub-mbr ...") if device[-1:].isdigit(): @@ -638,14 +636,14 @@ def install_grub(device): logging.info("Installing grub as bootloader") logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", - device_mountpoint, grub_device) - proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", - "--root-directory=%s" % device_mountpoint, grub_device], stdout=file(os.devnull, "r+")) + device_mountpoint, grub_device) + proc = subprocess.Popen(["grub-install", "--recheck", "--force", "--no-floppy", + "--root-directory=%s" % device_mountpoint, grub_device], stdout=file(os.devnull, "r+")) proc.wait() if proc.returncode != 0: # raise Exception("error executing grub-install") logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ or drop the --grub option)") - logging.critical("Note: if using grub2 consider using the --grub-mbr option because grub2's PBR feature is broken.") + logging.critical("Note: if using grub2 consider using the --grub-mbr option as grub considers PBR problematic.") cleanup() sys.exit(1) except CriticalException, error: @@ -797,9 +795,9 @@ def install_mir_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): raise Exception("error executing dd (first run)") logging.debug("executing: dd if=%s of=%s bs=%s count=1 conv=notrunc", mbrtemplate, - tmpf.name, nmbrbytes) + tmpf.name, nmbrbytes) proc = subprocess.Popen(["dd", "if=%s" % mbrtemplate, "of=%s" % tmpf.name, "bs=%s" % nmbrbytes, - "count=1", "conv=notrunc"], stderr=file(os.devnull, "r+")) + "count=1", "conv=notrunc"], stderr=file(os.devnull, "r+")) proc.wait() if proc.returncode != 0: raise Exception("error executing dd (second run)") @@ -810,15 +808,15 @@ def install_mir_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): if ismirbsdmbr: mbrcode = mbrcode[0:439] + chr(partition) + \ - mbrcode[440:510] + "\x55\xAA" + mbrcode[440:510] + "\x55\xAA" else: actives = ["\x00", "\x00", "\x00", "\x00"] actives[partition] = "\x80" mbrcode = mbrcode[0:446] + actives[0] + \ - mbrcode[447:462] + actives[1] + \ - mbrcode[463:478] + actives[2] + \ - mbrcode[479:494] + actives[3] + \ - mbrcode[495:510] + "\x55\xAA" + mbrcode[447:462] + actives[1] + \ + mbrcode[463:478] + actives[2] + \ + mbrcode[479:494] + actives[3] + \ + mbrcode[495:510] + "\x55\xAA" tmpf.file.seek(0) tmpf.file.truncate() @@ -827,7 +825,7 @@ def install_mir_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): logging.debug("executing: dd if='%s' of='%s' bs=512 count=1 conv=notrunc", tmpf.name, device) proc = subprocess.Popen(["dd", "if=%s" % tmpf.name, "of=%s" % device, "bs=512", "count=1", - "conv=notrunc"], stderr=file(os.devnull, "r+")) + "conv=notrunc"], stderr=file(os.devnull, "r+")) proc.wait() if proc.returncode != 0: raise Exception("error executing dd (third run)") @@ -965,7 +963,7 @@ def check_for_fat(partition): try: udev_info = subprocess.Popen(["/sbin/blkid", "-s", "TYPE", "-o", "value", partition], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE) filesystem = udev_info.communicate()[0].rstrip() if udev_info.returncode == 2: @@ -1023,12 +1021,12 @@ def get_uuid(target): uuid_file_name = conf_target + "/bootid.txt" if os.path.isdir(conf_target): if os.path.isfile(uuid_file_name): - uuid_file = open(uuid_file_name, 'r') - uid = uuid_file.readline().strip() - uuid_file.close() - return uid + uuid_file = open(uuid_file_name, 'r') + uid = uuid_file.readline().strip() + uuid_file.close() + return uid else: - return write_uuid(uuid_file_name) + return write_uuid(uuid_file_name) else: execute(mkdir, conf_target) return write_uuid(uuid_file_name) @@ -1943,7 +1941,7 @@ def handle_vfat(device): logging.critical("Execution failed: %s", error) sys.exit(1) - if not os.path.isdir(device) and not check_for_usbdevice(device) and not option.force: + if not os.path.isdir(device) and not check_for_usbdevice(device) and not options.force: print "Warning: the specified device %s does not look like a removable usb device." % device f = raw_input("Do you really want to continue? y/N ") if f == "y" or f == "Y":