. ./vars.sh.frag
-git diff -q -- "$PKGDIR_REL" || \
+git diff --quiet --cached || \
+abort 1 "You have other pending changes to git, please complete it or stash it away and re-run this script."
+
+git diff --quiet -- "$PKGDIR_REL" || \
abort 1 "Please git-add your changes to $PKGDIR_REL before running"
+head -n1 "$PKGDIR/debian/changelog" | grep -q UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO || \
+abort 1 "Package already released. If that was a mistake and you didn't actually upload yet, you may rewind your git and re-run this script."
+
( cd "$PKGDIR"
sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog
dch -r -D unstable ""
git commit -m "Release package $PKG"
( cd "$BUILDDIR" && dpkg-buildpackage -d -S --no-sign )
+
+cat >&2 <<eof
+Release of $PKG ready as a source package in ${BUILDDIR#$PWD/}.
+
+If the source package is already in Debian and this version does not introduce
+new binaries, then you can just go ahead and directly dput the source package.
+
+If this is a NEW source package or introduces NEW binary packages not already
+in the Debian archive, you will need to build a binary package out of it. The
+recommended way is to run something like:
+
+$ sbuild <source_package.dsc>
+$ changestool <sbuild_binary_changes.changes> addsc <source_package.dsc>
+$ debsign --no-re-sign <sbuild_binary_changes.changes>
+$ dput <sbuild_binary_changes.changes>
+
+See https://wiki.debian.org/sbuild for instructions on how to set it up. The
+other tools are from the 'devscripts' package.
+
+The above assumes you are a Debian Developer. If not, you should revert your
+changes and ask a Debian Developer to do this step.
+eof
echo "FIXME fill me in using ./copyright.debcargo.hint as a guide" > "$PKGDIR/debian/copyright"
fi
-rm -rf "$BUILDDIR" && mkdir -p "$(dirname $BUILDDIR)"
+rm -rf "$BUILDDIR"
$DEBCARGO package --config "$PKGCFG" --directory "$BUILDDIR" "$PKG" "$VER"
-if ! git diff -q -- "$PKGDIR_REL"; then
+if ! git diff --quiet -- "$PKGDIR_REL"; then
read -p "Update wrote some changes to $PKGDIR_REL, press enter to git diff..." x
git diff -- "$PKGDIR_REL"
fi
PKGDIR="$PWD/$PKGDIR_REL"
BUILDDIR="$PWD/build/$PKGNAME"
PKGCFG="$PKGDIR/debian/debcargo.toml"
+
+mkdir -p "$(dirname $BUILDDIR)"
+
+if [ -z "$PKG" ]; then
+ abort 2 "Usage: $0 <package> [<version>]"
+fi