| 1 |
#!/bin/sh -e
|
| 2 |
#
|
| 3 |
# svn-export-this: 'svn export' this tree and unpack the tarball so the
|
| 4 |
# package can be built.
|
| 5 |
#
|
| 6 |
# Requires a destination dir on the command line. Creates and
|
| 7 |
# populates this dir, where the actual dpkg-buildpackage can be run.
|
| 8 |
|
| 9 |
usage () {
|
| 10 |
exec >&2
|
| 11 |
echo "usage: ./$(basename $0) {destdir}"
|
| 12 |
echo ""
|
| 13 |
echo "Unpacks the package source into {destdir}"
|
| 14 |
echo "where you can run 'dpkg-buildpackage' or 'debuild'."
|
| 15 |
exit 1
|
| 16 |
}
|
| 17 |
|
| 18 |
# must run this from the directory the script is in
|
| 19 |
if [ "$(dirname "$0")" != '.' ] ||
|
| 20 |
[ -z "$1" ]; then
|
| 21 |
usage
|
| 22 |
fi
|
| 23 |
|
| 24 |
chglog=$(dpkg-parsechangelog)
|
| 25 |
|
| 26 |
pkg=$(echo "$chglog" | awk '/^Source: /{print $2}')
|
| 27 |
ver=$(echo "$chglog" | awk '/^Version: /{print $2}')
|
| 28 |
ver_upstream=${ver%-*}
|
| 29 |
tar_upstream_pattern=${pkg}_${ver_upstream}.orig.tar.*
|
| 30 |
tar_upstream=$(ls $tar_upstream_pattern)
|
| 31 |
|
| 32 |
destdir=$1/$pkg-$ver_upstream;
|
| 33 |
|
| 34 |
if [ -d "$destdir" ]; then
|
| 35 |
echo >&2 "$0: export directory $destdir already exists"
|
| 36 |
exit 1
|
| 37 |
fi
|
| 38 |
|
| 39 |
if [ ! -f "$tar_upstream" ]; then
|
| 40 |
echo >&2 "cannot find upstream tarball $tar_upstream_pattern"
|
| 41 |
exit 1
|
| 42 |
fi
|
| 43 |
|
| 44 |
mkdir -p "$destdir"
|
| 45 |
svn export --force $tar_upstream "$destdir/../$tar_upstream"
|
| 46 |
svn export --force debian "$destdir/debian"
|
| 47 |
cd "$destdir"
|
| 48 |
case $tar_upstream in
|
| 49 |
*.gz) z=z ;;
|
| 50 |
*.bz2) z=j ;;
|
| 51 |
*) echo >&2 "unrecognised tar format, $tar_upstream"; exit 1 ;;
|
| 52 |
esac
|
| 53 |
tar x${z}f ../$tar_upstream --strip-components=1
|
| 54 |
echo "exported to $destdir"
|