From 9ee1112ad06f9c429b405a93c061d3c178989011 Mon Sep 17 00:00:00 2001
From: nrb <freifunk@nicoboehr.de>
Date: Tue, 17 Nov 2020 18:17:50 +0100
Subject: [PATCH] ci: cache openwrt staging_dir outside openwrt directory

Previously, we've cached staging_dir in the gluon/openwrt subdirectory.
But this doesn't really work properly because of gitlab's submodule
behaviour. It will first extract the cache and then update the
submodules.

Because the cached directory resides inside the gluon submodule, it will
be deleted upon submodule checkout. By putting the cache in a directory
outside the submodule we can avoid this. We will then simply symlink the
cached directory to the desired destination such that it is found during
the build.
---
 .gitlab-ci.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f93c8a5ff..032cdb4d6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -41,6 +41,7 @@ update:
     - test -d ffs-openwrt-dl-cache || git clone ssh://git@gitlab.freifunk-stuttgart.de:22220/firmware/ffs-openwrt-dl-cache.git
     - git -C ffs-openwrt-dl-cache pull
     - rm -rf gluon/openwrt/dl && mkdir -p gluon/openwrt && ln -s ../../ffs-openwrt-dl-cache gluon/openwrt/dl
+    - rm -rf gluon/openwrt/staging_dir && mkdir -p staging_dir && ln -s ../../staging_dir gluon/openwrt/staging_dir
   script:
     - make -C gluon GLUON_SITEDIR="$CI_PROJECT_DIR" GLUON_TARGET="$GLUON_TARGET" GLUON_BRANCH=stable FFS_BUILD_DATE=$(cat build.date) V=1 -j`nproc`
     - cd gluon/openwrt/dl && git add . && git commit -m "update DL cache" && git pull --rebase && git push || true
@@ -53,7 +54,7 @@ update:
   cache:
     paths:
       - ffs-openwrt-dl-cache
-      - gluon/openwrt/staging_dir
+      - staging_dir
     key: "build-$CI_COMMIT_REF_SLUG"
  
 target:ar71xx-generic:
-- 
GitLab