X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=bin%2Flive-new-uuid;h=2e29f6a6f9f98ba2a5efa412737d8d859319bda0;hb=516cef1024f401735992bba54ab4922b767b6a6a;hp=4a6afa6d718c32bd38350dcb4037b1c5ba0c1914;hpb=47527b7666b1a12122a0b17098064e7af745d097;p=live-boot-grml.git diff --git a/bin/live-new-uuid b/bin/live-new-uuid index 4a6afa6..2e29f6a 100755 --- a/bin/live-new-uuid +++ b/bin/live-new-uuid @@ -1,9 +1,9 @@ #!/bin/sh # -*- coding: utf-8 -*- # -# «casper-new-uuid» - Creates and injects new UUIDs for casper disks +# «live-new-uuid» - Creates and injects new UUIDs for live disks # -# Create new UUIDs for disks to prevent conflicts and booting the wrong casper +# Create new UUIDs for disks to prevent conflicts and booting the wrong live # directory. Particularly useful in creating recovery disks that need to be # able to also work with recovery partitioning schemes. # @@ -31,14 +31,14 @@ set -e help() { echo - echo "USAGE: $0 initrd.gz " + echo "USAGE: $0 initrd.{l,g}z " echo - echo "initrd.gz is the absolute path to the original gzipped initramfs" - echo " is the destination directory for the new gzipped initramfs" - echo " is the destination directory for the new casper-uuid-TYPE " + echo "initrd.{l,g}z is the absolute path to the original gzipped or lzmaed initramfs" + echo " is the destination directory for the new compressed initramfs" + echo " is the destination directory for the new live-uuid-TYPE " echo echo "if either path is absent, they will end up in the current directory " - echo "TYPE is determined by an already existing casper-uuid-* or by 'uname -s'" + echo "TYPE is determined by an already existing live-uuid-* or by 'uname -s'" } if [ "$#" = "0" ] || [ "x$1" = x-h ] || [ "x$1" = x--help ]; then @@ -50,26 +50,37 @@ CWD=`pwd` TEMPDIR=`mktemp -d /tmp/uuid-XXXXXX` TYPE=`uname -r | cut -d '-' -f 3` +if echo "$1" | grep ".lz$" >/dev/null; then + COMPRESSOR="lzma" + SUFFIX=".lz" +elif echo "$1" | grep ".gz$" >/dev/null; then + COMPRESSOR="gzip" + SUFFIX=".gz" +else + echo "Unsupported archive type." + exit 2 +fi + if [ -z "$2" ] || [ ! -d "$2" ] || [ "$2" = "." ]; then - GZIPDIR="$CWD" + COMPRESS_DIR="$CWD" else - GZIPDIR="$2" + COMPRESS_DIR="$2" fi if [ -z "$3" ] || [ ! -d "$3" ] || [ "$3" = "." ]; then - CASPERDIR="$CWD" + LIVEDIR="$CWD" else - CASPERDIR="$3" + LIVEDIR="$3" fi cd "$TEMPDIR" -zcat "$1" | cpio -id +$COMPRESSOR -cd "$1" -S "$SUFFIX" | cpio -id uuidgen -r > conf/uuid.conf -find . | cpio --quiet --dereference -o -H newc | gzip > "$GZIPDIR/initrd.gz" -if [ "$(ls "$CASPERDIR/casper-uuid"-* >/dev/null 2>&1 | wc -l)" = 1 ]; then - cp conf/uuid.conf "$CASPERDIR/casper-uuid"-* +find . | cpio --quiet --dereference -o -H newc | $COMPRESSOR -9c > "$COMPRESS_DIR/initrd$SUFFIX" +if [ "$(ls "$LIVEDIR/live-uuid"-* >/dev/null 2>&1 | wc -l)" = 1 ]; then + cp conf/uuid.conf "$LIVEDIR/live-uuid"-* else - cp conf/uuid.conf "$CASPERDIR/casper-uuid-$TYPE" + cp conf/uuid.conf "$LIVEDIR/live-uuid-$TYPE" fi cd "$CWD" rm -rf "$TEMPDIR"