mrrl

Minimal Reliable Reproducible Linux
git clone https://ccx.te2000.cz/git/mrrl
Log | Files | Refs | Submodules | README

commit 4d63686fc540d853b3cb86184e2e3e77c79a8ae0
parent 0e342864d6c4c441e1302632d13bc6c399a0d6c0
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Sat, 10 Jun 2023 22:06:20 +0200

Simple download script

Diffstat:
Mcommand/pthbs-download | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Apackages/default.environment | 2++
2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/command/pthbs-download b/command/pthbs-download @@ -2,4 +2,53 @@ echo >&2 "$0 not implemented yet" set -x : "$@" + +test $# -gt 3 || exit 2 +checksum_format=$1 +checksum=$2 +size=$3 +shift 3 || exit +filename=downloads/$checksum_format/$checksum + +case $checksum_format in + (md5);; + (sha1);; + (sha256);; + (sha3);; + (sha512);; + (*) + printf>&2 "FATAL: unrecognized checksum format '%s'\n" "$checksum_format" + exit 1 + ;; +esac + +check() { + find "$filename" -type f -size +"$size"c -delete + case $(find "$filename" -type f -size "$size"c -print) in + ($filename);; + (*) return 1;; + esac + if printf '%s %s\n' "$checksum" "$filename" | ${checksum_format}sum -c -; then + ln -sf "../../$filename" files/by-sha256 || exit 1 + return 0 + fi + rm -v "$filename" + exit 1 +} + +mkdir -p "downloads/$checksum_format" || exit $? + +if check; then + exit 0 +fi + +while test $# -gt 0; do + wget -cqO "$filename" -- "$1" + if check; then + exit 0 + fi + shift +done + +printf>&2 "FATAL: could not download file\n" exit 1 diff --git a/packages/default.environment b/packages/default.environment @@ -0,0 +1 @@ +#+busybox.adf5048c38bc2bca753b6949eb1e9effcd803fa1138f11a209fc891fb153cc80+ \ No newline at end of file