Skip to content

Commit

Permalink
fix with writing lock follow-ups
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Dec 10, 2024
1 parent 8cec517 commit 0efd196
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/xx-apk
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ set -e

if [ -z "$XX_APK_NOLOCK" ]; then
# readlink -f in ash can not resolve symlinks from deep workdir
cd /
cd / >/dev/null
if [ -L /var/lock ] && [ ! -e "$(readlink -f /var/lock)" ]; then
mkdir -p "$(readlink -f /var/lock)"
elif [ ! -d /var/lock ]; then
mkdir -p /var/lock
fi
cd -
cd - >/dev/null
lock="/var/lock/xx-apk"
exec 9>$lock
flock -x 9
Expand Down
3 changes: 3 additions & 0 deletions src/xx-apt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
set -e

if [ -z "$XX_APT_NOLOCK" ]; then
# readlink -f in ash can not resolve symlinks from deep workdir
cd / >/dev/null
if [ -L /var/lock ] && [ ! -e "$(readlink -f /var/lock)" ]; then
mkdir -p "$(readlink -f /var/lock)"
elif [ ! -d /var/lock ]; then
mkdir -p /var/lock
fi
cd - >/dev/null
lock="/var/lock/xx-apt"
exec 9>$lock
flock -x 9
Expand Down
3 changes: 3 additions & 0 deletions src/xx-cargo
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ execSilent() {
}

if [ -z "$XX_CARGO_NOLOCK" ]; then
# readlink -f in ash can not resolve symlinks from deep workdir
cd / >/dev/null
if [ -L /var/lock ] && [ ! -e "$(readlink -f /var/lock)" ]; then
mkdir -p "$(readlink -f /var/lock)"
elif [ ! -d /var/lock ]; then
mkdir -p /var/lock
fi
cd - >/dev/null
lock="/var/lock/xx-cargo"
exec 9>$lock
flock -x 9
Expand Down
3 changes: 3 additions & 0 deletions src/xx-cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,14 @@ fi

setup() {
if [ -z "$XX_CC_NOLOCK" ]; then
# readlink -f in ash can not resolve symlinks from deep workdir
cd / >/dev/null
if [ -L /var/lock ] && [ ! -e "$(readlink -f /var/lock)" ]; then
mkdir -p "$(readlink -f /var/lock)"
elif [ ! -d /var/lock ]; then
mkdir -p /var/lock
fi
cd - >/dev/null
lock="/var/lock/xx-cc"
exec 9>$lock
flock -x 9
Expand Down
3 changes: 3 additions & 0 deletions src/xx-verify
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
set -e

if [ -z "$XX_VERIFY_NOLOCK" ]; then
# readlink -f in ash can not resolve symlinks from deep workdir
cd / >/dev/null
if [ -L /var/lock ] && [ ! -e "$(readlink -f /var/lock)" ]; then
mkdir -p "$(readlink -f /var/lock)"
elif [ ! -d /var/lock ]; then
mkdir -p /var/lock
fi
cd - >/dev/null
lock="/var/lock/xx-verify"
exec 9>$lock
flock -x 9
Expand Down

0 comments on commit 0efd196

Please sign in to comment.