diff options
| -rwxr-xr-x | add-github-mirror | 27 | ||||
| -rwxr-xr-x | gen-checksums | 1 | ||||
| -rw-r--r-- | util/README | 7 | ||||
| -rwxr-xr-x | util/add-mirror | 16 | ||||
| -rwxr-xr-x | util/check-mirror | 40 |
5 files changed, 91 insertions, 0 deletions
diff --git a/add-github-mirror b/add-github-mirror new file mode 100755 index 0000000..063cfa5 --- /dev/null +++ b/add-github-mirror @@ -0,0 +1,27 @@ +#!/bin/sh +# See LICENSE file for copyright and license details. + +set -e + +if test ! $# = 2; then + printf 'usage: %s project version\n' "$0" >&2 + exit 1 +fi + +die () { + printf '%s\n' "$@" >&2 + exit 1 +} + +url="https://github.com/maandree/$1/archive/$2.tar.gz" + +tarball=".static/$1-$2.tar.gz" +infofile="rel/$1/$2.info" +sumfile="rel/$1/$2.checksums" +test -e "${tarball}" || die "${tarball} does not exist" +test -e "${infofile}" || die "${infofile} does not exist" +test -e "${sumfile}" || die "${sumfile} does not exist" + +checksums="$("$(dirname -- "$0")"/util/add-mirror "${url}" "${tarball}" < ${sumfile})" +printf '%s\n' "${checksums}" > "${sumfile}" +printf 'Tarball: %s\n' "${url}" >> "${infofile}" diff --git a/gen-checksums b/gen-checksums index d33b7b2..08264a0 100755 --- a/gen-checksums +++ b/gen-checksums @@ -1,4 +1,5 @@ #!/bin/sh +# See LICENSE file for copyright and license details. set -e diff --git a/util/README b/util/README index cc72f08..36426f1 100644 --- a/util/README +++ b/util/README @@ -62,6 +62,13 @@ get-and-check tarball-url reference-dir work-dir checksums. +check-mirror tarball-url ref-tarball work-dir + + This is the same as get-and-check except it expects a + known good tarball as the second argument instead of a + known good git repository + + gen-checksums tarball git-dir < tarball-url-list > checksum-listing This brings all of the above together. The tarball, diff --git a/util/add-mirror b/util/add-mirror new file mode 100755 index 0000000..70f9496 --- /dev/null +++ b/util/add-mirror @@ -0,0 +1,16 @@ +#!/bin/sh +# See LICENSE file for copyright and license details. + +set -e + +if test ! $# = 2 || test -t 0 || test -t 1; then + printf 'usage: %s tarball-url ref-tarball < old-checksums > all-checksums\n' "$0" >&2 + exit 1 +fi + +utildir="$(dirname -- "$0")" +(cd -- "${utildir}" && (make >/dev/null 2>/dev/null || make)) + +new_checksums="$("${utildir}"/tmpmount /var/empty "${utildir}"/check-mirror "$1" "$2" /var/empty)" + +(printf '%s\n' "${new_checksums}"; cat) | "${utildir}"/order-checksums diff --git a/util/check-mirror b/util/check-mirror new file mode 100755 index 0000000..ecf01b7 --- /dev/null +++ b/util/check-mirror @@ -0,0 +1,40 @@ +#!/bin/sh +# See LICENSE file for copyright and license details. + +set -e + +if ! test $# = 3; then + printf 'usage: %s tarball-url ref-tarball work-dir\n' "$0" >&2 + exit 1 +fi + +utildir="$(dirname -- "$0")" +tarball="$3/download-$$.tar.gz" +refdir="$3/$$.refdir" +tmpdir="$3/$$.tmpdir" + +rm -rf -- "${refdir}" +rm -rf -- "${tmpdir}" +mkdir -- "${refdir}" +mkdir -- "${tmpdir}" + +curl -sL -- "$1" > "${tarball}" +gunzip < "${tarball}" | (cd -- "${tmpdir}" && tar -x) +gunzip < "$2" | (cd -- "${refdir}" && tar -x) +(cd -- "${refdir}"/*/ && find -print0) > "$3/listing-1" +(cd -- "${tmpdir}"/*/ && find -print0) > "$3/listing-2" + +set +e +"${utildir}"/repodiff "${refdir}"/* "$3/listing-1" "${tmpdir}"/* "$3/listing-2" +ret=$? +set -e + +rm -rf -- "${refdir}" +rm -rf -- "${tmpdir}" + +if test $ret = 0; then + "${utildir}"/get-checksums "${tarball}" +fi + +rm -f -- "${tarball}" +exit $ret |
