Align all plugins with new method for cache id 63/4863/10
authorStefan K. Berg <stefan.k.berg@ericsson.com>
Fri, 18 Dec 2015 11:53:46 +0000 (12:53 +0100)
committerJonas Bjurel <jonas.bjurel@ericsson.com>
Mon, 21 Dec 2015 17:52:48 +0000 (17:52 +0000)
The cache tool is now responsible for returning the commit
ID of a branch, tag or commit. This change was first
introduced in the bgpvpn plugin and now the rest of the
plugins with a need for this are also using the same method.

Without this, a plugin pointing to a commit ID on master
would fail to build once the head of master is updated to
point to a later commit...

Change-Id: I7c32d5b41871741717ae42c1334e8557f0b0bedd
Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
build/cache.sh
build/f_isoroot/f_bgpvpn-pluginbuild/Makefile
build/f_isoroot/f_odlpluginbuild/Makefile
build/f_isoroot/f_ovs-nsh-dpdk-pluginbuild/Makefile
build/f_isoroot/f_qemupluginbuild/Makefile

index ed90056..07361d2 100755 (executable)
@@ -96,13 +96,32 @@ validSHA1() {
 
 # Figure out commit ID from URI and tag/branch/commit ID
 getcommitid() {
-    HEADMATCH=`git ls-remote $1 | grep "refs/heads/$2$" | awk '{ print $1 }'`
-    TAGMATCH=`git ls-remote $1 | grep "refs/tags/$2$" | awk '{ print $1 }'`
+    if echo $2 | grep -q '^refs/changes/'; then
+        REF=`echo $2 | sed "s,refs\/changes\/\(.*\),\1,"`
+    else
+        REF=$2
+    fi
+
+    echo "Repo is $1, ref is ${REF}" >&2
+
+    HEADMATCH=`git ls-remote $1 | grep "refs/heads/${REF}$" | awk '{ print $1 }'`
+    TAGMATCH=`git ls-remote $1 | grep "refs/tags/${REF}$" | awk '{ print $1 }'`
+    CHANGEMATCH=`git ls-remote $1 | grep "refs/changes/${REF}$" | awk '{ print $1 }'`
 
     if [ -n "$HEADMATCH" ]; then
         echo "$HEADMATCH"
     elif [ -n "$TAGMATCH" ]; then
         echo "$TAGMATCH"
+    elif [ -n "$CHANGEMATCH" ]; then
+        echo "Warning: ${REF} is a change!" >&2
+        TMPDIR=`mktemp -d /tmp/cacheXXXXX`
+        cd $TMPDIR
+        git clone $1 &>/dev/null || errorexit "Could not clone $1"
+        cd * || errorexit "Could not enter clone of $1"
+       git fetch $1 refs/changes/$REF &>/dev/null || errorexit "Could not fetch change"
+       git checkout FETCH_HEAD &>/dev/null || errorexit "Could not checkout FETCH_HEAD"
+        git show HEAD &>/dev/null || errorexit "Could not find commit $2"
+        git show HEAD | head -1 | awk '{ print $2 }'
     else
         TMPDIR=`mktemp -d /tmp/cacheXXXXX`
         cd $TMPDIR
index 3da8d38..a99a426 100644 (file)
@@ -61,7 +61,7 @@ release:.bgpvpnbuild
 #   - The SHA1 hash of the HEAD on the plugin repo's $(BGPVPN_BRANCH)
 #   - The contents of this Makefile
 .cacheid:
-       if [ ! -z $(BGPVPN_CHANGE) ]; then \
+       @if [ ! -z $(BGPVPN_CHANGE) ]; then \
          $(CACHETOOL) getcommitid $(BGPVPN_REPO) $(BGPVPN_CHANGE) > .cachedata; \
        else \
          $(CACHETOOL) getcommitid $(BGPVPN_REPO) $(BGPVPN_BRANCH) > .cachedata; \
index 4ec7e80..ba5a06b 100644 (file)
@@ -47,7 +47,7 @@ release:.odlbuild
 #   - The SHA1 hash of the HEAD on the plugin repo's $(ODL_BRANCH)
 #   - The contents of this Makefile
 .cacheid:
-       git ls-remote --heads $(ODL_REPO) | grep $(ODL_BRANCH) > .cachedata
+       @$(CACHETOOL) getcommitid $(ODL_REPO) $(ODL_BRANCH) > .cachedata
        sha1sum Makefile >> .cachedata
        cat .cachedata | $(CACHETOOL) getid > .cacheid
 
index 601ec1e..89af75b 100644 (file)
@@ -60,7 +60,11 @@ release:.ovsbuild
 #   - The SHA1 hash of the HEAD on the plugin repo's $(OVS_NSH_DPDK_BRANCH)
 #   - The contents of this Makefile
 .cacheid:
-       @git ls-remote --heads $(OVS_NSH_DPDK_REPO) | grep $(OVS_NSH_DPDK_BRANCH) | awk {'print $$1'} > .cachedata
+       @if [ ! -z $(OVS_NSH_DPDK_CHANGE) ]; then \
+         $(CACHETOOL) getcommitid $(OVS_NSH_DPDK_REPO) $(OVS_NSH_DPDK_CHANGE) > .cachedata; \
+       else \
+         $(CACHETOOL) getcommitid $(OVS_NSH_DPDK_REPO) $(OVS_NSH_DPDK_BRANCH) > .cachedata; \
+       fi
        @sha1sum Makefile | awk {'print $$1'} >> .cachedata
        @sha1sum config.mk | awk {'print $$1'} >> .cachedata
        @cat .cachedata | $(CACHETOOL) getid > .cacheid
index 4e8d9e9..19a2337 100644 (file)
@@ -60,7 +60,11 @@ release:.qemubuild
 #   - The SHA1 hash of the HEAD on the plugin repo's $(QEMU_BRANCH)
 #   - The contents of this Makefile
 .cacheid:
-       @git ls-remote --heads $(QEMU_REPO) | grep $(QEMU_BRANCH) | awk {'print $$1'} > .cachedata
+       @if [ ! -z $(QEMU_CHANGE) ]; then \
+         $(CACHETOOL) getcommitid $(QEMU_REPO) $(QEMU_CHANGE) > .cachedata; \
+       else \
+         $(CACHETOOL) getcommitid $(QEMU_REPO) $(QEMU_BRANCH) > .cachedata; \
+       fi
        @sha1sum Makefile | awk {'print $$1'} >> .cachedata
        @sha1sum config.mk | awk {'print $$1'} >> .cachedata
        @cat .cachedata | $(CACHETOOL) getid > .cacheid