Use a correct version of the CzechLight/dependencies repo

Now that these are no longer pinned via cla-sysrepo or netconf-cli, it's
possible to support taking a specific commit in two different ways:

- as a git submodule, i.e., whatever is in the repo, ignoring Zuul,
- or from Zuul's job dependencies, overriding whatever is pinned via the git submodule

In a way, this achieves a similar end result with what we're currently
doing for `velia`, `cla-sysrepo`, `netconf-cli` and `rousette` -- except
these are BR-level packages which map 1:1 to a git submodule, whereas
the `CzechLight/dependencies` is a magic snowflake which determines
versions of a zillion of other packages.

Fixes: 69c92de Fix git version reporting of `CzechLight/dependencies`
Fixes: 32ca34f Stop pinning `CzechLight/dependencies` via `cla-sysrepo` and `netconf-cli`
Change-Id: Iac701db50f5d349a053aa548c9ce4b960349e95a
Depends-on: https://gerrit.cesnet.cz/c/ci/zuul-jobs-cesnet/+/5618
diff --git a/.zuul.yaml b/.zuul.yaml
index 2462399..fb85f6b 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -6,6 +6,7 @@
     vars:
       prepare_git_submodules: true
       zuul_work_dir: "{{ zuul.projects[zuul.project.canonical_hostname + '/CzechLight/br2-external'].src_dir }}"
+      git_submodule_dirs: "{{ zuul.projects[zuul.project.canonical_hostname + '/CzechLight/br2-external'].src_dir }}:{{ zuul.projects[zuul.project.canonical_hostname + '/CzechLight/dependencies'].src_dir }}"
     required-projects: &projects
       - github/buildroot/buildroot
       - CzechLight/dependencies
diff --git a/board/czechlight/common/os-release.sh b/board/czechlight/common/os-release.sh
index 06c65d1..6c4b4c2 100755
--- a/board/czechlight/common/os-release.sh
+++ b/board/czechlight/common/os-release.sh
@@ -11,11 +11,13 @@
 CLA_BR2_EXTERNAL_REV=$(czechlight_describe_git ${BR2_EXTERNAL_CZECHLIGHT_PATH})
 CLA_SYSREPO_REV=$(czechlight_describe_git $(czechlight_query_local_make_var CLA_SYSREPO_OVERRIDE_SRCDIR))
 NETCONF_CLI_REV=$(czechlight_describe_git $(czechlight_query_local_make_var NETCONF_CLI_OVERRIDE_SRCDIR))
-CLA_CPP_DEPENDENCIES_REV=$(czechlight_describe_git ${BR2_EXTERNAL_CZECHLIGHT_PATH}/submodules/dependencies)
 GAMMARUS_REV=$(czechlight_describe_git $(czechlight_query_local_make_var GAMMARUS_OVERRIDE_SRCDIR))
 VELIA_REV=$(czechlight_describe_git $(czechlight_query_local_make_var VELIA_OVERRIDE_SRCDIR))
 ROUSETTE_REV=$(czechlight_describe_git $(czechlight_query_local_make_var ROUSETTE_OVERRIDE_SRCDIR))
 
+# CzechLight/dependencies might come either from a git submodule, or from a Zuul change enqueued before this one
+CLA_CPP_DEPENDENCIES_REV=$(czechlight_describe_git $(czechlight_query_local_make_var LIBYANG_OVERRIDE_SRCDIR)/..)
+
 sed -i \
 	-e 's/^VERSION_ID=/BUILDROOT_VERSION_ID=/' \
 	-e 's/^VERSION=/BUILDROOT_VERSION=/' \
diff --git a/ci/build.sh b/ci/build.sh
index 8e0b0b8..d7a6ada 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -54,6 +54,7 @@
 
             # `make ${pkg}-reconfigure` is *not* enough with BR2_PER_PACKAGE_DIRECTORIES=y
             # Even this is possibly fragile if these packages were not the "leaf" ones (in terms of BR-level dependencies).
+            # But any change to CzechLight/dependencies is handled explicitly below.
             rm -rf build/${PROJECT}-custom/ per-package/${PROJECT}/
         fi
     done
@@ -68,13 +69,17 @@
 # After a "big" update there should always be a standalone sync to `br2-external` as the very last step anyway.
 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 \
-	libyang-cpp sysrepo-cpp \
-	docopt-cpp replxx cppcodec sdbus-cpp \
-	; do
-    rm -rf build/{,host-}${PROJECT}-custom/ per-package/{,host-}${PROJECT}/
-done
+    # redirect BR packages to a Zuul-injected dependency
+    sed -i "s|${ZUUL_PROJECT_SRC_DIR}/submodules/dependencies|${HOME}/${HAS_CHANGE_OF_DEPENDENCIES}|g" local.mk
+
+    # persuade BR to rebuild them
+    for PROJECT in \
+            libyang sysrepo libnetconf2 netopeer2 \
+            libyang-cpp sysrepo-cpp \
+            docopt-cpp replxx cppcodec sdbus-cpp \
+            ; do
+        rm -rf build/{,host-}${PROJECT}-custom/ per-package/{,host-}${PROJECT}/
+    done
 fi
 
 make source -j${CI_PARALLEL_JOBS} --output-sync=target