render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

Blame update-tarball.sh

Gerd Hoffmann b0c3af
#!/bin/sh
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
user="tianocore"
Gerd Hoffmann b0c3af
repo="edk2"
Gerd Hoffmann b0c3af
branch="master"
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
uri="https://github.com/${user}/${repo}"
Gerd Hoffmann b0c3af
api="${uri/github.com/api.github.com/repos}"
Gerd Hoffmann b0c3af
tar="${uri/github.com/codeload.github.com}/legacy.tar.gz"
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
hash=$(curl -s "${api}/git/refs/heads/${branch}" | grep '"sha"' | cut -d'"' -f4)
Gerd Hoffmann b0c3af
if test "$hash" = ""; then
Gerd Hoffmann b0c3af
	echo "# failed to fetch $branch hash"
Gerd Hoffmann b0c3af
	exit 1
Gerd Hoffmann b0c3af
fi
Gerd Hoffmann b0c3af
short=$(echo $hash | sed -e 's/^\(.......\).*/\1/')
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
date=$(curl -s "${api}/git/commits/$hash" | awk '
Gerd Hoffmann b0c3af
	/"committer"/	{ c=1 }
Gerd Hoffmann b0c3af
	/"date"/	{ if (c) { print } }
Gerd Hoffmann b0c3af
' | cut -d'"' -f4)
Gerd Hoffmann b0c3af
date="${date%T*}"
Gerd Hoffmann b0c3af
date="${date//-/}"
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
name="${repo}-${date}-${short}.tar.gz"
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
if test -f "$name"; then
Gerd Hoffmann b0c3af
	echo "# exists: $name"
Gerd Hoffmann b0c3af
	exit 1
Gerd Hoffmann b0c3af
fi
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
echo
Gerd Hoffmann b0c3af
echo "# specfile update: version $date, release $short"
Gerd Hoffmann b0c3af
sed -i.old \
Gerd Hoffmann b0c3af
        -e "s/\(%global edk2_date[ \t]\+\)\(.*\)/\1$date/" \
Gerd Hoffmann b0c3af
        -e "s/\(%global edk2_githash[ \t]\+\)\(.*\)/\1$short/" \
Gerd Hoffmann b0c3af
        edk2.spec
Gerd Hoffmann b0c3af
diff -u edk2.spec.old edk2.spec
Gerd Hoffmann b0c3af
Gerd Hoffmann b0c3af
echo
Gerd Hoffmann b0c3af
echo "# cleanup ..."
Gerd Hoffmann b0c3af
rm -vf ${repo}-*.tar*
Gerd Hoffmann b0c3af
echo "# fetching $name ..."
Gerd Hoffmann b0c3af
curl "$tar/$hash" > "$name"
Gerd Hoffmann b0c3af
exit 0