summaryrefslogtreecommitdiff
path: root/files
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2020-07-29 09:07:31 +0200
committerKarel Kočí <cynerd@email.cz>2020-07-29 09:07:31 +0200
commit5945a7d62cd656394d5e9880c5d9116351e81955 (patch)
tree1ed8e078d22853376ebdae8cf173ffe435f89167 /files
parent2f64edb7fa0d9f584f168f4d3532d5bf4d0fcdd1 (diff)
downloadlaminar-cnf-5945a7d62cd656394d5e9880c5d9116351e81955.tar.gz
laminar-cnf-5945a7d62cd656394d5e9880c5d9116351e81955.tar.bz2
laminar-cnf-5945a7d62cd656394d5e9880c5d9116351e81955.zip
turris: protect git fetch to prevent failures
Diffstat (limited to 'files')
-rw-r--r--files/git-fetch-lock.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/files/git-fetch-lock.patch b/files/git-fetch-lock.patch
new file mode 100644
index 0000000..adeb4c1
--- /dev/null
+++ b/files/git-fetch-lock.patch
@@ -0,0 +1,59 @@
+From f08b9ae86aa612b71512451b9db0c7e729dda58c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= <cynerd@email.cz>
+Date: Wed, 29 Jul 2020 09:02:08 +0200
+Subject: [PATCH] compile_pkgs: protect repository fetch from local mirror with
+ lock
+
+We have protection for local repository mirror update but we do not have
+it for reading. It can happen that while one instance is updating
+repository the second one is trying to read it. That leads to git
+failing about unexpected references. This adds read protection as well
+as write one for local mirror repositories.
+---
+ compile_pkgs | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/compile_pkgs b/compile_pkgs
+index 8184e04..2af84b3 100755
+--- a/compile_pkgs
++++ b/compile_pkgs
+@@ -231,6 +231,14 @@ EOF
+ mirror_updated="yes"
+ }
+
++_git_fetch() {
++ if [ -n "$GIT_MIRROR" ] && [ -d "$GIT_MIRROR" ]; then
++ flock --shared "$GIT_MIRROR" -- git fetch "$@"
++ else
++ git fetch "$@"
++ fi
++}
++
+ _checkout_init() {
+ report "Checking out clean OpenWRT repository"
+ update_mirror
+@@ -267,10 +275,10 @@ checkout() {
+ local githash
+ githash="$(echo "$OPENWRT_BRANCH" | sed -n 's|^#||p')"
+ if [ -n "$githash" ]; then
+- git fetch origin
++ _git_fetch origin
+ git checkout -f "$githash"
+ else
+- git fetch ${CLONE_DEEP+--depth 1} origin "$OPENWRT_BRANCH"
++ _git_fetch ${CLONE_DEEP+--depth 1} origin "$OPENWRT_BRANCH"
+ git checkout -f "origin/$OPENWRT_BRANCH"
+ fi
+ _checkout_clean
+@@ -282,7 +290,7 @@ repo_checkout() {
+ report "Starting out $TARGET_BOARD-$PUBLISH_BRANCH!"
+ curl "https://repo.turris.cz/$PUBLISH_BRANCH/$TARGET_BOARD/packages/git-hash" | tail -n +2 | grep -v '^$' | sed 's/^ \* //;s/: /:/' > repo-git-hashes
+ _checkout_init
+- git fetch
++ _git_fetch
+ git checkout -f "$(awk -F : '/^openwrt:/{print $2}' repo-git-hashes)"
+ GIT_HASHES="$(cat repo-git-hashes)"
+ _checkout_clean
+--
+2.27.0
+