From f43fcb1ad907b9c22da1c121fcede22dc3cf0a47 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 22 Aug 2014 12:06:17 -0400 Subject: install: Verify checksums --- (limited to 'lib/cmd') diff --git a/lib/cmd/install.sh b/lib/cmd/install.sh index 4483843..3bfdfa4 100644 --- a/lib/cmd/install.sh +++ b/lib/cmd/install.sh @@ -209,6 +209,8 @@ cmd_install_get_pkgs() local status_fd= local pkg= local fname= + local md5sum= + local sha256sum= local file= local control= local field= @@ -224,10 +226,26 @@ cmd_install_get_pkgs() info "$(get_msg 'cmd_install_downloading_pkg')" "${pkg}" fname="$(printf '%s\n' "${cmd_install_fnames}" | \ sed -n "s/^${pkg} //p")" + md5sum="$(printf '%s\n' "${cmd_install_md5sums}" | \ + sed -n "s/^${pkg} //p")" + sha256sum="$(printf '%s\n' "${cmd_install_sha256sums}" | \ + sed -n "s/^${pkg} //p")" wget -q -O "${chroot}/var/cache/opkg/archives/${fname##*/}" \ "${fname}" || \ error 2 "$(get_msg 'cmd_install_downloading_pkg_fail')" fname="var/cache/opkg/archives/${fname##*/}" + if [ "x${md5sum}" != 'x' ]; then + printf '%s %s\n' \ + "${md5sum}" "${chroot}/${fname}" | \ + md5sum -c >/dev/null 2>&1 || \ + error 2 "$(get_msg 'cmd_install_checksum_fail')" + fi + if [ "x${sha256sum}" != 'x' ]; then + printf '%s %s\n' \ + "${sha256sum}" "${chroot}/${fname}" | \ + sha256sum -c >/dev/null 2>&1 || \ + error 2 "$(get_msg 'cmd_install_checksum_fail')" + fi info "$(get_msg 'cmd_install_unpacking_pkg')" "${pkg}" mkdir "${chroot}/tmp/opkg/${pkg}" -- cgit v0.9.1