Use `md5` if `md5sum` is not available (useful for FreeBSD users).
authorZac Medico <zmedico@gentoo.org>
Sat, 24 Nov 2007 18:28:15 +0000 (18:28 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 24 Nov 2007 18:28:15 +0000 (18:28 -0000)
svn path=/main/trunk/; revision=8643

bin/misc-functions.sh

index e13e1ea7643728bd39877864110a33d9706d9886..2e860453e6ab4fd04fb6b810c789e7c4dc396850 100755 (executable)
@@ -527,8 +527,16 @@ dyn_package() {
                rm -f "${PORTAGE_BINPKG_TMPFILE}"
                die "Failed to append metadata to the tbz2 file"
        fi
-       local md5sum_output=$(md5sum "${PORTAGE_BINPKG_TMPFILE}")
-       echo ${md5sum_output%% *} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
+       local md5_hash=""
+       if type md5sum &>/dev/null ; then
+               md5_hash=$(md5sum "${PORTAGE_BINPKG_TMPFILE}")
+               md5_hash=${md5_hash%% *}
+       elif type md5 &>/dev/null ; then
+               md5_hash=$(md5 "${PORTAGE_BINPKG_TMPFILE}")
+               md5_hash=${md5_hash##* }
+       fi
+       [ -n "${md5_hash}" ] && \
+               echo ${md5_hash} > "${PORTAGE_BUILDDIR}"/build-info/BINPKGMD5
        vecho ">>> Done."
        cd "${PORTAGE_BUILDDIR}"
        touch .packaged || die "Failed to 'touch .packaged' in ${PORTAGE_BUILDDIR}"