From d4f0258695c2039cc4bbeb6ed200643c072b22d2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Tue, 2 Nov 2021 14:54:23 +0100 Subject: [PATCH] config/shell/debian: check for add-apt-repository --- .config/shell/debian | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/.config/shell/debian b/.config/shell/debian index 3593ecb..b987fca 100644 --- a/.config/shell/debian +++ b/.config/shell/debian @@ -33,17 +33,6 @@ uma() { fi } -alias aptrepo='sudo add-apt-repository' -_aptrepo_n="$(test "$OSTYPE" != "cygwin" && add-apt-repository --help | grep -- "-n")" -aptrepon() { - test $_aptrepo_n && aptrepo -y -n "$@" || aptrepo -y "$@" -} -aptrepos() { - for repo in "$@" - do aptrepon $repo - done - aptupdate -} alias aptinstall='sudo apt-get install' aptinstalls() { apt-cache show "$1" | grep --color=never '\(Version\|Description\):' @@ -53,13 +42,27 @@ aptinstalli() { apt download $1 sudo dpkg --ignore-depends=$2 -i $1*.deb } -aptrepoinstall() { - aptrepo -yu $1 - if (( $# > 1 )) - then aptinstall "${@:2}" - else aptinstall "${1##*/}" - fi -} + +if which add-apt-repository >/dev/null; then + alias aptrepo='sudo add-apt-repository' + _aptrepo_n="$(add-apt-repository --help | grep -- "-n")" + aptrepon() { + test $_aptrepo_n && aptrepo -y -n "$@" || aptrepo -y "$@" + } + aptrepos() { + for repo in "$@" + do aptrepon $repo + done + aptupdate + } + aptrepoinstall() { + aptrepo -yu $1 + if (( $# > 1 )) + then aptinstall "${@:2}" + else aptinstall "${1##*/}" + fi + } +fi # Gets the download url for the latest release of a package provided via GitHub Releases # Usage: ghrelease USER REPO [PATTERN]