kumquat-buildroot/support/download/hg
Yann E. MORIN 76b51f90c0 support/download: generate reproducible Hg archives
When hg directly creates the output file, the hash for that file changes
everytime.

However, if we just tell hg to output the archive on stdout and we do
the redirect to the file, then the archive is reproducible.

(The reason is that in the first case, a temporary file is created and
then compressed, and gzip is adding the filename and its timestamp in
the gzip header, while in the second case, there is no temporary file,
and thus no timestamp and thus it is reproducible.)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2016-01-03 21:50:38 +01:00

39 lines
891 B
Bash
Executable File

#!/usr/bin/env bash
# We want to catch any unexpected failure, and exit immediately
set -e
# Download helper for hg, to be called from the download wrapper script
#
# Call it as:
# .../hg [-q] OUT_FILE REPO_URL CSET BASENAME
#
# Environment:
# HG : the hg command to call
verbose=
while getopts :q OPT; do
case "${OPT}" in
q) verbose=-q;;
\?) printf "unknown option '%s'\n" "${OPTARG}" >&2; exit 1;;
esac
done
shift $((OPTIND-1))
output="${1}"
repo="${2}"
cset="${3}"
basename="${4}"
# Caller needs to single-quote its arguments to prevent them from
# being expanded a second time (in case there are spaces in them)
_hg() {
eval ${HG} "${@}"
}
_hg clone ${verbose} --noupdate "'${repo}'" "'${basename}'"
_hg archive ${verbose} --repository "'${basename}'" --type tgz \
--prefix "'${basename}'" --rev "'${cset}'" \
- >"${output}"