CI: rebuild the NETCONF stack if updated via CzechLight/dependencies

If there's a change for, say, CzechLight/cla-sysrepo which depends-on a
change for CzechLight/dependencies, the build job which rebuilds the FW
image for that change of cla-sysrepo was ignoring updated dependencies
by mistake.

As explained in the commit message, this is far from perfect, but hey,
it's a CI system, not a spaceship.

Change-Id: If590c2dc8733d7960784e171c06a005511ee3277
diff --git a/ci/build.sh b/ci/build.sh
index 4fced8e..3f6dea2 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -74,6 +74,15 @@
             rm -rf build/${PROJECT}-custom/ per-package/${PROJECT}/
         fi
     done
+
+    # Is there a change ahead which updates CzechLight/dependencies? If so, make sure these will get rebuilt
+    # This is (still) not foolproof. It will use a wrong version of dependencies if that change has been already merged, but br2-external doesn't have it merged
+    HAS_CHANGE_OF_DEPENDENCIES=$(jq < ~/zuul-env.json -r '[.items[]? | select(.project.name == "CzechLight/dependencies")][-1]?.project.src_dir + ""')
+    if [[ ! -z "${HAS_CHANGE_OF_DEPENDENCIES}" ]]; then
+        for PROJECT in libyang sysrepo libnetconf2 netopeer2; do
+            rm -rf build/{,host-}${PROJECT}-custom/ per-package/{,host-}${PROJECT}/
+        done
+    fi
 fi
 
 make source -j${CI_PARALLEL_JOBS} --output-sync=target