NW.js/build.sh

48 lines
1.4 KiB
Bash
Raw Normal View History

2019-06-01 15:23:09 -06:00
#!/bin/bash
2019-06-01 15:27:21 -06:00
# This script is licensed under your favorite open source license.
# I really don't care what you do with it.
2019-06-01 15:23:09 -06:00
if [ $# -ne 3 ]; then
echo "Usage: build.sh [architecture] [package version] [binary tar.gz url]"
echo "Note: It is recommended to use \`fakeroot build.sh ...\` to ensure correct file permissions"
echo -e "Example usage:\n\tfakeroot ./build.sh amd64 0.38.4 https://dl.nwjs.io/v0.38.4/nwjs-v0.38.4-linux-x64.tar.gz"
exit 1
fi
ARCH=$1
VERSION=$2
URL=$3
FILENAME="nwjs-normal_$VERSION-1_$ARCH.deb"
mkdir -p out
# Fill in real architecture and version info
# Need to escape periods in the version string first
ESCAPEDVERSION=$(echo "$VERSION" | sed 's/\./\\\./g')
echo "Setting package version and architecture in control file"
sed -i "s/ARCH/$ARCH/" debian/DEBIAN/control
sed -i "s/VERSION/$ESCAPEDVERSION/" debian/DEBIAN/control
function clean_exit() {
echo "Resetting arch/version strings in control file"
sed -i "s/$ARCH/ARCH/" debian/DEBIAN/control
sed -i "s/$ESCAPEDVERSION/VERSION/" debian/DEBIAN/control
exit 0
}
# Clean and remake binary folder
rm -rf debian/usr/lib/nw.js
mkdir -p debian/usr/lib/nw.js
# Make sure the control file resets even when Ctrl-C pressed
trap "clean_exit" 2
# Download binary
echo "Downloading and unpacking $URL"
wget -q -O- $URL | tar -xvz --strip 1 -C debian/usr/lib/nw.js
echo "Packaging deb file $FILENAME"
dpkg-deb -b debian "out/$FILENAME"
clean_exit