Improve and fix build script

master
Skylar Ittner 5 years ago
parent a4c1fc504e
commit f749e14267

@ -0,0 +1,46 @@
#!/bin/bash
# $1 is the arch, $2 is the version, $3 is the binary tarball URL
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

@ -1,18 +0,0 @@
#!/bin/bash
# $1 is the arch, $2 is the version, $3 is the binary tarball URL
mkdir out
# Fill in real architecture and version info
sed -i '/ARCH/$1' debian/DEBIAN/control
sed -i '/VERSION/$2' debian/DEBIAN/control
# Clean and remake binary folder
rm -rf debian/usr/lib/nw.js
mkdir -p debian/usr/lib/nw.js
# Download binary
echo "Downloading and unpacking $3"
wget -q -O- $3 | tar -xvz --strip 1 -C debian/usr/lib/nw.js
echo "Packaging deb file nwjs-normal_$2-1_$1.deb"
dpkg-deb -b debian "out/nwjs-normal_$2-1_$1.deb"
Loading…
Cancel
Save