From 56ba6559a5d40425b5aa1fe395cdaf90b19efb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20J=C4=99drych?= <22376195+oreze@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:53:23 +0200 Subject: [PATCH] fix: add fixed time lock timeout on apt-get install/update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Szymon Jędrych <22376195+oreze@users.noreply.github.com> --- install.sh | 8 ++++---- rootless-install.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index a740fe36..0d7e217c 100755 --- a/install.sh +++ b/install.sh @@ -498,13 +498,13 @@ do_install() { if ! is_dry_run; then set -x fi - $sh_c 'apt-get update -qq >/dev/null' - $sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pre_reqs >/dev/null" + $sh_c 'apt-get -o DPkg::Lock::Timeout=60 update -qq >/dev/null' + $sh_c "DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 install -y -qq $pre_reqs >/dev/null" $sh_c 'install -m 0755 -d /etc/apt/keyrings' $sh_c "curl -fsSL \"$DOWNLOAD_URL/linux/$lsb_dist/gpg\" -o /etc/apt/keyrings/docker.asc" $sh_c "chmod a+r /etc/apt/keyrings/docker.asc" $sh_c "echo \"$apt_repo\" > /etc/apt/sources.list.d/docker.list" - $sh_c 'apt-get update -qq >/dev/null' + $sh_c 'apt-get -o DPkg::Lock::Timeout=60 update -qq >/dev/null' ) pkg_version="" if [ -n "$VERSION" ]; then @@ -546,7 +546,7 @@ do_install() { if ! is_dry_run; then set -x fi - $sh_c "DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $pkgs >/dev/null" + $sh_c "DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 install -y -qq $pkgs >/dev/null" ) echo_docker_as_nonroot exit 0 diff --git a/rootless-install.sh b/rootless-install.sh index 0d964ff1..c8c5f348 100755 --- a/rootless-install.sh +++ b/rootless-install.sh @@ -127,8 +127,8 @@ checks() { # uidmap dependency check if ! command -v newuidmap >/dev/null 2>&1; then - if command -v apt-get >/dev/null 2>&1; then - INSTRUCTIONS="apt-get install -y uidmap" + if command -v apt-get -o DPkg::Lock::Timeout=60 >/dev/null 2>&1; then + INSTRUCTIONS="apt-get -o DPkg::Lock::Timeout=60 install -y uidmap" elif command -v dnf >/dev/null 2>&1; then INSTRUCTIONS="dnf install -y shadow-utils" elif command -v yum >/dev/null 2>&1; then @@ -142,9 +142,9 @@ yum install -y shadow-utils46-newxidmap" # iptables dependency check if [ -z "$SKIP_IPTABLES" ] && ! command -v iptables >/dev/null 2>&1 && [ ! -f /sbin/iptables ] && [ ! -f /usr/sbin/iptables ]; then - if command -v apt-get >/dev/null 2>&1; then + if command -v apt-get -o DPkg::Lock::Timeout=60 >/dev/null 2>&1; then INSTRUCTIONS="${INSTRUCTIONS} -apt-get install -y iptables" +apt-get -o DPkg::Lock::Timeout=60 install -y iptables" elif command -v dnf >/dev/null 2>&1; then INSTRUCTIONS="${INSTRUCTIONS} dnf install -y iptables"