"""
-# 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
import uuid
# global variables
-PROG_VERSION = "0.9.23"
+PROG_VERSION = "0.9.24"
MOUNTED = set() # register mountpoints
TMPFILES = set() # register tmpfiles
DATESTAMP = time.mktime(datetime.datetime.now().timetuple()) # unique identifier for syslinux.cfg
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
}
""" % {'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):
logging.info("Installing grub as bootloader")
logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s",
- device_mountpoint, grub_device)
+ device_mountpoint, grub_device)
proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy",
- "--root-directory=%s" % device_mountpoint, grub_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")
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)")
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()
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)")
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:
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)
for expr in name, 'distri.cfg', \
options, 'grml.png', 'hd.cfg', 'isolinux.cfg', 'isolinux.bin', \
'isoprompt.cfg', 'options.cfg', \
- 'prompt.cfg', 'vesamenu.c32', 'vesamenu.cfg', 'grml.png':
+ 'prompt.cfg', 'vesamenu.c32', 'vesamenu.cfg', 'grml.png', '*.c32':
files = glob.glob(iso_mount + source_dir + expr)
for path in files:
filename = os.path.basename(path)