#!/bin/sh . ./vars.sh.frag if test ! -d $PKGDIR_REL; then abort 1 "Cannot find $PKGDIR_REL. Did you run ./new-package.sh before?" fi if test ! -f "$PKGDIR_REL/debian/changelog"; then abort 1 "Cannot find $PKGDIR_REL/debian/changelog. Did you run ./new-package.sh before?" fi if git grep --quiet FIXME -- "$PKGDIR_REL" :^"$PKGDIR_REL/debian/*.debcargo.hint" :^"$PKGDIR_REL/debian/changelog"; then abort 1 "FIXMEs remain in $PKGDIR_REL, fix and commit those first." fi 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" type dch >/dev/null || \ abort 1 "Install devscripts, we need to run dch." RELBRANCH="pending-$PKGNAME" git fetch origin --prune if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then abort 0 "Package already released." fi PREVBRANCH="$(git rev-parse --abbrev-ref HEAD)" case "$PREVBRANCH" in pending-$PKGNAME) true;; pending-*) abort 1 "You are on a pending-release branch for a package other than $PKGNAME, $0 can only be run on another branch, like master";; *) if git rev-parse -q --verify "refs/heads/$RELBRANCH" >/dev/null || \ git rev-parse -q --verify "refs/remotes/origin/$RELBRANCH" >/dev/null; then git checkout "$RELBRANCH" else git checkout -b "$RELBRANCH" fi;; esac if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then git checkout "$PREVBRANCH" abort 0 "Package already released on branch $RELBRANCH. If that was a mistake then run \`git branch -D $RELBRANCH\`, and re-run this script ($0 $*). You might have to delete the remote branch too (\`git push --delete origin $RELBRANCH\`)." fi ( cd "$PKGDIR" sed -i -e s/UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO/UNRELEASED/ debian/changelog dch -m -r -D unstable "" git add debian/changelog ) revert_git_changes() { git reset git checkout -- "$PKGDIR/debian/changelog" git checkout "$PREVBRANCH" git branch -d "$RELBRANCH" } if ! run_debcargo --changelog-ready; then revert_git_changes abort 1 "Release attempt failed to run debcargo, probably the package needs updating (./update.sh $*)" fi if ! git diff --exit-code -- "$PKGDIR_REL"; then revert_git_changes abort 1 "Release attempt resulted in git diffs to $PKGDIR_REL, probably the package needs updating (./update.sh $*)" fi if ! ( cd build && SOURCEONLY=1 ./build.sh "$CRATE" $VER ); then revert_git_changes abort 1 "Release attempt failed (see messages above), possible reasons are: " \ "- build-dependencies not in Debian => release those first." \ "- packaged version is out-of-date => run \`./update.sh $*\`" fi git commit -m "Release package $PKGNAME" DEBVER=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SVersion) DEBSRC=$(dpkg-parsechangelog -l $BUILDDIR/debian/changelog -SSource) DEB_HOST_ARCH=$(dpkg-architecture -q DEB_HOST_ARCH) cat >&2 <