1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/bin/bash
set -e
if [ "$1" = "--help" ]
then
cat <<__END__
init - Create an initial packaging
__END__
$0 --manpage
exit 0
fi
if [ "$1" = "--manpage" ]
then
cat <<'__END__'
Usage: dht init [-D distribution] Cabal-Pkg ...
This script will:
* Query the package plan for the desired version number of CabalPkg.
* Use `cabal unpack --pristine` to fetch the source into the right directory
* Run cabal-debian --official to initialize the packaging.
* Optimistically mark the package as ready for release
* Commit this to git.
Please review the package afterwards, in particular `debian/copyright`.
__END__
exit 0;
fi
if [ "$1" = "-D" ]
then
dist="$2"
shift
shift
else
dist=unstable
fi
if ! git diff-files --quiet -- "$@"
then
echo "The git repository is not clean. Please fix that first!"
exit 1
fi
if ! git diff-index --cached --quiet HEAD -- "$@"
then
echo "WARNING: The git index is not clean, and will be amended!"
fi
if test -n "$(git ls-files --exclude-standard --others -- "$@")"
then
echo "The git repository has untracked files. Please fix that first!"
exit 1
fi
for cabal_name in "$@"
do
cd "$(git rev-parse --show-toplevel)"
version=$(grep "^$cabal_name " ../package-plan/packages.txt|cut -d\ -f2)
if [ -z "$version" ]
then
echo "ERROR: could not detect version of $cabal_name to package"
echo "Please update the package-plan first."
continue
fi
source_name="haskell-$(echo "$cabal_name" | tr '[:upper:]' '[:lower:]')"
if [ -d "p/$source_name" ]
then
echo "ERROR: p/$source_name already exists."
continue
fi
cabal unpack --pristine "$cabal_name-$version"
mv -v "$cabal_name-$version" "p/$source_name"
cd "p/$source_name"
dht cabal-debian
git add .
git commit -m "Initial packaging of $cabal_name-$version"
dch -D $dist -r ''
echo "Packaged $cabal_name-$version"
git diff HEAD^..HEAD
done
|