#!/bin/sh
#
# Creates the minimal debhelper-7-using package.
#
# Usage: newpackage <packagename>
# This will create the package in the directory <packagename>-1.0, at which
# point you can modify it and run debuild.
#
# Geoffrey Thomas <geofft@mit.edu>, July 2011, released to the public domain.

set -e

package=$1
if [ -z "$1" ]; then
	echo "usage: newpackage <name>"
	exit 1
fi
if [ -e "$1-1.0" ]; then
	echo "error: $1-1.0 exists"
	exit 1
fi

if [ -e ~/.devscripts ]; then
	. ~/.devscripts
fi

mkdir "$1-1.0"
cd "$1-1.0"
mkdir debian
dch --create --package "$1" -v 1.0 -D unstable --distributor local "Initial release."
echo 7 > debian/compat
dpkg-parsechangelog | egrep '^(Source|Maintainer): ' > debian/control
cat >> debian/control << EOF
Section: misc
Priority: extra
Build-Depends: debhelper (>= 7.0.50~)
Standards-Version: 3.9.2

Package: $1
Architecture: all
Depends: \${misc:Depends}
Description: New package
 $1 has no description yet.
EOF
cat > debian/copyright << EOF
Format: http://dep.debian.net/deps/dep5/

Files: *
Copyright: © 2011 Geoffrey Thomas <geofft@mit.edu>
License: Public domain
EOF
cat > debian/rules << 'EOF'
#!/usr/bin/make -f

%:
	dh $@
EOF
chmod +x debian/rules