From e750115fdd71ae3c26f954a667b7d33643b8aeb7 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Tue, 2 Aug 2016 11:53:08 +0800 Subject: buildlive: update checksum function, add grub.cfg --- buildlive | 17 ++++++++--------- functions.sh | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/buildlive b/buildlive index 94b2101..e1c971f 100755 --- a/buildlive +++ b/buildlive @@ -32,6 +32,7 @@ do || fatalerror "UUID of $ROOTPATH not found, not a mountpoint?")" KERNELDIR="$ROOTPATH/liveusb-kernel" DATADIR="$ROOTPATH/liveusb-data" + GRUBCFG="$ROOTPATH/grub/grub.cfg" install -d "$KERNELDIR" "$DATADIR" msg "Files will be copy to $ROOTPATH" ;; @@ -55,20 +56,18 @@ do shift done +install -d "$ROOTPATH/grub" +echo "uuid=$UUID" > "$GRUBCFG" + for i in ${DISTROLIST[@]} do - process_distro "$i" - if [ -f "isofiles/$ISOFILE" ]; then - CKSUM=$(sha256sum "isofiles/$ISOFILE" | cut -d' ' -f1) - if [[ $CKSUM == $SHA256 ]]; then - msg "$ISOFILE ok." - else - fatalerror "$ISOFILE checksum bad!" - fi + process_distro "$i" + if [ -f "isofiles/$ISOFILE" ]; then + checksum_verify else fatalerror "File isofiles/$ISOFILE not found!" fi install_live + cat "distro/$i/grub.cfg" >> "$GRUBCFG" done - diff --git a/functions.sh b/functions.sh index d4ddfc7..e44b8a7 100644 --- a/functions.sh +++ b/functions.sh @@ -1,4 +1,27 @@ +checksum_verify() { + local _hashtool _hashsum _cksum + if [ -n "$SHA256" ]; then + _hashtool=sha256sum + _hashsum=$SHA256 + elif [ -n "$SHA1" ]; then + _hashtool=sha1sum + _hashsum=$SHA1 + elif [ -n "$MD5" ]; then + _hashtool=md5sum + _hashsum=$MD5 + else + fatalerror "Cannot find the SHA256, SHA1, or MD5 checksum of $ISOFILE" + fi + _cksum=$("$_hashtool" "isofiles/$ISOFILE" | cut -d' ' -f1) + if [[ $_cksum == $_hashsum ]]; then + msg "$ISOFILE ok." + else + fatalerror "$ISOFILE checksum bad!" + fi +} + process_distro() { + unset MD5 SHA1 SHA256 source "distro/$1/install.sh" ISOFILE="$(basename $ISOURL)" ISOMNT="/media/$ISOFILE" -- cgit v1.2.3