builddeb
84 lines
| 1.8 KiB
| text/plain
|
TextLexer
/ contrib / builddeb
|
r24971 | #!/bin/sh -e | ||
# | ||||
# Build a Mercurial debian package from the current repo | ||||
# | ||||
# Tested on Jessie (stable as of original script authoring.) | ||||
|
r24972 | . $(dirname $0)/packagelib.sh | ||
|
r24971 | BUILD=1 | ||
|
r26148 | CLEANUP=1 | ||
|
r26108 | DEBVERSION=jessie | ||
|
r24971 | while [ "$1" ]; do | ||
case "$1" in | ||||
|
r26108 | --release ) | ||
shift | ||||
DEBVERSION="$1" | ||||
shift | ||||
;; | ||||
|
r26148 | --cleanup ) | ||
|
r24971 | shift | ||
BUILD= | ||||
;; | ||||
|
r26148 | --build ) | ||
shift | ||||
CLEANUP= | ||||
;; | ||||
|
r24971 | --debbuilddir ) | ||
shift | ||||
DEBBUILDDIR="$1" | ||||
shift | ||||
;; | ||||
* ) | ||||
echo "Invalid parameter $1!" 1>&2 | ||||
exit 1 | ||||
;; | ||||
esac | ||||
done | ||||
|
r26148 | trap "if [ '$CLEANUP' ] ; then rm -r '$PWD/debian' ; fi" EXIT | ||
|
r26108 | |||
|
r24971 | set -u | ||
if [ ! -d .hg ]; then | ||||
echo 'You are not inside a Mercurial repository!' 1>&2 | ||||
exit 1 | ||||
fi | ||||
|
r24972 | gethgversion | ||
|
r24971 | |||
|
r26148 | control=debian/control | ||
changelog=debian/changelog | ||||
|
r24971 | |||
if [ "$BUILD" ]; then | ||||
|
r26148 | if [ -d debian ] ; then | ||
echo "Error! debian control directory already exists!" | ||||
exit 1 | ||||
|
r24971 | fi | ||
|
r26148 | |||
cp -r $PWD/contrib/debian debian | ||||
chmod -R 0755 debian | ||||
# This looks like sed -i, but sed -i behaves just differently enough | ||||
# between BSD and GNU sed that I gave up and did the dumb thing. | ||||
sed "s/__VERSION__/$version/" < $changelog > $changelog.tmp | ||||
date=$(date --rfc-2822) | ||||
sed "s/__DATE__/$date/" < $changelog.tmp > $changelog | ||||
rm $changelog.tmp | ||||
debuild -us -uc -b | ||||
if [ $? != 0 ]; then | ||||
echo 'debuild failed!' | ||||
exit 1 | ||||
fi | ||||
|
r24971 | fi | ||
|
r26148 | if [ "$CLEANUP" ] ; then | ||
echo | ||||
OUTPUTDIR=${OUTPUTDIR:=packages/debian-$DEBVERSION} | ||||
find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ | ||||
-type f -newer $control -print0 | \ | ||||
xargs -Inarf -0 mv narf "$OUTPUTDIR" | ||||
echo "Built packages for $version-$release:" | ||||
find "$OUTPUTDIR" -type f -newer $control -name '*.deb' | ||||
fi | ||||