X-Git-Url: https://git.grml.org/?a=blobdiff_plain;ds=sidebyside;f=grml2usb;h=eb13a0717cc07b41a44ec10fa1d53ea23578cb47;hb=189791042c86bda34541e773b056ee00fcd2e0f8;hp=66c40c38fcc9dda0d0e0c56164f5478f75463868;hpb=d10b71b7c6dda652f3a00ecd9ace6c5710e94543;p=grml2usb.git diff --git a/grml2usb b/grml2usb index 66c40c3..eb13a07 100755 --- a/grml2usb +++ b/grml2usb @@ -16,6 +16,7 @@ This script installs a grml system (either a running system or ISO[s]) to a USB from optparse import OptionParser from inspect import isroutine, isclass import datetime, logging, os, re, subprocess, sys, tempfile, time, os.path +import fileinput # global variables PROG_VERSION = "0.9.13-pre1" @@ -360,7 +361,7 @@ menuentry "%(grml_flavour)s2ram - copy compressed grml file to RAM" { ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] menuentry "%(grml_flavour)s-debug - enable debugging options" { set gfxpayload=1024x768x16,1024x768 - linux /boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ debug boot=live initcall_debug%(bootoptions)s + linux /boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ debug initcall_debug%(bootoptions)s initrd /boot/release/%(grml_flavour)s/initrd.gz } @@ -379,7 +380,7 @@ menuentry "%(grml_flavour)s-nofb - disable framebuffer" { ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] menuentry "%(grml_flavour)s-failsafe - disable hardware detection" { - linux /boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ vga=normal boot=live noautoconfig atapicd noapic noacpi acpi=off nomodules nofirewire noudev nousb nohotplug noapm nopcmcia nosmp maxcpus=0 noscsi noagp nodma ide=nodma noswap nofstab nosound nogpm nosyslog nodhcp nocpu nodisc nomodem xmodule=vesa noraid nolvm noresume selinux=0 edd=off pci=nomsi %(bootoptions)s + linux /boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ vga=normal noautoconfig atapicd noapic noacpi acpi=off nomodules nofirewire noudev nousb nohotplug noapm nopcmcia nosmp maxcpus=0 noscsi noagp nodma ide=nodma noswap nofstab nosound nogpm nosyslog nodhcp nocpu nodisc nomodem xmodule=vesa noraid nolvm noresume selinux=0 edd=off pci=nomsi %(bootoptions)s initrd /boot/release/%(grml_flavour)s/initrd.gz } @@ -421,7 +422,7 @@ initrd (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/initrd.gz ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] title %(grml_flavour)s-debug -kernel (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce vga=791 quiet live-media-path=/live/%(grml_flavour)s/ debug boot=live initcall_debug%(bootoptions)s +kernel (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce vga=791 quiet live-media-path=/live/%(grml_flavour)s/ debug initcall_debug%(bootoptions)s initrd (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/initrd.gz ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] @@ -436,7 +437,7 @@ initrd (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/initrd.gz ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] title %(grml_flavour)s-failsafe -kernel (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ vga=normal boot=live noautoconfig atapicd noapic noacpi acpi=off nomodules nofirewire noudev nousb nohotplug noapm nopcmcia nosmp maxcpus=0 noscsi noagp nodma ide=nodma noswap nofstab nosound nogpm nosyslog nodhcp nocpu nodisc nomodem xmodule=vesa noraid nolvm noresume selinux=0 edd=off pci=nomsi %(bootoptions)s +kernel (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/linux26 apm=power-off boot=live nomce quiet live-media-path=/live/%(grml_flavour)s/ vga=normal noautoconfig atapicd noapic noacpi acpi=off nomodules nofirewire noudev nousb nohotplug noapm nopcmcia nosmp maxcpus=0 noscsi noagp nodma ide=nodma noswap nofstab nosound nogpm nosyslog nodhcp nocpu nodisc nomodem xmodule=vesa noraid nolvm noresume selinux=0 edd=off pci=nomsi %(bootoptions)s initrd (hd0,%(install_partition)s)/boot/release/%(grml_flavour)s/initrd.gz ## flavour specific configuration for %(grml_flavour)s [grml2usb for %(grml_flavour)s: %(local_datestamp)s] @@ -1363,13 +1364,11 @@ def initial_syslinux_config(target): data.close -def adjust_syslinux_bootoptions(src_name, dst_name, flavour): +def adjust_syslinux_bootoptions(src, flavour): append_re = re.compile("^(\s*append.*)$", re.I) boot_re = re.compile("/boot/([a-zA-Z0-9_]+/)+([a-zA-Z0-9._]+)") flavour_re = re.compile("(label.*)(grml\w+)") default_re = re.compile("(default.cfg)") - src = open(src_name, "r") - dst = open(dst_name, "w") # do NOT write "None" in kernel cmdline if options.bootoptions is None: @@ -1377,15 +1376,14 @@ def adjust_syslinux_bootoptions(src_name, dst_name, flavour): else: bootopt = options.bootoptions - for line in src: + for line in fileinput.input(src, inplace=1): line = boot_re.sub(r'/boot/release/%s/\2 ' % flavour, line) line = flavour_re.sub(r'\1 %s-\2' % flavour, line) line = default_re.sub(r'%s-\1' % flavour, line) line = append_re.sub(r'\1 live-media-path=/live/%s/ ' % flavour, line) line = append_re.sub(r'\1 boot=live %s ' % bootopt, line) - dst.write(line) - src.close() - dst.close() + print line + fileinput.close() def add_syslinux_entry(filename, grml_flavour): @@ -1435,8 +1433,8 @@ def handle_syslinux_config(grml_flavour, target): for filename in 'grml.cfg', 'default.cfg', 'hidden.cfg': old_filename = "%s/%s" % (syslinux_target, filename) new_filename = "%s/%s-%s" % (syslinux_target, grml_flavour, filename) - adjust_syslinux_bootoptions(old_filename, new_filename, grml_flavour) - os.unlink(old_filename) + os.rename(old_filename, new_filename) + adjust_syslinux_bootoptions(new_filename, grml_flavour) new_hidden = "%s-hidden.cfg" % (grml_flavour) new_default = "%s-default.cfg" % (grml_flavour)