blob: adeb4c16f1b02abc4cc59415604fdc2887854fb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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
|