From 04ed832f06b0949b44512e8cbb065cf66b31dd45 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 22 Jul 2021 14:17:39 +0100 Subject: [PATCH 1/2] install_base.sh: Ignore package install failure for unsupported distro Install packages one by one to avoid failure of apt when some packages do not exist. This happens when an apt-based distro lacks one of the Ubuntu package name. --- install_base.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/install_base.sh b/install_base.sh index f450d57be..d74c35333 100755 --- a/install_base.sh +++ b/install_base.sh @@ -115,8 +115,16 @@ clone_alpine_chroot_install() { install_apt() { echo "Installing apt packages ..." - sudo apt-get update && - sudo apt-get install -y "${apt_packages[@]}" + sudo apt-get update + if [[ $unsupported_distro == 1 ]]; then + for package in "${apt_packages[@]}"; do + if ! sudo apt-get install -y "$package"; then + echo "Failed to install $package on that distribution" >&2 + fi + done + else + sudo apt-get install -y "${apt_packages[@]}" + fi } install_pacman() { @@ -212,9 +220,12 @@ else fi if [[ ! -z "$package_manager" ]] && ! test_os_release NAME "$expected_distro"; then + unsupported_distro=1 echo echo "INFO: the distribution seems based on $package_manager but is not $expected_distro, some package names might not be right" echo +else + unsupported_distro=0 fi usage() { -- GitLab From e1be01c5bbf05958d7eab1dafcf096a4324dd078 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 22 Jul 2021 14:26:48 +0100 Subject: [PATCH 2/2] install_base.sh: Make distro package install stage fatal If installing the distro packages fail, there is no point in carrying on as the basic environment cannot be guaranteed, and obscure failures will ensue. --- install_base.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_base.sh b/install_base.sh index d74c35333..3b18da1ff 100755 --- a/install_base.sh +++ b/install_base.sh @@ -123,13 +123,13 @@ install_apt() { fi done else - sudo apt-get install -y "${apt_packages[@]}" + sudo apt-get install -y "${apt_packages[@]}" || exit $? fi } install_pacman() { echo "Installing pacman packages ..." - sudo pacman -Sy --needed --noconfirm "${pacman_packages[@]}" + sudo pacman -Sy --needed --noconfirm "${pacman_packages[@]}" || exit $? } register_pip_extra_requirements() { -- GitLab