builddeb
101 lines
| 2.2 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 | ||
r27212 | DISTID=`(lsb_release -is 2> /dev/null | tr '[:upper:]' '[:lower:]') || echo debian` | |||
CODENAME=`lsb_release -cs 2> /dev/null || echo unknown` | ||||
|
r28994 | DEBFLAGS=-b | ||
|
r24971 | while [ "$1" ]; do | ||
case "$1" in | ||||
r27210 | --distid ) | |||
shift | ||||
DISTID="$1" | ||||
shift | ||||
;; | ||||
r27209 | --codename ) | |||
|
r26108 | shift | ||
r27209 | CODENAME="$1" | |||
|
r26108 | shift | ||
;; | ||||
|
r26148 | --cleanup ) | ||
|
r24971 | shift | ||
BUILD= | ||||
;; | ||||
|
r26148 | --build ) | ||
shift | ||||
CLEANUP= | ||||
;; | ||||
|
r28994 | --source-only ) | ||
shift | ||||
DEBFLAGS=-S | ||||
;; | ||||
|
r24971 | * ) | ||
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 | ||
|
r26833 | debver="$version" | ||
if [ -n "$type" ] ; then | ||||
debver="$debver~$type" | ||||
fi | ||||
if [ -n "$distance" ] ; then | ||||
debver="$debver+$distance-$node" | ||||
fi | ||||
|
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 | ||||
|
r28988 | sed -i.tmp "s/__VERSION__/$debver/" $changelog | ||
sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog | ||||
|
r28989 | sed -i.tmp "s/__CODENAME__/$CODENAME/" $changelog | ||
|
r26148 | rm $changelog.tmp | ||
|
r28993 | # remove the node from the version string | ||
SRCFILE="mercurial_$(echo $debver | sed "s,-$node,,").orig.tar.gz" | ||||
"$PWD/hg" archive $SRCFILE | ||||
mv $SRCFILE .. | ||||
|
r28994 | debuild -us -uc -i -I $DEBFLAGS | ||
|
r26148 | if [ $? != 0 ]; then | ||
echo 'debuild failed!' | ||||
exit 1 | ||||
fi | ||||
|
r24971 | fi | ||
|
r26148 | if [ "$CLEANUP" ] ; then | ||
echo | ||||
r27210 | OUTPUTDIR=${OUTPUTDIR:=packages/$DISTID-$CODENAME} | |||
r27212 | mkdir -p "$OUTPUTDIR" | |||
|
r26148 | find ../mercurial*.deb ../mercurial_*.build ../mercurial_*.changes \ | ||
|
r28991 | ../mercurial*.dsc ../mercurial*.gz \ | ||
|
r28990 | -type f -newer $control -print0 2>/dev/null | \ | ||
|
r26148 | xargs -Inarf -0 mv narf "$OUTPUTDIR" | ||
|
r26833 | echo "Built packages for $debver:" | ||
|
r26148 | find "$OUTPUTDIR" -type f -newer $control -name '*.deb' | ||
fi | ||||