From 0c4bedd98ddd16f6fe7758329a0e49e7a94fa0c3 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 11 Jan 2012 16:12:40 +0100 Subject: [PATCH 01/16] Release new version 0.11.5 --- debian/changelog | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/debian/changelog b/debian/changelog index b26ccd0..68009d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +grml2usb (0.11.5) unstable; urgency=low + + The "grml96 support ♫♫♫" release + + [ Ulrich Dangel ] + * [eb087c0] Support multiple flavours on a cd + * [4608131] Modify grub config files for the specified flavour instead + of all grub config files + * [c6af951] Streamline grml_flavour modification + * [c421fb3] Only modify live-media-path for current flavour + + -- Michael Prokop Wed, 11 Jan 2012 16:10:51 +0100 + grml2usb (0.11.4) unstable; urgency=low [ Ulrich Dangel ] -- 2.1.4 From f956c82e76971d2706f783b2e7907a14fb0e4196 Mon Sep 17 00:00:00 2001 From: Ulrich Dangel Date: Fri, 27 Jan 2012 03:52:56 +0100 Subject: [PATCH 02/16] Canonicalize overlay directory --- grml2iso | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grml2iso b/grml2iso index c4c13ee..d9236ee 100755 --- a/grml2iso +++ b/grml2iso @@ -78,7 +78,7 @@ Options: case $name in o) ISOFILE="$OPTARG";; b) GRML2USB_OPTS+=(--bootoptions="$OPTARG");; - c) DIR="$OPTARG";; + c) DIR="$(readlink -f "$OPTARG")";; f) FORCE='true';; r) GRML2USB_OPTS+=(--remove-bootoption="$OPTARG");; p) GRML2USB_OPTS+=("$OPTARG");; -- 2.1.4 From 7494e3f255313238eda9d6bfe3f96648b9adbb38 Mon Sep 17 00:00:00 2001 From: Ulrich Dangel Date: Fri, 27 Jan 2012 02:49:23 +0100 Subject: [PATCH 03/16] Support template parameters in overlay directory. For now only GRML_NAME, VERSION RELEASENAME DATE SHORT_NAME RELEASE_INFO and BOOTID are supported. As in grml-live grml2iso supports template filename as well which you will need for modifying file entries. --- grml2iso | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/grml2iso b/grml2iso index d9236ee..3e48b35 100755 --- a/grml2iso +++ b/grml2iso @@ -203,9 +203,42 @@ Options: # copy specified directory to cd {{{ if [ -n "$DIR" ] ; then echo >&2 "Copying ${DIR} to generated ISO" - rsync -a ${DIR}/ . + for param in GRML_NAME VERSION RELEASENAME DATE SHORT_NAME \ + VERSION BOOTID RELEASE_INFO ; do + EXCLUDE_PARAM="$EXCLUDE_PARAM --exclude **%${param}%**" + done + rsync -a ${DIR}/ $EXCLUDE_PARAM . fi + # adjust files from overlay directory + for GRML_VERSION_FILE in $(find . -name grml-version) ; do + GRML_NAME=$(awk '{print $1}' "$GRML_VERSION_FILE") + VERSION=$(awk '{print $2}' "$GRML_VERSION_FILE") + RELEASENAME=$(sed 's/.*- \(.*\).*\[.*/\1/' "$GRML_VERSION_FILE") + DATE=$(sed 's/.*\[\(.*\)].*/\1/' "$GRML_VERSION_FILE") + SHORT_NAME="$(echo $GRML_NAME | tr -d ',./;\- ')" + RELEASE_INFO="$GRML_NAME $VERSION - $RELEASENAME" + BOOTID=$(cat conf/bootid.txt) + + for param in GRML_NAME VERSION RELEASENAME DATE SHORT_NAME \ + RELEASE_INFO BOOTID ; do + value="$(eval echo '$'"$param")" + + # copy parameterized files from the overlay directory + for file in $(find ${DIR} -name "*%$param%*") ; do + file=${file##$DIR/} + target_dir="$(dirname ${file})" + mkdir -p "$target_dir" || true + cp -r ${DIR}/${file} ./${target_dir}/"$(basename ${file/\%${param}\%/$value})" + done + + # adjust config files + for file in ./boot/isolinux/*.cfg ./boot/isolinux/*.msg \ + ./boot/grub/*.cfg ; do + sed -i "s/%$param%/$value/g" ${file} 2>/dev/null || true + done + done + done # }}} # generate the CD/DVD ISO {{{ -- 2.1.4 From 939e6a970373e81e4f6a5d5ae65580dc2df40fe2 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 27 Jan 2012 12:34:18 +0100 Subject: [PATCH 04/16] Release new version 0.11.6 --- debian/changelog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/changelog b/debian/changelog index 68009d6..89363fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +grml2usb (0.11.6) unstable; urgency=low + + The "custom bootsplash without remastering ☕☕☕" release + + [ Ulrich Dangel ] + * [f956c82] grml2iso: Canonicalize overlay directory + * [7494e3f] grml2iso: Support template parameters in overlay directory. + For now only GRML_NAME, VERSION, RELEASENAME, DATE, SHORT_NAME, + RELEASE_INFO and BOOTID are supported. + + -- Michael Prokop Fri, 27 Jan 2012 12:29:21 +0100 + grml2usb (0.11.5) unstable; urgency=low The "grml96 support ♫♫♫" release -- 2.1.4 From f1cfc39202809f9172c7c1b833f6392f0ac23e5d Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 8 Feb 2012 23:14:38 +0100 Subject: [PATCH 05/16] grml2iso: use shell for calculation instead of using bc We are lacking a dependency on bc but there shouldn't be any reason why we'd have to use bc to calculate the cylinder foo, so let's just use the internal shell mechanism. --- grml2iso | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grml2iso b/grml2iso index 3e48b35..dc23036 100755 --- a/grml2iso +++ b/grml2iso @@ -248,8 +248,8 @@ Options: # pad the output ISO to multiples of 256 KiB for partition table support {{{ siz=$($getfilesize "$ISOFILE") - cyls=$(echo "$siz / 512 / 32 / 16 + 1" | bc) # C=$cyls H=16 S=32 - ofs=$(echo "$cyls * 16 * 32 * 512 - 1" | bc) # padding offset (size - 1) + cyls=$(($siz / 512 / 32 / 16 + 1)) # C=$cyls H=16 S=32 + ofs=$(($cyls * 16 * 32 * 512 - 1)) # padding offset (size - 1) dd if=/dev/zero bs=1 count=1 seek=$ofs of="$ISOFILE" 2>/dev/null # }}} -- 2.1.4 From 22238432167d60b8c1e781be26095995eb5de52a Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 5 Mar 2012 17:02:35 +0100 Subject: [PATCH 06/16] Rebuild loopback.cfg with present configuration files Related to grml-live's recent commit titled "Generate static loopback.cfg configuration without depending on GRUB's regexp module" (94a9b17) to address the regexp issue of Debian/squeeze's GRUB. --- grml2usb | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/grml2usb b/grml2usb index 42426ee..751d8cc 100755 --- a/grml2usb +++ b/grml2usb @@ -546,7 +546,7 @@ def install_mbr(mbrtemplate, device, partition, ismirbsdmbr=True): mbrcode[463:478] + actives[2] + \ mbrcode[479:494] + actives[3] + \ mbrcode[495:510] + "\x55\xAA" - + tmpf.file.seek(0) tmpf.file.truncate() tmpf.file.write(mbrcode) @@ -914,6 +914,36 @@ def copy_addons(iso_mount, target): # ipxe.lkrn handle_addon_copy('ipxe.lkrn', addons, iso_mount) + +def build_loopbackcfg(target): + """Generate GRUB's loopback.cfg based on existing config files. + + @target: target directory + """ + + grub_dir='/boot/grub/' + mkdir(os.path.join(target, grub_dir)) + + f = open(target + grub_dir + 'loopback.cfg','w') + + f.write("# grml2usb generated grub2 configuration file\n") + f.write("source /boot/grub/header.cfg\n") + + for defaults in glob.glob(target + os.path.sep + grub_dir + os.path.sep + "*_default.cfg"): + sourcefile = defaults.split(target + os.path.sep)[1] + logging.debug("Found source file" + sourcefile) + os.path.isfile(defaults) and f.write("source " + sourcefile + "\n") + + for ops in glob.glob(target + os.path.sep + grub_dir + os.path.sep + "*_options.cfg"): + sourcefile = ops.split(target + os.path.sep)[1] + logging.debug("Found source file" + sourcefile) + os.path.isfile(ops) and f.write("source " + sourcefile + "\n") + + f.write("source /boot/grub/adddons.cfg\n") + f.write("source /boot/grub/footer.cfg\n") + f.close() + + def glob_and_copy(filepattern, dst): """Glob on specified filepattern and copy the result to dst @@ -972,13 +1002,6 @@ def copy_bootloader_files(iso_mount, target, grml_flavour): for ffile in ['f%d' % number for number in range(1, 11) ]: search_and_copy(ffile, iso_mount, syslinux_target + ffile) - loopback_cfg = search_file("loopback.cfg", iso_mount) - if loopback_cfg: - directory = os.path.dirname(loopback_cfg) - directory = directory.replace(iso_mount, "") - mkdir(os.path.join(target, directory)) - exec_rsync(loopback_cfg, target + os.path.sep + directory) - # avoid the "file is read only, overwrite anyway (y/n) ?" question # of mtools by syslinux ("mmove -D o -D O s:/ldlinux.sys $target_file") if os.path.isfile(syslinux_target + 'ldlinux.sys'): @@ -1014,6 +1037,10 @@ def copy_bootloader_files(iso_mount, target, grml_flavour): # copy all grub files from ISO glob_and_copy(iso_mount + '/boot/grub/*', grub_target) + # finally (after all GRUB files have been been installed) build static loopback.cfg + build_loopbackcfg(target) + + def install_iso_files(grml_flavour, iso_mount, device, target): """Copy files from ISO to given target -- 2.1.4 From 5df5aeb6b85d70207ba1b7314407bbbb2c8492a7 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 25 Apr 2012 16:49:36 +0200 Subject: [PATCH 07/16] Bump Standards-Version to 3.9.3 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 23da388..41c217a 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: Grml Team Uploaders: Michael Prokop , Alexander Wirt , Christian Hofstaedtler , Ulrich Dangel DM-Upload-Allowed: yes Build-Depends: debhelper (>= 7), asciidoc, xsltproc, docbook-xsl -Standards-Version: 3.9.2 +Standards-Version: 3.9.3 Homepage: http://grml.org/grml2usb/ Vcs-git: git://git.grml.org/grml2usb.git Vcs-Browser: http://git.grml.org/?p=grml2usb.git -- 2.1.4 From 3505897e5173bd0336f21bee1124c242c8fd3fdf Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Wed, 25 Apr 2012 16:52:35 +0200 Subject: [PATCH 08/16] fix manpage markup - single dashes don't need to be escaped - * has to apear directly after the string --- grml2iso.8.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grml2iso.8.txt b/grml2iso.8.txt index 84a5146..69d97df 100644 --- a/grml2iso.8.txt +++ b/grml2iso.8.txt @@ -30,34 +30,34 @@ WRKDIR specifies the work directory for creating the filesystem. The work directory needs at least as much free disk space as the sum of all specified ISOs. - *\-o *:: + *-o *:: This option is mandatory and specifies where the resulting multiboot grml ISO should be placed. Note that (to avoid any possible data loss) grml2iso will exit if the specified target.iso exists already. - *\-c *:: + *-c *:: The content of the specified directory will be copied to the resulting multiboot grml ISO. - *\-b *:: + *-b *:: Use specified default bootoptions as default. - *\-f *:: + *-f*:: Force the program to run and overwrite an existing iso image. - *\-r *:: + *-r *:: Remove specified boot parameter from existing command line. Could be specified multiple times. - *\-p *:: + *-p *:: Execute grml2usb with the specified parameters. For a list of valid parameters have a look at the link:http://grml.org/grml2usb/[grml2usb webpage] or the grml2usb manpage - *\-s *:: + *-s *:: Generate a small iso file which downloads the squashfs file from the specified URI. Due to current limitations in busyboxs wget and DNS resolution, an URL can not contain a hostname but an IP only. This is useful if you want to boot systems which support booting iso image from your local system. Besides the iso image this command also copies the squashfs file to the output directory. -- 2.1.4 From 09149d774d47e757ca6df1e9363fa8cb75d41740 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 26 Apr 2012 17:56:10 +0200 Subject: [PATCH 09/16] Drop oudated tarball-online make target and support prepare-release instead --- Makefile | 5 +++-- tarball.sh | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5fa9476..9ed8a8a 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,9 @@ online: all tarball: all ./tarball.sh -tarball-online: tarball - scp grml2usb.tgz grml2usb.tgz.md5.asc grml:/var/www/grml/grml2usb/ +prepare-release: + ./tarball.sh --no-gpg + clean: rm -rf grml2usb.8.html grml2usb.8.xml grml2usb.8 diff --git a/tarball.sh b/tarball.sh index d643e5d..1f3b003 100755 --- a/tarball.sh +++ b/tarball.sh @@ -122,8 +122,17 @@ tar zcf grml2usb.tgz "${DIR}" rm -rf "${DIR}" md5sum grml2usb.tgz > grml2usb.tgz.md5 -gpg --clearsign grml2usb.tgz.md5 -rm grml2usb.tgz.md5 -echo "Generated grml2usb.tgz and grml2usb.tgz.md5.asc of grml2usb $VERSION" + +case "$1" in + --no-gpg) + echo "Not signing grml2usb.tgz.md5 as requested via --no-gpg." + echo "Do not forget to run gpg --clearsign grml2usb.tgz.md5 before uploading." + ;; + *) + gpg --clearsign grml2usb.tgz.md5 + rm grml2usb.tgz.md5 + echo "Generated grml2usb.tgz and grml2usb.tgz.md5.asc of grml2usb $VERSION" + ;; +esac ## END OF FILE ################################################################# -- 2.1.4 From 607fd410c2c8261498f4f9169fc74f7811a043f7 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 27 Apr 2012 02:42:44 +0200 Subject: [PATCH 10/16] pep8 cleanups --- grml2usb | 84 +++++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/grml2usb b/grml2usb index 751d8cc..80c5160 100755 --- a/grml2usb +++ b/grml2usb @@ -15,24 +15,33 @@ 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 datetime import fileinput import glob -import uuid +import logging +import os +import os.path +import re import struct +import subprocess +import sys +import tempfile +import time +import uuid # The line following this line is patched by debian/rules and tarball.sh. -PROG_VERSION='***UNRELEASED***' +PROG_VERSION = '***UNRELEASED***' # global variables -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? +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 """ @@ -41,6 +50,7 @@ def syslinux_warning(option, opt, value, opt_parser): "is grml2usb's default. Continuing anyway.\n") setattr(opt_parser.values, option.dest, True) + # if grub option is set, unset syslinux option def grub_option(option, opt, value, opt_parser): """A helper function adjusting other option values @@ -247,7 +257,8 @@ def get_defaults_file(iso_mount, flavour, name): "%s_%s" % (get_flavour_filename(flavour), name): if os.path.isfile(iso_mount + directory + name): return (directory, name) - return ('','') + return ('', '') + def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin'): """Given a search path, find file @@ -256,7 +267,7 @@ def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin'): @search_path: path where searching for the specified filename""" file_found = 0 paths = search_path.split(os.pathsep) - current_dir = '' # make pylint happy :) + current_dir = '' # make pylint happy :) def match_file(cwd): """Helper function ffor testing if specified file exists in cwd @@ -283,7 +294,7 @@ def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin'): def check_uid_root(): """Check for root permissions""" - if not os.geteuid()==0: + if not os.geteuid() == 0: sys.exit("Error: please run this script with uid 0 (root).") @@ -316,7 +327,7 @@ def generate_isolinux_splash(grml_flavour): Some information and boot options available via keys F2 - F10. http://grml.org/ %(grml_name)s -""" % {'grml_name': grml_name} ) +""" % {'grml_name': grml_name}) def generate_main_syslinux_config(*arg): @@ -364,7 +375,6 @@ def generate_flavour_specific_syslinux_config(grml_flavour): @grml_flavour: name of grml flavour the configuration should be generated for""" - return("""\ menu begin grml %(grml_flavour)s menu title %(display_name)s @@ -376,7 +386,7 @@ menu begin grml %(grml_flavour)s include %(grml_flavour)s_grml.cfg menu hide menu end -""" % {'grml_flavour': grml_flavour, 'display_name' : get_flavour_filename(grml_flavour) } ) +""" % {'grml_flavour': grml_flavour, 'display_name': get_flavour_filename(grml_flavour)}) def install_grub(device): @@ -405,7 +415,7 @@ def install_grub(device): grub_device = device logging.info("Installing grub as bootloader") - for opt in ["", "--force" ]: + 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", @@ -740,12 +750,14 @@ def get_uuid(target): execute(mkdir, conf_target) return write_uuid(uuid_file_name) + def get_shortname(grml_flavour): """Get shortname based from grml_flavour name. The rules applied are the same as in grml-live @grml_flavour: flavour name which shold be translated to shortname""" return re.sub(r'[,._-]', '', grml_flavour) + def copy_system_files(grml_flavour, iso_mount, target): """copy grml's main files (like squashfs, kernel and initrd) to a given target @@ -773,7 +785,6 @@ def copy_system_files(grml_flavour, iso_mount, target): else: exec_rsync(filesystem_module, squashfs_target + 'filesystem.module') - shortname = get_shortname(grml_flavour) if os.path.isdir(iso_mount + '/boot/' + shortname): exec_rsync(iso_mount + '/boot/' + shortname, target + '/boot') @@ -788,7 +799,7 @@ def copy_system_files(grml_flavour, iso_mount, target): raise CriticalException("error locating kernel file") source = os.path.dirname(kernel) + '/' - dest = target + '/' + os.path.dirname(kernel).replace(iso_mount,'') + '/' + dest = target + '/' + os.path.dirname(kernel).replace(iso_mount, '') + '/' execute(mkdir, dest) exec_rsync(source, dest) @@ -837,6 +848,7 @@ def update_grml_versions(iso_mount, target): else: return False + def copy_grml_files(grml_flavour, iso_mount, target): """copy some minor grml files to a given target @@ -849,12 +861,12 @@ def copy_grml_files(grml_flavour, iso_mount, target): grml_prefixe = ["GRML", "grml"] for prefix in grml_prefixe: - filename = "{0}/{1}/{2}".format(iso_mount, prefix, grml_flavour) - if os.path.exists(filename): - exec_rsync(filename, grml_target) - break + filename = "{0}/{1}/{2}".format(iso_mount, prefix, grml_flavour) + if os.path.exists(filename): + exec_rsync(filename, grml_target) + break else: - logging.warn("Warning: could not find flavour directory for %s ", grml_flavour) + logging.warn("Warning: could not find flavour directory for %s ", grml_flavour) def handle_addon_copy(filename, dst, iso_mount, ignore_errors=False): @@ -868,7 +880,7 @@ def handle_addon_copy(filename, dst, iso_mount, ignore_errors=False): file_location = search_file(filename, iso_mount) if file_location is None: if not ignore_errors: - logging.warn("Warning: %s not found (that's fine if you don't need it)", filename) + logging.warn("Warning: %s not found (that's fine if you don't need it)", filename) else: exec_rsync(file_location, dst) @@ -921,10 +933,10 @@ def build_loopbackcfg(target): @target: target directory """ - grub_dir='/boot/grub/' + grub_dir = '/boot/grub/' mkdir(os.path.join(target, grub_dir)) - f = open(target + grub_dir + 'loopback.cfg','w') + f = open(target + grub_dir + 'loopback.cfg', 'w') f.write("# grml2usb generated grub2 configuration file\n") f.write("source /boot/grub/header.cfg\n") @@ -953,6 +965,7 @@ def glob_and_copy(filepattern, dst): for name in glob.glob(filepattern): copy_if_exist(name, dst) + def search_and_copy(filename, search_path, dst): """Search for the specified filename at searchpath and copy it to dst @@ -963,6 +976,7 @@ def search_and_copy(filename, search_path, dst): file_location = search_file(filename, search_path) copy_if_exist(file_location, dst) + def copy_if_exist(filename, dst): """Copy filename to dst if filename is set. @@ -972,6 +986,7 @@ def copy_if_exist(filename, dst): if filename and (os.path.isfile(filename) or os.path.isdir(filename)): exec_rsync(filename, dst) + def copy_bootloader_files(iso_mount, target, grml_flavour): """Copy grml's bootloader files to a given target @@ -999,7 +1014,7 @@ def copy_bootloader_files(iso_mount, target, grml_flavour): mkdir(target + '/boot/') exec_rsync(efi_img, target + '/boot/efi.img') - for ffile in ['f%d' % number for number in range(1, 11) ]: + for ffile in ['f%d' % number for number in range(1, 11)]: search_and_copy(ffile, iso_mount, syslinux_target + ffile) # avoid the "file is read only, overwrite anyway (y/n) ?" question @@ -1028,7 +1043,6 @@ def copy_bootloader_files(iso_mount, target, grml_flavour): 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) @@ -1084,6 +1098,7 @@ def get_flavour(flavour_str): """ return re.match(r'[\w-]*', flavour_str).group() + def identify_grml_flavour(mountpath): """Get name of grml flavour @@ -1187,6 +1202,7 @@ def initial_syslinux_config(target): data.write("include hidden.cfg\n") data.close() + def add_entry_if_not_present(filename, entry): """Write entry into filename if entry is not already in the file @@ -1202,6 +1218,7 @@ def add_entry_if_not_present(filename, entry): data.close() + def get_flavour_filename(flavour): """Generate a iso9960 save filename out of the specified flavour @@ -1209,6 +1226,7 @@ def get_flavour_filename(flavour): """ return flavour.replace('-', '_') + def adjust_syslinux_bootoptions(src, flavour): """Adjust existing bootoptions of specified syslinux config to grml2usb specific ones, e.g. change the location of the kernel... @@ -1247,6 +1265,7 @@ def adjust_syslinux_bootoptions(src, flavour): sys.stdout.write(line) fileinput.close() + def adjust_labels(src, replacement): """Adjust the specified labels in the syslinux config file src with specified replacement @@ -1275,6 +1294,7 @@ def add_syslinux_entry(filename, grml_flavour): data.write(generate_flavour_specific_syslinux_config(grml_flavour)) data.close() + def modify_filenames(grml_flavour, target, filenames): """Replace the standard filenames with the new ones @@ -1314,7 +1334,6 @@ def handle_syslinux_config(grml_flavour, target): execute(mkdir, syslinux_target) syslinux_cfg = syslinux_target + 'syslinux.cfg' - # 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") @@ -1333,22 +1352,19 @@ def handle_syslinux_config(grml_flavour, target): filename = search_file("new_hidden.cfg", syslinux_target) - # process hidden file if not search_file("hidden.cfg", syslinux_target): new_hidden = syslinux_target + "hidden.cfg" os.rename(filename, new_hidden) adjust_syslinux_bootoptions(new_hidden, grml_flavour) else: - new_hidden_file = "%s/%s_hidden.cfg" % (syslinux_target, flavour_filename) + new_hidden_file = "%s/%s_hidden.cfg" % (syslinux_target, flavour_filename) os.rename(filename, new_hidden_file) adjust_labels(new_hidden_file, r'\1 %s-\2' % grml_flavour) adjust_syslinux_bootoptions(new_hidden_file, grml_flavour) entry = 'include %s_hidden.cfg\n' % flavour_filename add_entry_if_not_present("%s/hiddens.cfg" % syslinux_target, entry) - - new_default = "%s_default.cfg" % (flavour_filename) entry = 'include %s\n' % new_default defaults_file = '%s/defaults.cfg' % syslinux_target @@ -1401,7 +1417,6 @@ def handle_bootloader_config(grml_flavour, device, target): sys.exit(1) - def install(image, device): """Install a grml image to the specified device @@ -1434,7 +1449,6 @@ def install(image, device): cleanup() - def install_grml(mountpoint, device): """Main logic for copying files of the currently running grml system. @@ -1470,6 +1484,7 @@ def install_grml(mountpoint, device): if remove_device_mountpoint: remove_mountpoint(device_mountpoint) + def remove_mountpoint(mountpoint): """remove a registred mountpoint """ @@ -1483,6 +1498,7 @@ def remove_mountpoint(mountpoint): logging.critical("Fatal: %s", error) cleanup() + def handle_mbr(device): """Main handler for installing master boot record (MBR) @@ -1642,11 +1658,13 @@ def check_programs(): logging.critical("Fatal: rsync not available, can not continue - sorry.") sys.exit(1) + def load_loop(): """Runs modprobe loop and throws away it's output""" proc = subprocess.Popen(["modprobe", "loop"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc.wait() + def main(): """Main function [make pylint happy :)]""" -- 2.1.4 From c2d87f6b8fe71af172bbc0c8a3edc6f933739ef2 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 9 May 2012 12:58:40 +0200 Subject: [PATCH 11/16] Adjust PROG_VERSION code in debian/rules for pep8 cleanup --- debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index eadf441..0ba3486 100755 --- a/debian/rules +++ b/debian/rules @@ -18,7 +18,7 @@ build-indep: build-stamp build-stamp: dh_testdir - egrep -q "PROG_VERSION='\*\*\*UNRELEASED\*\*\*'" grml2usb || (echo "PROG_VERSION in grml2usb wrong." && exit 2) + egrep -q "PROG_VERSION = '\*\*\*UNRELEASED\*\*\*'" grml2usb || (echo "PROG_VERSION in grml2usb wrong." && exit 2) $(MAKE) cd mbr && $(MAKE) && cd .. touch build-stamp @@ -41,7 +41,7 @@ install: build # Add here commands to install the package into debian/grml2usb. install -m 755 grml2usb debian/grml2usb/usr/sbin/grml2usb - sed -i -e "s/PROG_VERSION='\*\*\*UNRELEASED\*\*\*'/PROG_VERSION='$(VERSION)'/" debian/grml2usb/usr/sbin/grml2usb + sed -i -e "s/PROG_VERSION = '\*\*\*UNRELEASED\*\*\*'/PROG_VERSION = '$(VERSION)'/" debian/grml2usb/usr/sbin/grml2usb install -m 755 grml2iso debian/grml2usb/usr/sbin/grml2iso install -m 644 mbr/mbrmgr debian/grml2usb/usr/share/grml2usb/mbr/mbrmgr install -m 644 mbr/mbrldr debian/grml2usb/usr/share/grml2usb/mbr/mbrldr -- 2.1.4 From f377e973e94daa06304ea975105319386cb2a0cf Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 9 May 2012 12:59:02 +0200 Subject: [PATCH 12/16] Release new version 0.12.0 --- debian/changelog | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/debian/changelog b/debian/changelog index 89363fb..983ff31 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +grml2usb (0.12.0) unstable; urgency=low + + [ Michael Prokop ] + * [f1cfc39] grml2iso: use shell for calculation instead of using bc + * [2223843] Rebuild loopback.cfg with present configuration files + * [5df5aeb] Bump Standards-Version to 3.9.3 + * [09149d7] Drop oudated tarball-online make target and support + prepare-release instead + * [607fd41] pep8 cleanups + * [c2d87f6] Adjust PROG_VERSION code in debian/rules for pep8 cleanup + + [ Evgeni Golov ] + * [3505897] fix manpage markup + + -- Michael Prokop Wed, 09 May 2012 12:58:46 +0200 + grml2usb (0.11.6) unstable; urgency=low The "custom bootsplash without remastering ☕☕☕" release -- 2.1.4 From 7c076d1dd83dc76e700f430d33d81507c322de30 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sun, 27 May 2012 21:36:04 +0200 Subject: [PATCH 13/16] Support multiple flavours inside one ISO On grml96 we have multiple grml-version files inside one single ISO, so we need to find all those grml-version files. Thanks: Christopher Schramm for the bugreport Thanks: Ulrich Dangel for the patch Closes: issue1172 --- grml2usb | 57 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/grml2usb b/grml2usb index 80c5160..0a34583 100755 --- a/grml2usb +++ b/grml2usb @@ -121,7 +121,7 @@ if not os.path.isdir(GRML2USB_BASE): class CriticalException(Exception): - """Throw critical exception if the exact error is not known but fatal." + """Throw critical exception if the exact error is not known but fatal. @Exception: message""" pass @@ -260,14 +260,15 @@ def get_defaults_file(iso_mount, flavour, name): return ('', '') -def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin'): +def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin', lst_return=False): """Given a search path, find file @filename: name of file to search for - @search_path: path where searching for the specified filename""" - file_found = 0 + @search_path: path where searching for the specified filename + @lst_return: return list of matching files instead one file""" paths = search_path.split(os.pathsep) current_dir = '' # make pylint happy :) + retval = [] def match_file(cwd): """Helper function ffor testing if specified file exists in cwd @@ -279,15 +280,19 @@ def search_file(filename, search_path='/bin' + os.pathsep + '/usr/bin'): for path in paths: current_dir = path if match_file(current_dir): - file_found = 1 - break + retval.append(os.path.abspath(os.path.join(current_dir, filename))) + if not lst_return: + break # pylint: disable-msg=W0612 for current_dir, directories, files in os.walk(path): if match_file(current_dir): - file_found = 1 - break - if file_found: - return os.path.abspath(os.path.join(current_dir, filename)) + retval.append(os.path.abspath(os.path.join(current_dir, filename))) + if not lst_return: + break + if lst_return: + return retval + elif retval: + return retval[0] else: return None @@ -1105,26 +1110,28 @@ def identify_grml_flavour(mountpath): @mountpath: path where the grml ISO is mounted to @return: name of grml-flavour""" - version_file = search_file('grml-version', mountpath) + version_files = search_file('grml-version', mountpath, lst_return=True) - if version_file == "": + if not version_files: logging.critical("Error: could not find grml-version file.") raise flavours = [] - tmpfile = None - try: - tmpfile = open(version_file, 'r') - for line in tmpfile.readlines(): - flavours.append(get_flavour(line)) - except TypeError, e: - raise - except Exception, e: - logging.critical("Unexpected error: %s", e) - raise - finally: - if tmpfile: - tmpfile.close() + logging.debug("version_files = %s", version_files) + for version_file in version_files: + tmpfile = None + try: + tmpfile = open(version_file, 'r') + for line in tmpfile.readlines(): + flavours.append(get_flavour(line)) + except TypeError, e: + raise + except Exception, e: + logging.critical("Unexpected error: %s", e) + raise + finally: + if tmpfile: + tmpfile.close() return flavours -- 2.1.4 From 9b5a5195ba1343ba9ee9d2e20be81e9c25565701 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Sun, 27 May 2012 22:23:27 +0200 Subject: [PATCH 14/16] Release new version 0.12.1 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 983ff31..b79a46c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml2usb (0.12.1) unstable; urgency=low + + * [7c076d1] Support multiple flavours inside one ISO. Thanks to Ulrich + Dangel for the patch (Closes: issue1172) + + -- Michael Prokop Sun, 27 May 2012 22:23:07 +0200 + grml2usb (0.12.0) unstable; urgency=low [ Michael Prokop ] -- 2.1.4 From f3a85acbbab6bd1f0140bdf8e7496d983a8a7c15 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 28 May 2012 17:05:44 +0200 Subject: [PATCH 15/16] copy_addons: install all *.c32 addons in /boot/addons/ Do not depend on options.syslinux, instead always install the files --- grml2usb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/grml2usb b/grml2usb index 0a34583..075029e 100755 --- a/grml2usb +++ b/grml2usb @@ -902,22 +902,15 @@ def copy_addons(iso_mount, target): # grub all-in-one image handle_addon_copy('allinone.img', addons, iso_mount) - # bsd imag + # bsd image handle_addon_copy('bsd4grml', addons, iso_mount) + # DOS image handle_addon_copy('balder10.imz', addons, iso_mount) - # install hdt and pci.ids only when using syslinux (grub doesn't support it) - if options.syslinux: - # hdt (hardware detection tool) image - hdtimg = search_file('hdt.c32', iso_mount) - if hdtimg: - exec_rsync(hdtimg, addons + '/hdt.c32') - - # pci.ids file - picids = search_file('pci.ids', iso_mount) - if picids: - exec_rsync(picids, addons + '/pci.ids') + # syslinux + pci.ids for hdt + for expr in '*.c32', 'pci.ids': + glob_and_copy(iso_mount + '/boot/addons/' + expr, addons) # memdisk image handle_addon_copy('memdisk', addons, iso_mount) -- 2.1.4 From 4681f33de8775160a184f01a0ec067a777be0e93 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 28 May 2012 17:17:24 +0200 Subject: [PATCH 16/16] Release new version 0.12.2 --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index b79a46c..2e8b714 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml2usb (0.12.2) unstable; urgency=low + + * [f3a85ac] copy_addons: install all *.c32 addons in /boot/addons/ + (fixing broken addon entries in grml96 ISOs) + + -- Michael Prokop Mon, 28 May 2012 17:16:40 +0200 + grml2usb (0.12.1) unstable; urgency=low * [7c076d1] Support multiple flavours inside one ISO. Thanks to Ulrich -- 2.1.4