#!/bin/sh

. ./vars.sh.frag

git diff -q -- "$PKGDIR_REL" || \
abort 1 "Please git-add your changes to $PKGDIR_REL before running"

( cd "$PKGDIR"
sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
dch -r -D unstable ""
git add debian/changelog
)

rm -rf "$BUILDDIR"
$DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" --changelog-ready "$PKG"

git diff -q -- "$PKGDIR_REL" || \
abort 1 "cannot release, update resulted in git diffs to $PKGDIR_REL"

git commit -m "Update package $PKG"

( cd "$BUILDDIR" && dpkg-buildpackage -d -S --no-sign )
