From 3520ff8f7907523623881d9c218e9caaa3fc5b9c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 3 Feb 2023 13:36:00 +0100 Subject: [PATCH] contrib: avoid using "sudo" in REQUIRED_PACKAGES scripts It's often not installed, and usually we are already root. Avoid using sudo. (cherry picked from commit f6805debee86a603ef290fe0242548990075cf19) --- .gitlab-ci.yml | 8 ++++---- contrib/debian/REQUIRED_PACKAGES | 5 ++++- contrib/fedora/REQUIRED_PACKAGES | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dc80aae51a..016d8ab9c9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,10 +53,10 @@ variables: # # This is done by running `ci-fairy generate-template` and possibly bumping # ".default_tag". - FEDORA_TAG: '2023-01-18.0-1423f8164e71' - UBUNTU_TAG: '2023-01-18.0-08fb4e6eb861' - DEBIAN_TAG: '2023-01-18.0-08fb4e6eb861' - CENTOS_TAG: '2023-01-18.0-1423f8164e71' + FEDORA_TAG: '2023-01-18.0-503dba0518ae' + UBUNTU_TAG: '2023-01-18.0-1218be1cbc9d' + DEBIAN_TAG: '2023-01-18.0-1218be1cbc9d' + CENTOS_TAG: '2023-01-18.0-503dba0518ae' ALPINE_TAG: '2023-01-18.0-14c807942fa4' FEDORA_EXEC: 'bash .gitlab-ci/fedora-install.sh' diff --git a/contrib/debian/REQUIRED_PACKAGES b/contrib/debian/REQUIRED_PACKAGES index 34e591ddc7..4e8bb8c603 100755 --- a/contrib/debian/REQUIRED_PACKAGES +++ b/contrib/debian/REQUIRED_PACKAGES @@ -12,11 +12,14 @@ set -xe # Not all of these packages are strictly speaking necessary. # This is a generous list of related packages. +SUDO= +[ "$EUID" -eq 0 ] || SUDO=sudo + install() { if [ "$NM_INSTALL" != "" ]; then $NM_INSTALL "$@" else - sudo apt-get install -y "$@" + $SUDO apt-get install -y "$@" fi } diff --git a/contrib/fedora/REQUIRED_PACKAGES b/contrib/fedora/REQUIRED_PACKAGES index c77f4ccdc1..644e518b1b 100755 --- a/contrib/fedora/REQUIRED_PACKAGES +++ b/contrib/fedora/REQUIRED_PACKAGES @@ -14,11 +14,14 @@ set -xe DNF="$(command -v dnf &>/dev/null && echo dnf || echo yum)" +SUDO= +[ "$EUID" -eq 0 ] || SUDO=sudo + install() { if [ "$NM_INSTALL" != "" ]; then $NM_INSTALL "$@" else - sudo "$DNF" install -y "$@" + $SUDO "$DNF" install -y "$@" fi }