Skip to content

Instantly share code, notes, and snippets.

@pelgrim
Created August 24, 2011 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pelgrim/1168564 to your computer and use it in GitHub Desktop.
Save pelgrim/1168564 to your computer and use it in GitHub Desktop.
Just a script for generating deb packages Like a Boss :-)
#!/bin/bash
# Script for generating deb packages Like a Boss
# Developed by Lucas Vieira <lucas at heap dot com dot br>
# Exit with error when things go bad
if [ $# -ne 1 ] || [ ! -e "$1/DEBIAN/control" ]; then
echo "Bad argumentation. Try ./create_pkg [package_dir]"
exit 1
fi
if [ ! $(which dpkg) ] && [ ! -x $DPKG ]; then
"Couldn't find dpkg. Please, export DPKG=[dpkg_path] && ./create_pkg [package_dir]"
exit 2
fi
# Variables
[ $DPKG ] || DPKG=`which dpkg`
PACK=`grep Package: $1/DEBIAN/control | cut -d' ' -f2`
VERSION=`grep Version: $1/DEBIAN/control | cut -d' ' -f2`
ARCH=`grep Architecture: $1/DEBIAN/control | cut -d' ' -f2`
# The real thing
PACK_NAME=$PACK-$VERSION
[ $ARCH ] && PACK_NAME=$PACK_NAME"_"$ARCH
$DPKG --build $1 $PACK_NAME.deb
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment