mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
sha256-tarball-to: Support zipfiles.
This commit is contained in:
committed by
Tim Abbott
parent
bd54f0363e
commit
ba9569a6fe
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [ "$#" -lt 4 ]; then
|
if [ "$#" -lt 4 ]; then
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
@@ -23,15 +23,29 @@ tmpdir="$(mktemp -d)"
|
|||||||
trap 'rm -r "$tmpdir"' EXIT
|
trap 'rm -r "$tmpdir"' EXIT
|
||||||
cd "$tmpdir"
|
cd "$tmpdir"
|
||||||
|
|
||||||
|
# We support both .tar.gz and .zip files
|
||||||
|
if [[ "$URL" == *.tar.gz ]] || [[ "$URL" == *.tgz ]]; then
|
||||||
|
extension="tar.gz"
|
||||||
|
elif [[ "$URL" == *.zip ]]; then
|
||||||
|
extension="zip"
|
||||||
|
else
|
||||||
|
echo "Can't determine archive type from URL: $URL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Fetch to a predictable name, not whatever curl guesses from the URL
|
# Fetch to a predictable name, not whatever curl guesses from the URL
|
||||||
LOCALFILE="archive.tar.gz"
|
LOCALFILE="archive.$extension"
|
||||||
curl -fL --retry 3 -o "$LOCALFILE" "$URL"
|
curl -fL --retry 3 -o "$LOCALFILE" "$URL"
|
||||||
|
|
||||||
# Check the hash against what was passed in
|
# Check the hash against what was passed in
|
||||||
echo "$SHA256 $LOCALFILE" >"$LOCALFILE.sha256"
|
echo "$SHA256 $LOCALFILE" >"$LOCALFILE.sha256"
|
||||||
sha256sum -c "$LOCALFILE.sha256"
|
sha256sum -c "$LOCALFILE.sha256"
|
||||||
|
|
||||||
|
if [[ "$extension" == "tar.gz" ]]; then
|
||||||
tar xzf "$LOCALFILE"
|
tar xzf "$LOCALFILE"
|
||||||
|
else
|
||||||
|
unzip "$LOCALFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
# Take the rest of the arguments two-at-a-time, as source and
|
# Take the rest of the arguments two-at-a-time, as source and
|
||||||
# destination to move out of the unpacked tarball.
|
# destination to move out of the unpacked tarball.
|
||||||
|
|||||||
Reference in New Issue
Block a user