import struct
# global variables
-PROG_VERSION = "0.9.28~git"
+PROG_VERSION = "0.9.28"
MOUNTED = set() # register mountpoints
TMPFILES = set() # register tmpfiles
DATESTAMP = time.mktime(datetime.datetime.now().timetuple()) # unique identifier for syslinux.cfg
GRML_FLAVOURS = set() # which flavours are being installed?
GRML_DEFAULT = None
UUID = None
+SYSLINUX_LIBS = "/usr/lib/syslinux/"
def syslinux_warning(option, opt, value, opt_parser):
"""A helper function for printing a warning about deprecated option
grub_device = device
logging.info("Installing grub as bootloader")
- logging.debug("grub-install --recheck --force --no-floppy --root-directory=%s %s",
- 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()
+ for opt in ["", "--force" ]:
+ logging.debug("grub-install --recheck %s --no-floppy --root-directory=%s %s",
+ opt, device_mountpoint, grub_device)
+ proc = subprocess.Popen(["grub-install", "--recheck", opt, "--no-floppy",
+ "--root-directory=%s" % device_mountpoint, grub_device],
+ stdout=file(os.devnull, "r+"))
+ proc.wait()
+ if proc.returncode == 0:
+ break
+
if proc.returncode != 0:
# raise Exception("error executing grub-install")
logging.critical("Fatal: error executing grub-install "
logging.warn("Warning: %s could not be found - can not install it", iso_grml_version_file)
return False
try:
- target_file = open(target_grml_version_file, 'a+')
- target_flavours = [ get_flavour(l) for l in target_file.readlines() ]
-
+ iso_versions = {}
iso_file = open(iso_grml_version_file, 'r')
- iso_lines = iso_file.readlines()
- for line in iso_lines:
- if not get_flavour(line) in target_flavours:
- target_file.write(line)
+ for line in iso_file:
+ iso_versions[get_flavour(line)] = line.strip()
+
+ for line in fileinput.input([target_grml_version_file], inplace=1):
+ flavour = get_flavour(line)
+ if flavour in iso_versions.keys():
+ print iso_versions[flavour]
+ else:
+ print line.strip()
except IOError:
logging.warn("Warning: Could not write file")
finally:
- target_file.close()
iso_file.close()
+ fileinput.close()
return True
else:
return False
if file_location is None:
logging.warn("Warning: %s not found (that's fine if you don't need it)", filename)
else:
- exec_rsync(file_location, dst + filename)
+ exec_rsync(file_location, dst)
def copy_addons(iso_mount, target):
for expr in name, 'distri.cfg', \
defaults_file, 'grml.png', 'hd.cfg', 'isolinux.cfg', 'isolinux.bin', \
'isoprompt.cfg', 'options.cfg', \
- 'prompt.cfg', 'vesamenu.c32', 'vesamenu.cfg', 'grml.png', '*.c32':
+ 'prompt.cfg', 'vesamenu.cfg', 'grml.png', '*.c32':
glob_and_copy(iso_mount + source_dir + expr, syslinux_target)
+ for filename in glob.glob1(syslinux_target, "*.c32"):
+ copy_if_exist(os.path.join(SYSLINUX_LIBS, filename), syslinux_target)
+
+
# copy the addons_*.cfg file to the new syslinux directory
glob_and_copy(iso_mount + source_dir + 'addon*.cfg', syslinux_target)