NW.js/build.sh

57 lines
1.6 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
2019-06-01 16:15:14 -06:00
if [ $# -ne 4 ]; then
echo "Usage: build.sh [architecture] [package version] [normal|sdk] [binary tar.gz url]"
2019-06-01 15:23:09 -06:00
echo "Note: It is recommended to use \`fakeroot build.sh ...\` to ensure correct file permissions"
2019-06-01 16:15:14 -06:00
echo -e "Example usage:\n\tfakeroot ./build.sh amd64 0.38.4 normal https://dl.nwjs.io/v0.38.4/nwjs-v0.38.4-linux-x64.tar.gz"
2019-06-01 15:23:09 -06:00
exit 1
fi
ARCH=$1
VERSION=$2
2019-06-01 16:15:14 -06:00
TYPE=$3
URL=$4
2019-06-01 16:29:22 -06:00
FILENAME="nwjs-${TYPE}_$VERSION-1_$ARCH.deb"
2019-06-01 15:23:09 -06:00
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')
2019-06-01 16:15:14 -06:00
echo "Setting package version, architecture, and type in control file"
2019-06-01 15:23:09 -06:00
sed -i "s/ARCH/$ARCH/" debian/DEBIAN/control
sed -i "s/VERSION/$ESCAPEDVERSION/" debian/DEBIAN/control
2019-06-01 16:15:14 -06:00
if [ $TYPE == "sdk" ]; then
sed -i "s/normal/sdk/" debian/DEBIAN/control
fi
2019-06-01 15:23:09 -06:00
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
2019-06-01 16:15:14 -06:00
if [ $TYPE == "sdk" ]; then
sed -i "s/normal/sdk/" debian/DEBIAN/control
fi
2019-06-01 15:23:09 -06:00
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
2019-06-01 16:15:14 -06:00
echo "Packaging deb file"
2019-06-01 15:23:09 -06:00
dpkg-deb -b debian "out/$FILENAME"
clean_exit