Skip to content

Commit

Permalink
Remove backports for releases older than oldstable (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjac committed Apr 16, 2024
1 parent 7da5214 commit 18acb1a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions gpu/install_gpu_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@

set -euxo pipefail

function remove_old_backports {
# This script uses 'apt-get update' and is therefore potentially dependent on
# backports repositories which have been archived. In order to mitigate this
# problem, we will remove any reference to backports repos older than oldstable

# https://github.com/GoogleCloudDataproc/initialization-actions/issues/1157
oldstable=$(curl -s https://deb.debian.org/debian/dists/oldstable/Release | awk '/^Codename/ {print $2}');
stable=$(curl -s https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename/ {print $2}');

matched_files="$(grep -rsil '\-backports' /etc/apt/sources.list*)"
if [[ -n "$matched_files" ]]; then
for filename in "$matched_files"; do
grep -e "$oldstable-backports" -e "$stable-backports" "$filename" || \
sed -i -e 's/^.*-backports.*$//' "$filename"
done
fi
}

function compare_versions_lte {
[ "$1" = "$(echo -e "$1\n$2" | sort -V | head -n1)" ]
}
Expand Down Expand Up @@ -492,6 +510,8 @@ function main() {
exit 1
fi

remove_old_backports

if [[ ${OS_NAME} == debian ]] || [[ ${OS_NAME} == ubuntu ]]; then
export DEBIAN_FRONTEND=noninteractive
execute_with_retries "apt-get update"
Expand Down

0 comments on commit 18acb1a

Please sign in to comment.