X-Git-Url: http://git.grml.org/?a=blobdiff_plain;ds=sidebyside;f=grml2usb;h=1aa39bad4fdb204ec4af2b1de4e52e0d319a08f4;hb=656f5a714c1751f946f238e24bb81d4c1109c960;hp=ae24edb999a035b0d836ac249a500a8a15284f1c;hpb=20260c61b96d0d785f8162dcf75c35366def3162;p=grml2usb.git diff --git a/grml2usb b/grml2usb index ae24edb..1aa39ba 100755 --- a/grml2usb +++ b/grml2usb @@ -49,6 +49,8 @@ parser.add_option("--fat16", dest="fat16", action="store_true", help="format specified partition with FAT16") parser.add_option("--force", dest="force", action="store_true", help="force any actions requiring manual interaction") +parser.add_option("--grub-mbr", dest="grubmbr", action="store_true", + help="install grub into MBR instead of (default) PBR") #parser.add_option("--initrd", dest="initrd", action="store", type="string", # help="install specified initrd instead of the default [TODO - not implemented yet]") #parser.add_option("--kernel", dest="kernel", action="store", type="string", @@ -225,7 +227,6 @@ def mkfs_fat16(device): @device: partition that should be formated""" - # syslinux -d boot/isolinux /dev/sdb1 if options.dryrun: logging.info("Would execute mkfs.vfat -F 16 %s now.", device) return 0 @@ -631,13 +632,26 @@ def install_grub(device): try: try: mount(device, device_mountpoint, "") - logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) + + # 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(): + grub_device = re.match(r'(.*?)\d*$', device).group(1) + else: + grub_device = device + else: + grub_device = device + + 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, device], stdout=file(os.devnull, "r+")) + "--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)") + logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ or use --syslinux)") + logging.critical("Note: if using grub2 consider using the --grub-mbr option because grub2's PBR feature is broken.") cleanup() sys.exit(1) except CriticalException, error: @@ -666,7 +680,7 @@ def install_syslinux(device): proc = subprocess.Popen(["syslinux", "-d", "boot/syslinux", device]) proc.wait() if proc.returncode != 0: - raise CriticalException("Error executing syslinux (either try --fat16 or --grub?)") + raise CriticalException("Error executing syslinux (either try --fat16 or use grub?)") def install_bootloader(device): @@ -1629,16 +1643,24 @@ def handle_vfat(device): @device: device that should checked / formated""" # make sure we have mkfs.vfat available - if options.fat16 and not options.force: + if options.fat16: if not which("mkfs.vfat") and not options.copyonly and not options.dryrun: logging.critical('Sorry, mkfs.vfat not available. Exiting.') logging.critical('Please make sure to install dosfstools.') sys.exit(1) - # make sure the user is aware of what he is doing - f = raw_input("Are you sure you want to format the specified partition with fat16? y/N ") - if f == "y" or f == "Y": - logging.info("Note: you can skip this question using the option --force") + exec_mkfs = False + if options.force: + print "Forcing mkfs.fat16 on %s as requested via option --force." % device + exec_mkfs = True + else: + # make sure the user is aware of what he is doing + f = raw_input("Are you sure you want to format the specified partition with fat16? y/N ") + if f == "y" or f == "Y": + logging.info("Note: you can skip this question using the option --force") + exec_mkfs = True + + if exec_mkfs: try: mkfs_fat16(device) except CriticalException, error: