From 8a38afd4795ce976978e3be0fd539cda1a3da243 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 15 Aug 2011 16:29:11 -0400 Subject: Support using md5 and shaN programs, as found on FreeBSD, in addition to md5sum and shaNsum. Based on the patch used for the FreeBSD port of debootstrap: http://www.freebsd.org/cgi/cvsweb.cgi/ports/sysutils/debootstrap/files/patch-functions?rev=1.3;content-type=text%2Fplain That entire patch should now be unnecessary. --- debian/changelog | 2 ++ debootstrap | 2 +- functions | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 72ca0a8..05bda1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ debootstrap (1.0.36) UNRELEASED; urgency=low chroot or jail. * Clarify "target" in usage message. * Search PATH for programs, rather than checking hardcoded locations. + * Support using md5 and shaN programs, as found on FreeBSD, in addition + to md5sum and shaNsum. -- Joey Hess Mon, 15 Aug 2011 14:14:29 -0400 diff --git a/debootstrap b/debootstrap index 278ed64..ca4c026 100755 --- a/debootstrap +++ b/debootstrap @@ -447,7 +447,7 @@ fi if [ -z "$SHA_SIZE" ]; then SHA_SIZE=256 fi -if ! in_path "sha${SHA_SIZE}sum"; then +if ! in_path "sha${SHA_SIZE}sum" && ! in_path "sha${SHA_SIZE}"; then SHA_SIZE=1 fi DEBOOTSTRAP_CHECKSUM_FIELD="SHA$SHA_SIZE" diff --git a/functions b/functions index 80844de..e07ca69 100644 --- a/functions +++ b/functions @@ -249,9 +249,21 @@ verify_checksum () { local expchecksum="$2" local expsize="$3" if [ "$DEBOOTSTRAP_CHECKSUM_FIELD" = "MD5SUM" ]; then - relchecksum=`md5sum < "$1" | sed 's/ .*$//'` + if in_path md5sum; then + relchecksum=`md5sum < "$1" | sed 's/ .*$//'` + elif in_path md5; then + relchecksum=`md5 < "$1"` + else + error 1 SIGCHECK "Cannot check md5sum" + fi else - relchecksum=`sha${SHA_SIZE}sum < "$1" | sed 's/ .*$//'` + if in_path "sha${SHA_SIZE}sum"; then + relchecksum=`sha${SHA_SIZE}sum < "$1" | sed 's/ .*$//'` + elif in_path "sha${SHA_SIZE}"; then + relchecksum=`sha${SHA_SIZE} < "$1"` + else + error 1 SIGCHECK "Cannot check sha${SHA_SIZE}sum" + fi fi relsize=`wc -c < "$1"` if [ "$expsize" -ne "$relsize" ] || [ "$expchecksum" != "$relchecksum" ]; then -- cgit v1.2.3