From 0b454dda1207c24ba19d51d7cd5839ea3c349f67 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 16 Dec 2021 16:01:15 -0800 Subject: [PATCH] install: Try apt-get update if the Ubuntu universe check fails. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a system where ‘apt-get update’ has never been run, ‘apt-cache policy’ may show no repositories at all. Try to correct this with ‘apt-get update’ before giving up. Signed-off-by: Anders Kaseorg --- scripts/lib/install | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/lib/install b/scripts/lib/install index 2b87089357..3192de2905 100755 --- a/scripts/lib/install +++ b/scripts/lib/install @@ -232,8 +232,12 @@ EOF ;; esac -if [ "$os_id" = ubuntu ] && ! apt-cache policy \ - | grep -q "^ release v=$os_version_id,o=Ubuntu,a=$os_version_codename,n=$os_version_codename,l=Ubuntu,c=universe"; then +has_universe() { + apt-cache policy \ + | grep -q "^ release v=$os_version_id,o=Ubuntu,a=$os_version_codename,n=$os_version_codename,l=Ubuntu,c=universe" +} + +if [ "$os_id" = ubuntu ] && ! has_universe && ! { apt-get update && has_universe; }; then set +x cat <<'EOF'