[med-svn] [Git][med-team/community/helper-scripts][master] 3 commits: Add script to semi-automate backports

Andreas Tille gitlab at salsa.debian.org
Fri May 10 12:53:04 BST 2019



Andreas Tille pushed to branch master at Debian Med / community / helper-scripts


Commits:
f82311ce by Andreas Tille at 2019-05-06T09:17:47Z
Add script to semi-automate backports

- - - - -
a06f37fc by Andreas Tille at 2019-05-06T09:42:02Z
Automatic d/changelog editing seems to work as expected

- - - - -
fa1224a7 by Andreas Tille at 2019-05-10T11:52:40Z
Exit in case of error if appropriate

- - - - -


1 changed file:

- + do_backport


Changes:

=====================================
do_backport
=====================================
@@ -0,0 +1,84 @@
+#!/bin/sh -e
+
+# automate all steps to backport a package
+
+# Should be turned into a command line option later
+FORCE=1
+
+TARGETDIST=stretch
+BRANCH=debian/${TARGETDIST}-backports
+
+set -x
+git checkout --quiet master
+tmppull=`mktemp /tmp/$(basename $0).XXXXXX`
+# not all error return codes of gbp pull are critical
+gbp pull 2>&1 | tee > $tmppull || true
+# do not tolerate "uncommitted changes"
+if grep 'gbp:error: You have uncommitted changes in your source tree' $tmppull ; then
+  cat $tmppull
+  rm $tmppull
+  exit 1
+fi
+rm $tmppull
+
+DIST=`dpkg-parsechangelog | awk '/^Distribution:/ {print $2}'`
+SPKG=`dpkg-parsechangelog | awk '/^Source:/ {print $2}'`
+if [ "$DIST" != "unstable" ] ; then
+  echo 'Current state of Git is not targeting "unstable"'
+  exit 1
+fi
+
+PKG=`grep "Package:" debian/control | head -n1 | awk '/^Package:/ {print $2}'`
+VERSION=`dpkg-parsechangelog | awk '/^Version:/ {print $2}' | sed 's/-[^-]\+$//'`
+
+if ! apt-cache policy $PKG | grep -A3 $VERSION | grep -q testing ; then # FIXME: That's a bit weak
+  echo "Package $PKG version $VERSION does not seem to be in testing (according local apt-cache)"
+  if [ $FORCE -ne 1 ] ; then
+    exit 1
+  fi
+fi
+
+exists=$(git show-ref refs/heads/$BRANCH) || true
+if [ -n "$exists" ] ; then
+  git checkout $BRANCH
+  LASTBACKPORTVERSION=$(dpkg-parsechangelog | awk '/^Version:/ {print $2}')
+  git merge master || true
+  if ! grep -q "$LASTBACKPORTVERSION" debian/changelog ; then
+    echo "Last backports paragraph from version $LASTBACKPORTVERSION is missing in debian/changelog"
+    exit 1
+  fi
+  if grep -q -e '^<<<<<<<' -e '^=======' debian/changelog ; then
+    echo "There are merge issues in debian/changelog"
+    # try fixing sequence of changes in changelog
+    # Moving blocks in sed is not possible - thus use vim (== ex)
+    ex "+2,/^=======/m/>>>>>>> master/" -sc'wq' debian/changelog
+    sed -i -e 's/^>>>>>>> master$//' -e '/^=======$/d' -e '1d' debian/changelog
+    # debug: check whether all is OK, if the above works several times remove next line
+    # edit debian/changelog
+    if grep -q -e '^<<<<<<<' -e '^=======' debian/control ; then
+      echo "There are merge issues in debian/changelog"
+      edit debian/changelog
+    fi
+    git commit || true
+  fi
+  dch --bpo ""
+else
+  git checkout -b $BRANCH
+  dch --bpo ""
+fi
+git commit -a -m"Rebuild for ${TARGETDIST}-backports"
+
+if ! which gbp-build >/dev/null ; then
+  echo "Andreas Tille has a local script that cares for correct configuration of gbp for backports"
+  echo "Either you create such a script yourself, nag Andreas to publish or call 'gbp buildpackage' manually"
+  exit 1
+fi
+gbp-build
+
+if [ -d /var/cache/pbuilder/extra/${TARGETDIST}/packages/ ] ; then
+  cp -a ../build-area/${SPKG}_${VERSION}*bpo*+1_a*.deb /var/cache/pbuilder/extra/${TARGETDIST}/packages/
+fi
+
+set -x
+TAG=debian/`dpkg-parsechangelog | awk '/^Version:/ {print $2}' | sed -e 's/~/_/'`
+git tag "$TAG"



View it on GitLab: https://salsa.debian.org/med-team/community/helper-scripts/compare/b26611e3c013642c3e665deb5fced40cdfc53166...fa1224a708f70c7cfde25107bc781a48bd953de7

-- 
View it on GitLab: https://salsa.debian.org/med-team/community/helper-scripts/compare/b26611e3c013642c3e665deb5fced40cdfc53166...fa1224a708f70c7cfde25107bc781a48bd953de7
You're receiving this email because of your account on salsa.debian.org.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190510/06b24386/attachment-0001.html>


More information about the debian-med-commit mailing list