#!/bin/bash # Release a packaged crate to Debian. # # Usage: [REALVER=] ./release.sh [] # # Envvars: # See also ./vars.sh.frag for its envvars, which we pass through. # See also ./build.sh for its envvars, which we pass through. # RERELEASE=1 # Bump the changelog for a source-only reupload, required for migration to # Debian Testing, and automatically dput the tarball. You need this after a # NEW upload. This is a dumb consequence of two independently-thought-out # policies but nobody on either team has expressed interest in fixing it, # claiming "not my department". # REUSE_EXISTING_ORIG_TARBALL=1 # Re-use the existing .orig tarball. This is needed if it was previously # generated with an old version of debcargo, otherwise you'll get # auto-REJECT from Debian FTP. TODO: we probably want to set this # automatically on if the Debian version ends with -2 or above. . ./vars.sh.frag RED=`echo -e "\033[1;31m"` NC=`echo -e "\033[0m"` 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" :^"$PKGDIR_REL/debian/patches/*"; 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" timeout --foreground 15 git fetch origin --prune || abort 1 "Failed to fetch upstream to check whether we are synced, please check network" git merge-base --is-ancestor origin/master HEAD || \ abort 1 "You are not synced with origin/master, please do so before running this script." REALVER="$(get_existing_version "$PKGDIR")" if head -n1 "$PKGDIR/debian/changelog" | grep -qv UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO; then if [ "$RERELEASE" = 1 ]; then run_debcargo ( cd "$PKGDIR" && dch -a "No-op source-only re-upload for Debian Testing Migration." ) export REUSE_EXISTING_ORIG_TARBALL=1 else abort 0 \ "Package already released. If you want to do a source-only re-upload e.g. to" \ "hoop-jump through the Debian Testing migration requirements, set RERELEASE=1." fi fi if [ -e "$PKGDIR/debian/BLOCK" ]; then abort 1 "TODO items remain in $PKGDIR/debian/BLOCK, please deal with those" 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 CHANGEDBY=$(dpkg-parsechangelog -l $PKGDIR/debian/changelog -SMaintainer) if [ "$CHANGEDBY" != "$UPLOADER" ]; then cat < release those first." \ "- packaged version is out-of-date => run \`./update.sh $*\`" fi 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) git commit -m "$PKGNAME: release $DEBVER" if [ "$RERELEASE" = 1 ]; then ( cd build && dput "${DEBSRC}_${DEBVER}_source.changes" ) git push origin "$RELBRANCH" git checkout master cat <> $PKGDIR_REL/debian/debcargo.toml && git commit -m '$PKGDIR_REL: add collapse_features = true' $PKGDIR_REL/debian/debcargo.toml" echo "${NC}" exit 1 fi elif [ -z "$new_bin_packages" ]; then cat <&2 <