From 76bf44393cbd4de3fac3f4535c8383c329f4e6b4 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Fri, 16 Oct 2020 13:08:28 -0400 Subject: handling of apt sources is intelligenter --- selfpublish.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/selfpublish.sh b/selfpublish.sh index 0d9dd96..eb3c5d9 100644 --- a/selfpublish.sh +++ b/selfpublish.sh @@ -37,12 +37,25 @@ apt_install() as_root apt-get install "$@" } +write_line_once() +{ + local line="$2" target_file="$1" + if grep -qF "$line" "$target_file" + then + return + else + printf %s "$line" | as_root tee -a "$target_file" >/dev/null + fi +} + dpkg_install() { case "$(lsb_release -cs)" in buster) - echo 'deb http://httpredir.debian.org/debian buster-backports main' | - as_root tee -a /etc/apt/sources.list.d/buster-backports.list >/dev/null ;; + apt-cache policy | grep -q 'http://httpredir.debian.org/debian buster-backports/main' || + write_line_once /etc/apt/sources.list.d/buster-backports.list \ + 'deb http://httpredir.debian.org/debian buster-backports main' + ;; esac as_root $SHELL -c "set -$- +e; dpkg -i $*; apt-get -t buster-backports -f install" -- cgit v1.2.3