projects
/
grml2usb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
grml2iso: mention isolinux in 'isohybrid executable not found' message, add isolinux...
[grml2usb.git]
/
grml2usb
diff --git
a/grml2usb
b/grml2usb
index
0c9ffc0
..
ab0ad63
100755
(executable)
--- a/
grml2usb
+++ b/
grml2usb
@@
-40,6
+40,7
@@
GRML_FLAVOURS = set() # which flavours are being installed?
GRML_DEFAULT = None
UUID = None
SYSLINUX_LIBS = "/usr/lib/syslinux/"
GRML_DEFAULT = None
UUID = None
SYSLINUX_LIBS = "/usr/lib/syslinux/"
+GPT_HEADER = "\x55\xaa\x45\x46\x49\x20\x50\x41\x52\x54" # original GPT header
RE_PARTITION = re.compile(r'([a-z/]*?)(\d+)$')
RE_P_PARTITION = re.compile(r'(.*?\d+)p(\d+)$')
RE_PARTITION = re.compile(r'([a-z/]*?)(\d+)$')
RE_P_PARTITION = re.compile(r'(.*?\d+)p(\d+)$')
@@
-170,7
+171,7
@@
def cleanup():
os.unlink(tmpfile)
# ignore: RuntimeError: Set changed size during iteration
except RuntimeError:
os.unlink(tmpfile)
# ignore: RuntimeError: Set changed size during iteration
except RuntimeError:
- logging.debug('caught ex
pec
tion RuntimeError, ignoring')
+ logging.debug('caught ex
cep
tion RuntimeError, ignoring')
def register_tmpfile(path):
def register_tmpfile(path):
@@
-311,16
+312,20
@@
def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_retu
def check_uid_root():
"""Check for root permissions"""
if not os.geteuid() == 0:
def check_uid_root():
"""Check for root permissions"""
if not os.geteuid() == 0:
-
sys.exit("Error:
please run this script with uid 0 (root).")
+
raise CriticalException("
please run this script with uid 0 (root).")
def check_boot_flag(device):
boot_dev, x = get_device_from_partition(device)
with open(boot_dev, 'r') as image:
def check_boot_flag(device):
boot_dev, x = get_device_from_partition(device)
with open(boot_dev, 'r') as image:
- data = image.read(5
12
)
+ data = image.read(5
20
)
bootcode = data[440:]
bootcode = data[440:]
- if bootcode[6] == '\x80':
+ gpt_data = bootcode[70:80]
+
+ if gpt_data == GPT_HEADER:
+ logging.info("GPT detected, skipping bootflag check")
+ elif bootcode[6] == '\x80':
logging.debug("bootflag is enabled")
else:
logging.debug("bootflag is NOT enabled")
logging.debug("bootflag is enabled")
else:
logging.debug("bootflag is NOT enabled")
@@
-540,7
+545,7
@@
def install_mbr(mbrtemplate, device, partition, ismirbsdmbr=True):
if not os.path.isfile(mbrtemplate):
logging.error('Error installing MBR (either try --syslinux-mbr or '
'install missing file "%s"?)', mbrtemplate)
if not os.path.isfile(mbrtemplate):
logging.error('Error installing MBR (either try --syslinux-mbr or '
'install missing file "%s"?)', mbrtemplate)
- raise CriticalException("
Error: %s can not be read.",
mbrtemplate)
+ raise CriticalException("
%s can not be read." %
mbrtemplate)
if partition is not None and ((partition < 0) or (partition > 3)):
logging.warn("Cannot activate partition %d", partition)
if partition is not None and ((partition < 0) or (partition > 3)):
logging.warn("Cannot activate partition %d", partition)
@@
-796,7
+801,7
@@
def copy_system_files(grml_flavour, iso_mount, target):
squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
if squashfs is None:
logging.error("error locating squashfs file")
squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
if squashfs is None:
logging.error("error locating squashfs file")
- raise CriticalException("
Fatal:
squashfs file not found"
+ raise CriticalException("squashfs file not found"
", please check that your iso is not corrupt")
else:
squashfs_target = target + '/live/' + grml_flavour + '/'
", please check that your iso is not corrupt")
else:
squashfs_target = target + '/live/' + grml_flavour + '/'
@@
-1048,8
+1053,8
@@
def copy_bootloader_files(iso_mount, target, grml_flavour):
if not source_dir:
raise CriticalException(
if not source_dir:
raise CriticalException(
- "
Fatal: file default.cfg could not be found." \
- "Note: this grml2usb version requires an ISO generated by grml-live >=0.9.24 ...
" \
+ "
file default.cfg could not be found.\n"
+ "Note: this grml2usb version requires an ISO generated by grml-live >=0.9.24 ...
\n"
" ... either use grml releases >=2009.10 or switch to an older grml2usb version.")
if not os.path.exists(iso_mount + '/boot/grub/footer.cfg'):
" ... either use grml releases >=2009.10 or switch to an older grml2usb version.")
if not os.path.exists(iso_mount + '/boot/grub/footer.cfg'):
@@
-1379,7
+1384,7
@@
def handle_syslinux_config(grml_flavour, target):
# install main configuration only *once*, no matter how many ISOs we have:
syslinux_config_file = open(syslinux_cfg, 'w')
# install main configuration only *once*, no matter how many ISOs we have:
syslinux_config_file = open(syslinux_cfg, 'w')
- syslinux_config_file.write("
TIMEOUT
300\n")
+ syslinux_config_file.write("
timeout
300\n")
syslinux_config_file.write("include vesamenu.cfg\n")
syslinux_config_file.close()
syslinux_config_file.write("include vesamenu.cfg\n")
syslinux_config_file.close()
@@
-1488,8
+1493,8
@@
def install(image, device):
try:
remove_mountpoint(iso_mountpoint)
except CriticalException, error:
try:
remove_mountpoint(iso_mountpoint)
except CriticalException, error:
- logging.critical("Fatal: %s", error)
cleanup()
cleanup()
+ raise
def install_grml(mountpoint, device):
def install_grml(mountpoint, device):
@@
-1511,7
+1516,6
@@
def install_grml(mountpoint, device):
check_boot_flag(device)
mount(device, device_mountpoint, ['-o', 'utf8,iocharset=iso8859-1'])
except VerifyException, error:
check_boot_flag(device)
mount(device, device_mountpoint, ['-o', 'utf8,iocharset=iso8859-1'])
except VerifyException, error:
- logging.critical("Fatal: %s", error)
raise
except CriticalException, error:
mount(device, device_mountpoint, "")
raise
except CriticalException, error:
mount(device, device_mountpoint, "")
@@
-1538,8
+1542,8
@@
def remove_mountpoint(mountpoint):
os.rmdir(mountpoint)
unregister_tmpfile(mountpoint)
except CriticalException, error:
os.rmdir(mountpoint)
unregister_tmpfile(mountpoint)
except CriticalException, error:
- logging.critical("Fatal: %s", error)
cleanup()
cleanup()
+ raise
def handle_mbr(device):
def handle_mbr(device):
@@
-1645,14
+1649,13
@@
def handle_logging():
if options.verbose and options.quiet:
parser.error("please use either verbose (--verbose) or quiet (--quiet) option")
if options.verbose and options.quiet:
parser.error("please use either verbose (--verbose) or quiet (--quiet) option")
+ FORMAT = "%(message)s"
if options.verbose:
if options.verbose:
- FORMAT = "
Debug:
%(asctime)-15s %(message)s"
+ FORMAT = "%(asctime)-15s %(message)s"
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
elif options.quiet:
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
elif options.quiet:
- FORMAT = "Critical: %(message)s"
logging.basicConfig(level=logging.CRITICAL, format=FORMAT)
else:
logging.basicConfig(level=logging.CRITICAL, format=FORMAT)
else:
- FORMAT = "%(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)
logging.basicConfig(level=logging.INFO, format=FORMAT)
@@
-1676,8
+1679,7
@@
def check_options(opts):
@opts option dict from OptionParser
"""
if opts.grubmbr and not opts.grub:
@opts option dict from OptionParser
"""
if opts.grubmbr and not opts.grub:
- logging.critical("Error: --grub-mbr requires --grub option.")
- sys.exit(1)
+ raise CriticalException("--grub-mbr requires --grub option.")
def check_programs():
def check_programs():