From: Andrea Zagli <azagli@libero.it>
Date: Thu, 2 Mar 2017 16:09:57 +0000 (+0100)
Subject: Script che ritorna vero se un pacchetto debian git snapshot deve essere aggiornato.
X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=ac4519b576c967825e8afdac219cb3a217b538d1;p=msys2

Script che ritorna vero se un pacchetto debian git snapshot deve essere aggiornato.

Lo script prende le informazioni dal file di configurazione di gbp.
---

diff --git a/tools/autobuilder/debian_tobeupdated.sh b/tools/autobuilder/debian_tobeupdated.sh
new file mode 100755
index 0000000..1cec85a
--- /dev/null
+++ b/tools/autobuilder/debian_tobeupdated.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+if [ ! -d "debian" ]; then
+	echo "No debian directory found."
+	exit;
+fi
+
+# current branch
+CURRENT_BRANCH=`git branch | grep \* | sed -n -e 's/\* //p'`
+
+echo "Current branch: "$CURRENT_BRANCH
+
+# the upstream-branch from debian/gbp.conf
+UPSTREAM_BRANCH=`sed -n -e 's/^\s*upstream-branch\s*=\s*//p' debian/gbp.conf`
+
+echo "Upstream branch: "$UPSTREAM_BRANCH
+
+# update upstream branch
+git checkout $UPSTREAM_BRANCH
+git pull
+git checkout $CURRENT_BRANCH
+
+# not empty if there's at least one commit be merged
+TO_BE_MERGED=`git log --pretty=oneline --graph ..$UPSTREAM_BRANCH | head -n 1 | sed -n -e 's/\* //p'`
+TO_BE_MERGED=${TO_BE_MERGED%% *}
+
+echo "Last commit to be merged: "$TO_BE_MERGED
+
+if [ "$TO_BE_MERGED" = "" ]; then
+	echo -e "\nNot to be updated."
+else
+	# the snapshot hash of the package
+	SNAPSHOT_HASH=`head -n 1 debian/changelog | sed -n -e 's/.*\((.*)\).*/\1/;s/.*\(\.gbp\(.*\))\)/\2/p'`
+
+	echo "Debian package snapshot version: "$SNAPSHOT_HASH
+
+	if [ "${TO_BE_MERGED:6}" = "$SNAPSHOT_HASH" ]; then
+		echo -e "\nNot to be updated."
+	else
+		echo -e "\nThe debian branch must be updated."
+	fi
+fi