Skip to content

Instantly share code, notes, and snippets.

@sdumetz
Last active September 24, 2015 11:01
Show Gist options
  • Save sdumetz/7ce71a939a8018004fe6 to your computer and use it in GitHub Desktop.
Save sdumetz/7ce71a939a8018004fe6 to your computer and use it in GitHub Desktop.
barebones script to build deb packages
#!/bin/sh
# basic deb package building
set -e
DIR="$( cd "$( dirname "$0" )" && pwd )"
NODE_ENV=production
VERSION=$(head -1 $DIR/debian/changelog|sed -r 's/.*\(([^\)]*)\).*/\1/')
NAME=$(head -1 $DIR/debian/changelog|cut -d " " -f 1)
TMP=$(mktemp -d)
DEST=$TMP/$NAME-$VERSION
PREFIX=usr
ETC=/etc/$NAME
LIB=${DEST}/${PREFIX}/lib
BIN=${DEST}/${PREFIX}/bin
SHARE=${DEST}/${PREFIX}/share
mkdir -p $LIB $BIN
### HERE CP files and directories ###
### END of CP ###
### Edit symbolic link
ln -s /$PREFIX/lib/node_modules/$NAME/bin/$NAME $BIN/$NAME
#replace placeholders in control
sed -i -e "s/{{NAME}}/$NAME/" -e "s/{{VERSION}}/$VERSION/" $DEST/DEBIAN/control
echo "building package : ${NAME}_${VERSION}.deb"
dpkg-deb --build $DEST $DIR/${NAME}_${VERSION}.deb
rm -rf $TMP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment