diff options
Diffstat (limited to 'support/download/dl-wrapper')
-rwxr-xr-x | support/download/dl-wrapper | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper index dc5b4b08db..f0cdd735b4 100755 --- a/support/download/dl-wrapper +++ b/support/download/dl-wrapper @@ -21,14 +21,15 @@ set -e main() { local OPT OPTARG - local backend output + local backend output hfile # Parse our options; anything after '--' is for the backend - while getopts :hb:o: OPT; do + while getopts :hb:o:H: OPT; do case "${OPT}" in h) help; exit 0;; b) backend="${OPTARG}";; o) output="${OPTARG}";; + H) hfile="${OPTARG}";; :) error "option '%s' expects a mandatory argument\n" "${OPTARG}";; \?) error "unknown option '%s'\n" "${OPTARG}";; esac @@ -42,6 +43,9 @@ main() { if [ -z "${output}" ]; then error "no output specified, use -o\n" fi + if [ -z "${hfile}" ]; then + error "no hash-file specified, use -H\n" + fi # If the output file already exists, do not download it again if [ -e "${output}" ]; then @@ -75,6 +79,13 @@ main() { # cd back to free the temp-dir, so we can remove it later cd "${OLDPWD}" + # Check if the downloaded file is sane, and matches the stored hashes + # for that file + if ! support/download/check-hash "${hfile}" "${tmpf}" "${output##*/}"; then + rm -rf "${tmpd}" + exit 1 + fi + # tmp_output is in the same directory as the final output, so we can # later move it atomically. tmp_output="$(mktemp "${output}.XXXXXX")" @@ -150,6 +161,10 @@ DESCRIPTION -o FILE Store the downloaded archive in FILE. + -H FILE + Use FILE to read hashes from, and check them against the downloaded + archive. + Exit status: 0 if OK !0 in case of error |