You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.0 KiB
Bash
71 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# This script is licensed under your favorite open source license.
|
|
# I really don't care what you do with it.
|
|
|
|
if [ $# -ne 5 ]; then
|
|
echo "Usage: build.sh [architecture] [package version] [normal|sdk] [binary tar.gz url] [same-version revision number]"
|
|
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 normal https://dl.nwjs.io/v0.38.4/nwjs-v0.38.4-linux-x64.tar.gz 1"
|
|
exit 1
|
|
fi
|
|
|
|
ARCH=$1
|
|
VERSION=$2
|
|
TYPE=$3
|
|
URL=$4
|
|
REVISION=$5
|
|
|
|
FILENAME="nwjs-${TYPE}_$VERSION-${REVISION}_$ARCH.deb"
|
|
|
|
mkdir -p out
|
|
|
|
# Fill in real architecture and version info
|
|
# Need to escape periods in the version string first
|
|
ESCAPEDVERSION=$(echo "$VERSION-$REVISION" | sed 's/\./\\\./g')
|
|
echo "Setting package version, architecture, and type in control file"
|
|
sed -i "s/ARCH/$ARCH/" debian/DEBIAN/control
|
|
sed -i "s/VERSION/$ESCAPEDVERSION/" debian/DEBIAN/control
|
|
|
|
if [ $TYPE == "sdk" ]; then
|
|
sed -i "s/normal/sdk/" debian/DEBIAN/control
|
|
fi
|
|
if [ $TYPE == "normal" ]; then
|
|
sed -i "s/sdk/normal/" debian/DEBIAN/control
|
|
fi
|
|
|
|
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
|
|
if [ $TYPE == "sdk" ]; then
|
|
sed -i "s/sdk/normal/" debian/DEBIAN/control
|
|
fi
|
|
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
|
|
if [[ $URL == http*://* ]] ; then
|
|
echo "Downloading and unpacking $URL"
|
|
wget -q -O- $URL | tar -xvz --strip 1 -C debian/usr/lib/nw.js
|
|
else
|
|
echo "Unpacking local file $URL"
|
|
tar -xvz --strip 1 -C debian/usr/lib/nw.js -f $URL
|
|
fi
|
|
|
|
chmod -R a+rx debian/usr/lib/nw.js
|
|
chmod a+rx debian/usr/bin/nwjs
|
|
chown -R root:root debian/usr/lib/nw.js
|
|
chown -R root:root debian/usr/bin/nwjs
|
|
|
|
echo "Packaging deb file"
|
|
dpkg-deb -b debian "out/$FILENAME"
|
|
|
|
clean_exit
|