2020-11-08 15:07:17 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# The script builds a source package
|
|
|
|
|
|
|
|
# Usage
|
|
|
|
display_usage() {
|
2021-08-22 16:21:09 -04:00
|
|
|
echo "Usage: $0 [tag]"
|
2020-11-08 15:07:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -lt 1 ]
|
|
|
|
then
|
|
|
|
display_usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Input validation
|
|
|
|
TAG=$1
|
|
|
|
|
|
|
|
if [ "${TAG:0:1}" != "v" ]
|
|
|
|
then
|
|
|
|
echo "Tag must start with 'v' character"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION=${TAG:1}
|
|
|
|
|
|
|
|
# Make sure tag exists
|
|
|
|
git tag | grep "^$TAG\$"
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Tag does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clone source
|
|
|
|
mkdir -p build/source
|
|
|
|
mkdir -p dist
|
|
|
|
cd build/source
|
2022-03-02 09:40:49 -05:00
|
|
|
git clone --single-branch --branch $TAG --depth 1 https://github.com/onionshare/onionshare.git
|
2020-11-08 15:07:17 -05:00
|
|
|
cd onionshare
|
|
|
|
|
|
|
|
# Verify tag
|
|
|
|
git tag -v $TAG 2> ../verify.txt
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Tag does not verify"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-02-22 10:00:25 -05:00
|
|
|
cat ../verify.txt | grep -e "using RSA key 927F419D7EC82C2F149C1BD1403C2657CD994F73" -e "using RSA key 2E530667425F4B93874935707B7F1772C0C6FCBF"
|
2020-11-08 15:07:17 -05:00
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Tag signed with wrong key"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-08-22 16:21:09 -04:00
|
|
|
cat ../verify.txt | grep "^gpg: Good signature from"
|
2020-11-08 15:07:17 -05:00
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo "Tag verification missing 'Good signature from'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Checkout code
|
|
|
|
git checkout $TAG
|
|
|
|
|
|
|
|
# Delete .git, compress, and PGP sign
|
|
|
|
cd ..
|
|
|
|
rm -rf onionshare/.git
|
2022-03-02 08:12:17 -05:00
|
|
|
tar -czf onionshare-$VERSION.tar.gz onionshare/
|
2020-11-08 15:07:17 -05:00
|
|
|
|
|
|
|
# Move source package to dist
|
|
|
|
cd ../..
|
|
|
|
mv build/source/onionshare-$VERSION.tar.gz dist
|
|
|
|
|
|
|
|
# Clean up
|
|
|
|
rm -rf build/source/onionshare
|
|
|
|
rm build/source/verify.txt
|
|
|
|
|
|
|
|
echo "Source package complete, file in dist"
|