summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-12-28 20:08:30 +0800
committerIru Cai <mytbk920423@gmail.com>2018-12-28 20:08:30 +0800
commit51344fd4ffce9298b976255890edec6f214845a4 (patch)
tree5db4c441def40b8e2179781353b2402e42fdcf5b
parentd44f8aa5b0241150be607de76b5c612cf61ac767 (diff)
downloadliveusb-builder-51344fd4ffce9298b976255890edec6f214845a4.tar.xz
a common hashfile verify function
-rw-r--r--distro/debian/isoinfo.common16
-rw-r--r--functions.sh14
2 files changed, 17 insertions, 13 deletions
diff --git a/distro/debian/isoinfo.common b/distro/debian/isoinfo.common
index 44da88b..3ab1727 100644
--- a/distro/debian/isoinfo.common
+++ b/distro/debian/isoinfo.common
@@ -2,20 +2,10 @@ _isover=9.6.0
ISONAME="$DISTRONAME $_isover amd64 ${_desktop}"
ISOURL="${_isover}-live/amd64/iso-hybrid/debian-live-${_isover}-amd64-${_desktop,,}.iso"
-VERIFY=sha512chk
+HASHTOOL=sha512sum
+HASHFILE=distro/debian/SHA512SUMS
+VERIFY=hashfile
mirrorlist=(
https://mirrors.tuna.tsinghua.edu.cn/debian-cd
http://mirrors.ustc.edu.cn/debian-cd
)
-
-sha512chk() {
- local _cksum _hashsum
- _cksum=$(sha512sum "$ISOPATH/$ISOFILE" | cut -d' ' -f1)
- _hashsum=$(grep "${ISOFILE}\$" distro/debian/SHA512SUMS | cut -d' ' -f1)
-
- if [[ $_cksum == $_hashsum ]]; then
- msg "$ISOFILE ok."
- else
- msg "$ISOFILE checksum bad!" && return 1
- fi
-}
diff --git a/functions.sh b/functions.sh
index 488141f..45c6ac6 100644
--- a/functions.sh
+++ b/functions.sh
@@ -25,6 +25,20 @@ checksum_verify() {
fi
}
+# a hash verify function that uses a checksum file
+# usage: set HASHTOOL and HASHFILE in isoinfo, set VERIFY as hashfile
+hashfile() {
+ local _cksum _hashsum
+ _cksum=$("$HASHTOOL" "$ISOPATH/$ISOFILE" | cut -d' ' -f1)
+ _hashsum=$(grep "${ISOFILE}\$" "$HASHFILE" | cut -d' ' -f1)
+
+ if [[ $_cksum == $_hashsum ]]; then
+ msg "$ISOFILE ok."
+ else
+ msg "$ISOFILE checksum bad!" && return 1
+ fi
+}
+
set_distro() {
_distrobase="distro/$(cut -d'/' -f1 <<< "$1")"
source "$_distrobase/distroinfo"