render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

Blame update-tarball.sh

Paolo Bonzini ede8d7
#!/bin/bash
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
Paolo Bonzini ede8d7
if test $# -ge 1; then
Paolo Bonzini ede8d7
  hash=$1
Paolo Bonzini ede8d7
  short=$1
Paolo Bonzini ede8d7
else
Paolo Bonzini ede8d7
  hash=$(curl -s "${api}/git/refs/heads/${branch}" | grep '"sha"' | cut -d'"' -f4)
Paolo Bonzini ede8d7
  if test "$hash" = ""; then
Gerd Hoffmann b0c3af
	echo "# failed to fetch $branch hash"
Gerd Hoffmann b0c3af
	exit 1
Paolo Bonzini ede8d7
  fi
Paolo Bonzini ede8d7
  short=$(echo $hash | sed -e 's/^\(.......\).*/\1/')
Gerd Hoffmann b0c3af
fi
Gerd Hoffmann b0c3af
Paolo Bonzini ede8d7
if test $# = 2; then
Paolo Bonzini ede8d7
  date=$2
Paolo Bonzini ede8d7
else
Paolo Bonzini ede8d7
  date=$(curl -s "${api}/git/commits/$hash" | awk '
Paolo Bonzini ede8d7
	  /"committer"/	{ c=1 }
Paolo Bonzini ede8d7
	  /"date"/	{ if (c) { print } }
Paolo Bonzini ede8d7
  ' | cut -d'"' -f4)
Paolo Bonzini ede8d7
  date="${date%T*}"
Paolo Bonzini ede8d7
  date="${date//-/}"
Paolo Bonzini ede8d7
fi
Gerd Hoffmann b0c3af
Paolo Bonzini ede8d7
name="${repo}-${date}-${short}.tar.xz"
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 ..."
Paolo Bonzini ede8d7
curl "$tar/$hash" | zcat | xz -9e > "$name"
Gerd Hoffmann b0c3af
exit 0