From b8bffd625cbf589079fcfd9ba1a37c91fdc7f99b Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Mon, 19 Sep 2022 12:40:44 -0700 Subject: [PATCH] Fix: Update Ubuntu installs on aarch64 Do not change package mirror for aarch64 systems as this breaks since most mirrors do not carry the packages Change-Id: I800e83295bba8b55e9376fc735cd9f7b21fddf32 Signed-off-by: Andrew Grimberg --- provision/install-python.sh | 52 +++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/provision/install-python.sh b/provision/install-python.sh index 5817efb..76a83aa 100755 --- a/provision/install-python.sh +++ b/provision/install-python.sh @@ -38,6 +38,32 @@ function is_centos8() return 1 } +# Select fastest mirror on Ubuntu systems +function select_fastest() +{ + echo "Install netselect from debian to choose a mirror." + apt install wget -y + wget "http://ftp.au.debian.org/debian/pool/main/n/netselect/${NETSELECT_DEB}" + dpkg -i "${NETSELECT_DEB}" + apt install netselect -y + + available_mirrors=$(wget -qO - mirrors.ubuntu.com/mirrors.txt) + using_mirror=$(grep deb /etc/apt/sources.list | grep -v \# |head -1 | awk '{print $2}') + # SC2086 -- Double quote to prevent globbing + # Do not double quote around ${available_mirrors} since that breaks + # functionality + # shellcheck disable=SC2086 + fastest_mirror=$(sudo netselect -s 1 -t 40 ${available_mirrors} 2> /dev/null | awk '{print $2}') + RESULT=$? + if [ $RESULT -eq 0 ]; then + sed -i "s#${using_mirror}#${fastest_mirror}#" /etc/apt/sources.list + echo "Old mirror : ${using_mirror}" + echo "New mirror : ${fastest_mirror}" + else + echo "NOTE: Unable to select fastest mirror" + fi +} + # Ubuntu does not come with Python by default so we need to install it if is_ubuntu; then # Use netselect to choose a package mirror to install python-minimal in a @@ -50,37 +76,17 @@ if is_ubuntu; then case $_ARCH in x86_64) NETSELECT_DEB="netselect_0.3.ds1-28+b1_amd64.deb" + echo "NetSelect version to install is ${NETSELECT_DEB}" + select_fastest ;; aarch64) - NETSELECT_DEB="netselect_0.3.ds1-28+b1_arm64.deb" + #NETSELECT_DEB="netselect_0.3.ds1-28+b1_arm64.deb" ;; *) echo "Unknown arch ${_ARCH}. Exiting..." exit 1 esac - echo "NetSelect version to install is ${NETSELECT_DEB}" - - echo "Install netselect from debian to choose a mirror." - apt install wget -y - wget http://ftp.au.debian.org/debian/pool/main/n/netselect/${NETSELECT_DEB} - dpkg -i ${NETSELECT_DEB} - apt install netselect -y - - available_mirrors=$(wget -qO - mirrors.ubuntu.com/mirrors.txt) - using_mirror=$(grep deb /etc/apt/sources.list | grep -v \# |head -1 | awk '{print $2}') -## SC2086 -- Double quote to prevent globbing -## I can not have double quote around ${available_mirrors} since that breaks functionality -# shellcheck disable=SC2086 - fastest_mirror=$(sudo netselect -s 1 -t 40 ${available_mirrors} 2> /dev/null | awk '{print $2}') - RESULT=$? - if [ $RESULT -eq 0 ]; then - sed -i "s#${using_mirror}#${fastest_mirror}#" /etc/apt/sources.list - echo "Old mirror : ${using_mirror}" - echo "New mirror : ${fastest_mirror}" - else - echo "NOTE: Unable to select fastest mirror" - fi echo "Update and Remove unwanted packages..." apt clean all -y -- 2.16.6