Skip to content

Instantly share code, notes, and snippets.

@rkleemann
Created July 9, 2013 17:49
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 rkleemann/5959534 to your computer and use it in GitHub Desktop.
Save rkleemann/5959534 to your computer and use it in GitHub Desktop.
#!/bin/bash
sudo apt-get install devscripts debhelper
SOURCE_DIR=$1
if [ -n "$SOURCE_DIR" ]; then
cd ~/sources/$SOURCE_DIR
fi
if ! grep 'Depends:' debian/control \
| cut -d ':' -f 2- \
| perl -nE ' say for map {s/\s+|[()>]//g; $_} split /,/ ' \
| grep -v '\$' \
| grep -v debhelper \
| xargs sudo apt-get -y install
then
return
fi
if ! prove -lr t/ ; then
return
fi
PACKAGE_NAME=$( \
grep 'Package:' debian/control \
| cut -d ':' -f 2 \
| tr -d ' ' \
)
VERSION=$( \
grep $PACKAGE_NAME debian/changelog \
| head -n 1 \
| perl -pE 's/[^(]+\(([0-9.-]+)-\d+\)[^)]+/$1/' \
)
tar -zcvf ../${PACKAGE_NAME}_${VERSION}.orig.tar.gz \
--exclude=.git \
--exclude='.*.swp' \
.
debuild
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment