diff options
author | P. J. McDermott <pj@pehjota.net> | 2014-08-22 12:06:17 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2014-08-22 12:06:17 (EDT) |
commit | f43fcb1ad907b9c22da1c121fcede22dc3cf0a47 (patch) | |
tree | e52b7c5bc22963e873c9195f1e1f74e64cc910af /lib | |
parent | 2f2fa67818ac18d146852ebb9d40cb7eda8c16e3 (diff) |
install: Verify checksums
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cmd/install.sh | 18 |
1 files changed, 18 insertions, 0 deletions
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}" |