contrib/builddeb
author Matt Harbison <matt_harbison@yahoo.com>
Tue, 16 Jun 2015 16:15:15 -0400
changeset 25591 f1d46075b13a
parent 24972 56c64c91b429
child 26090 e5f2a2a095cb
permissions -rwxr-xr-x
verify: check the subrepository references in .hgsubstate While hopefully atypical, there are reasons that a subrepository revision can be lost that aren't covered by corruption of the .hgsubstate revlog. Such things can happen when a subrepo is amended, stripped or simply isn't pulled from upstream because the parent repo revision wasn't updated yet. There's no way to know if it is an error, but this will find potential problems sooner than when some random revision is updated. Until recently, convert made no attempt at rewriting the .hgsubstate file. The impetuous for this is to verify the conversion of some repositories, and this is orders of magnitude faster than a bash script from 0..tip that does an 'hg update -C $rev'. But it is equally useful to determine if everything has been pulled down before taking a thumb drive on the go. It feels somewhat wrong to leave this out of verifymod (mostly because the file is already read in there, and the final summary is printed before the subrepos are checked). But verifymod looks very low level, so importing subrepo stuff there seems more wrong.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24971
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
#!/bin/sh -e
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
#
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
# Build a Mercurial debian package from the current repo
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
#
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
# Tested on Jessie (stable as of original script authoring.)
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
24972
56c64c91b429 packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents: 24971
diff changeset
     7
. $(dirname $0)/packagelib.sh
56c64c91b429 packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents: 24971
diff changeset
     8
24971
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
BUILD=1
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
DEBBUILDDIR="$PWD/debbuild"
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
while [ "$1" ]; do
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    12
    case "$1" in
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    13
    --prepare )
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
        shift
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    15
        BUILD=
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
        ;;
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
    --debbuilddir )
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
        shift
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
        DEBBUILDDIR="$1"
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
        shift
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
        ;;
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
    * )
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
        echo "Invalid parameter $1!" 1>&2
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
        exit 1
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
        ;;
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
    esac
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
done
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    28
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
set -u
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    30
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
rm -rf $DEBBUILDDIR
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
mkdir -p $DEBBUILDDIR
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
if [ ! -d .hg ]; then
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
    echo 'You are not inside a Mercurial repository!' 1>&2
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
    exit 1
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
fi
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
24972
56c64c91b429 packaging: extract packagelib for common code from builddeb and buildrpm
Augie Fackler <augie@google.com>
parents: 24971
diff changeset
    39
gethgversion
24971
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    40
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
cp -r $PWD/contrib/debian $DEBBUILDDIR/DEBIAN
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
chmod -R 0755 $DEBBUILDDIR/DEBIAN
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
control=$DEBBUILDDIR/DEBIAN/control
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
# This looks like sed -i, but sed -i behaves just differently enough
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
# between BSD and GNU sed that I gave up and did the dumb thing.
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
sed "s/__VERSION__/$version/" < $control > $control.tmp
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
mv $control.tmp $control
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    50
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    51
if [ "$BUILD" ]; then
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    52
    dpkg-deb --build $DEBBUILDDIR
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    53
    mv $DEBBUILDDIR.deb $DEBBUILDDIR/mercurial-$version-$release.deb
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
    if [ $? = 0 ]; then
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    55
        echo
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
        echo "Built packages for $version-$release:"
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
        find $DEBBUILDDIR/ -type f -newer $control
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    58
    fi
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    59
else
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
    echo "Prepared sources for $version-$release $control are in $DEBBUILDDIR - use like:"
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    61
    echo "dpkg-deb --build $DEBBUILDDIR"
ab75baaf81d5 builddeb: new script for building a deb package
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
fi