| 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) [-k] {destdir}"
|
| 12 |
echo ""
|
| 13 |
echo "Unpacks the package source into {destdir}"
|
| 14 |
echo "where you can run 'dpkg-buildpackage' or 'debuild'."
|
| 15 |
echo " -k Keep .svn/ in {destdir}/debian/"
|
| 16 |
exit 1
|
| 17 |
}
|
| 18 |
|
| 19 |
if [ "$1" = "-k" ]; then
|
| 20 |
keep=1
|
| 21 |
shift
|
| 22 |
fi
|
| 23 |
|
| 24 |
# must run this from the directory the script is in
|
| 25 |
if [ "$(dirname "$0")" != '.' ] ||
|
| 26 |
[ -z "$1" ]; then
|
| 27 |
usage
|
| 28 |
fi
|
| 29 |
|
| 30 |
chglog=$(dpkg-parsechangelog)
|
| 31 |
|
| 32 |
pkg=$(echo "$chglog" | awk '/^Source: /{print $2}')
|
| 33 |
ver=$(echo "$chglog" | awk '/^Version: /{print $2}')
|
| 34 |
ver_upstream=${ver%-*}
|
| 35 |
tar_upstream_pattern=${pkg}_${ver_upstream}.orig.tar.*
|
| 36 |
|
| 37 |
for f in $tar_upstream_pattern; do
|
| 38 |
case $f in
|
| 39 |
*.gz) tar_upstream=$f; tar_z=z ;;
|
| 40 |
*.bz2) tar_upstream=$f; tar_z=j ;;
|
| 41 |
*) ;;
|
| 42 |
esac
|
| 43 |
done
|
| 44 |
|
| 45 |
destdir=$1/$pkg-$ver_upstream;
|
| 46 |
|
| 47 |
if [ -d "$destdir" ]; then
|
| 48 |
echo >&2 "$0: export directory $destdir already exists"
|
| 49 |
exit 1
|
| 50 |
fi
|
| 51 |
|
| 52 |
if [ ! -f "$tar_upstream" ]; then
|
| 53 |
echo >&2 "cannot find upstream tarball $tar_upstream_pattern"
|
| 54 |
exit 1
|
| 55 |
fi
|
| 56 |
|
| 57 |
mkdir -p "$destdir"
|
| 58 |
svn export --force $tar_upstream "$destdir/../$tar_upstream"
|
| 59 |
if [ -n "$keep" ]; then
|
| 60 |
cp -a debian "$destdir/debian"
|
| 61 |
else
|
| 62 |
svn export --force debian "$destdir/debian"
|
| 63 |
fi
|
| 64 |
cd "$destdir"
|
| 65 |
tar x${tar_z}f ../$tar_upstream --strip-components=1
|
| 66 |
echo "exported to $destdir"
|