2018-04-25 16:43:16 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# vim: set ts=3 sw=3 noet ft=sh : bash
|
|
|
|
# RetroArch packaging script
|
|
|
|
|
|
|
|
PRGNAM=RetroArch
|
|
|
|
SRCNAM="$(printf %s $PRGNAM | tr '[:upper:]' '[:lower:]')"
|
|
|
|
TMP=${TMP:-/tmp/libretro}
|
2018-10-12 22:23:16 +00:00
|
|
|
FORCE=0
|
|
|
|
CLEAN=0
|
|
|
|
|
|
|
|
for x in $@; do
|
|
|
|
if [ "$x" == "--force" ]; then
|
|
|
|
FORCE=1
|
|
|
|
fi
|
|
|
|
if [ "$x" == "--clean" ]; then
|
|
|
|
CLEAN=1
|
|
|
|
fi
|
|
|
|
done
|
2018-04-25 16:43:16 +00:00
|
|
|
|
2018-05-04 04:46:49 +00:00
|
|
|
# Exit on errors and unset variables
|
2018-04-25 16:43:16 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
# Ensure a clean and fully updated repo
|
2018-10-12 22:23:16 +00:00
|
|
|
if [ -d $SRCNAM ]; then
|
|
|
|
if [ $CLEAN -gt 0 ]; then
|
|
|
|
rm -rf -- $SRCNAM
|
|
|
|
elif [ $FORCE -gt 0 ]; then
|
|
|
|
echo "Using existing state of $SRCNAM. If build fails, use --clean to delete and re-clone."
|
|
|
|
else
|
|
|
|
echo "FATAL: $SRCNAM/ exists."
|
|
|
|
echo ""
|
|
|
|
echo " - To build with existing sources: $0 --force"
|
|
|
|
echo " - To delete existing sources and re-clone: $0 --clean"
|
|
|
|
echo ""
|
|
|
|
echo "WARNING: The --clean option does not preserve forks. That is,"
|
|
|
|
echo "the original libretro/$PRGNAM repository will be cloned, not"
|
|
|
|
echo "your personal fork. To build a release build from a fork,"
|
|
|
|
echo "use --force."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2018-08-31 05:19:51 +00:00
|
|
|
./libretro-fetch.sh $SRCNAM
|
2018-04-25 16:43:16 +00:00
|
|
|
|
|
|
|
COMMIT="$(git --work-tree=$SRCNAM --git-dir=$SRCNAM/.git describe --abbrev=0 \
|
|
|
|
--tags)"
|
|
|
|
VERSION="$(printf %s $COMMIT | tr -d v)"
|
|
|
|
|
|
|
|
trap 'rm -rf -- $TMP/$PRGNAM-$VERSION; exit 0' EXIT INT
|
|
|
|
|
|
|
|
# Don't alter the original cloned repo
|
|
|
|
mkdir -p -- "$TMP"
|
|
|
|
rm -rf -- "$TMP/$PRGNAM-$VERSION"
|
|
|
|
cp -a $SRCNAM "$TMP/$PRGNAM-$VERSION"
|
|
|
|
|
|
|
|
# Checkout the last release tag
|
|
|
|
git --work-tree="$TMP/$PRGNAM-$VERSION" --git-dir="$TMP/$PRGNAM-$VERSION/.git" \
|
|
|
|
checkout "$COMMIT"
|
|
|
|
|
|
|
|
# Remove .git directories and files
|
|
|
|
find "$TMP/$PRGNAM-$VERSION" -name ".git*" | xargs rm -rf
|
|
|
|
|
|
|
|
cd -- "$TMP"
|
|
|
|
|
|
|
|
# Create .zip and .tar.xz release tarballs.
|
|
|
|
zip -r "$PRGNAM-$VERSION.zip" "$PRGNAM-$VERSION"
|
|
|
|
tar cf - "$PRGNAM-$VERSION" | xz -c9 - > "$PRGNAM-$VERSION.tar.xz"
|
2018-05-04 04:46:49 +00:00
|
|
|
|
|
|
|
# Test the tarballs
|
|
|
|
rm -rf -- "$PRGNAM-$VERSION"
|
|
|
|
tar xvf "$PRGNAM-$VERSION.tar.xz"
|
|
|
|
rm -rf -- "$PRGNAM-$VERSION"
|
|
|
|
unzip -- "$PRGNAM-$VERSION.zip"
|
|
|
|
|
2018-10-07 15:11:37 +00:00
|
|
|
# Create SHA256SUMS and SHA512SUMS, use 'gpg --clearsign' to sign these.
|
|
|
|
sha256sum "$PRGNAM-$VERSION.tar.xz" "$PRGNAM-$VERSION.zip" > SHA256SUMS
|
|
|
|
sha512sum "$PRGNAM-$VERSION.tar.xz" "$PRGNAM-$VERSION.zip" > SHA512SUMS
|
|
|
|
|
2018-05-04 04:46:49 +00:00
|
|
|
exit 0
|