Skip to content

Commit 56ba655

Browse files
committed
fix: add fixed time lock timeout on apt-get install/update
Signed-off-by: Szymon Jędrych <[email protected]>
1 parent dd4d114 commit 56ba655

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ do_install() {
498498
if ! is_dry_run; then
499499
set -x
500500
fi
501-
$sh_c 'apt-get update -qq >/dev/null'
502-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pre_reqs >/dev/null"
501+
$sh_c 'apt-get -o DPkg::Lock::Timeout=60 update -qq >/dev/null'
502+
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 install -y -qq $pre_reqs >/dev/null"
503503
$sh_c 'install -m 0755 -d /etc/apt/keyrings'
504504
$sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" -o /etc/apt/keyrings/docker.asc"
505505
$sh_c "chmod a+r /etc/apt/keyrings/docker.asc"
506506
$sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list"
507-
$sh_c 'apt-get update -qq >/dev/null'
507+
$sh_c 'apt-get -o DPkg::Lock::Timeout=60 update -qq >/dev/null'
508508
)
509509
pkg_version=""
510510
if [ -n "$VERSION" ]; then
@@ -546,7 +546,7 @@ do_install() {
546546
if ! is_dry_run; then
547547
set -x
548548
fi
549-
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pkgs >/dev/null"
549+
$sh_c "DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 install -y -qq $pkgs >/dev/null"
550550
)
551551
echo_docker_as_nonroot
552552
exit 0

rootless-install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ checks() {
127127

128128
# uidmap dependency check
129129
if ! command -v newuidmap >/dev/null 2>&1; then
130-
if command -v apt-get >/dev/null 2>&1; then
131-
INSTRUCTIONS="apt-get install -y uidmap"
130+
if command -v apt-get -o DPkg::Lock::Timeout=60 >/dev/null 2>&1; then
131+
INSTRUCTIONS="apt-get -o DPkg::Lock::Timeout=60 install -y uidmap"
132132
elif command -v dnf >/dev/null 2>&1; then
133133
INSTRUCTIONS="dnf install -y shadow-utils"
134134
elif command -v yum >/dev/null 2>&1; then
@@ -142,9 +142,9 @@ yum install -y shadow-utils46-newxidmap"
142142

143143
# iptables dependency check
144144
if [ -z "$SKIP_IPTABLES" ] && ! command -v iptables >/dev/null 2>&1 && [ ! -f /sbin/iptables ] && [ ! -f /usr/sbin/iptables ]; then
145-
if command -v apt-get >/dev/null 2>&1; then
145+
if command -v apt-get -o DPkg::Lock::Timeout=60 >/dev/null 2>&1; then
146146
INSTRUCTIONS="${INSTRUCTIONS}
147-
apt-get install -y iptables"
147+
apt-get -o DPkg::Lock::Timeout=60 install -y iptables"
148148
elif command -v dnf >/dev/null 2>&1; then
149149
INSTRUCTIONS="${INSTRUCTIONS}
150150
dnf install -y iptables"

0 commit comments

Comments
 (0)