update-tarball.sh: allow passing hardcoded date and hash
This commit is contained in:
parent
498742e649
commit
ede8d7f7db
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
user="tianocore"
|
user="tianocore"
|
||||||
repo="edk2"
|
repo="edk2"
|
||||||
@ -8,21 +8,30 @@ uri="https://github.com/${user}/${repo}"
|
|||||||
api="${uri/github.com/api.github.com/repos}"
|
api="${uri/github.com/api.github.com/repos}"
|
||||||
tar="${uri/github.com/codeload.github.com}/legacy.tar.gz"
|
tar="${uri/github.com/codeload.github.com}/legacy.tar.gz"
|
||||||
|
|
||||||
hash=$(curl -s "${api}/git/refs/heads/${branch}" | grep '"sha"' | cut -d'"' -f4)
|
if test $# -ge 1; then
|
||||||
if test "$hash" = ""; then
|
hash=$1
|
||||||
|
short=$1
|
||||||
|
else
|
||||||
|
hash=$(curl -s "${api}/git/refs/heads/${branch}" | grep '"sha"' | cut -d'"' -f4)
|
||||||
|
if test "$hash" = ""; then
|
||||||
echo "# failed to fetch $branch hash"
|
echo "# failed to fetch $branch hash"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
short=$(echo $hash | sed -e 's/^\(.......\).*/\1/')
|
||||||
fi
|
fi
|
||||||
short=$(echo $hash | sed -e 's/^\(.......\).*/\1/')
|
|
||||||
|
|
||||||
date=$(curl -s "${api}/git/commits/$hash" | awk '
|
if test $# = 2; then
|
||||||
/"committer"/ { c=1 }
|
date=$2
|
||||||
/"date"/ { if (c) { print } }
|
else
|
||||||
' | cut -d'"' -f4)
|
date=$(curl -s "${api}/git/commits/$hash" | awk '
|
||||||
date="${date%T*}"
|
/"committer"/ { c=1 }
|
||||||
date="${date//-/}"
|
/"date"/ { if (c) { print } }
|
||||||
|
' | cut -d'"' -f4)
|
||||||
|
date="${date%T*}"
|
||||||
|
date="${date//-/}"
|
||||||
|
fi
|
||||||
|
|
||||||
name="${repo}-${date}-${short}.tar.gz"
|
name="${repo}-${date}-${short}.tar.xz"
|
||||||
|
|
||||||
if test -f "$name"; then
|
if test -f "$name"; then
|
||||||
echo "# exists: $name"
|
echo "# exists: $name"
|
||||||
@ -41,5 +50,5 @@ echo
|
|||||||
echo "# cleanup ..."
|
echo "# cleanup ..."
|
||||||
rm -vf ${repo}-*.tar*
|
rm -vf ${repo}-*.tar*
|
||||||
echo "# fetching $name ..."
|
echo "# fetching $name ..."
|
||||||
curl "$tar/$hash" > "$name"
|
curl "$tar/$hash" | zcat | xz -9e > "$name"
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user