From: Ian Kelling Date: Sat, 4 Sep 2021 19:14:11 +0000 (-0400) Subject: minor improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=da54fb345cff92b674bad5df4febf4484bb740d7;p=distro-functions minor improvements --- diff --git a/src/identify-distros b/src/identify-distros index 9c2221f..67d9608 100644 --- a/src/identify-distros +++ b/src/identify-distros @@ -91,9 +91,34 @@ EOF fi done < <(echo "$policy" | sed -rn "$expression" | sort -rn || [[ $? == 141 ]]) echo "$shortest" - } +# formatted for use in pfile in brc +positive-origins() { + isdeb || return 0 + local archive expression pri name highpri shortest + local policy="${1:-$(apt-cache policy)}" || return $? + # a = archive + # n = codename + # o = origin + # c = component (licensing component) + # l = label (Debian{,-Security,-Updates}) + read -rd '' expression < 0 )); then + if [[ ! $origins ]]; then + origins=$name + else + origins+=,$name + fi + fi + done < <(echo "$policy" | sed -rn "$expression" | sort -rn || [[ $? == 141 ]]) + echo $origins +} isdebian-testing() { [[ $(debian-archive) == testing ]] @@ -118,6 +143,9 @@ debian-codename-compat() { etiona) echo bionic ;; + nabia) + echo focal + ;; *) echo $n ;; diff --git a/src/package-manager-abstractions b/src/package-manager-abstractions index dece848..0bd5389 100644 --- a/src/package-manager-abstractions +++ b/src/package-manager-abstractions @@ -100,7 +100,7 @@ elif command -v apt-get &>/dev/null; then limittime=$(( now - 60*60*2 )) for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do if [[ -r $f ]]; then - t=$(stat -c %Y $f ) + t=$(stat -c %Y $f ) if (( t > limittime )); then limittime=$t fi @@ -113,11 +113,15 @@ elif command -v apt-get &>/dev/null; then pi() { pcheck "$@" || return 0 pupdate - local s; [[ $EUID != 0 ]] && s=sudo if [[ $- != *i* ]]; then - echo pi "$@" + echo pi "$*" + fi + if [[ $EUID == 0 ]]; then + DEBIAN_FRONTEND=noninteractive apt-get -y install --purge --auto-remove "$@" + else + sudo DEBIAN_FRONTEND=noninteractive apt-get -y install --purge --auto-remove "$@" fi - $s $PI_PREFIX apt-get -y install --purge --auto-remove "$@" + } pi-nostart() { @@ -125,18 +129,27 @@ elif command -v apt-get &>/dev/null; then pcheck "$@" || return 0 plock-wait pupdate - local s; [[ $EUID != 0 ]] && s=sudo local f=/usr/sbin/policy-rc.d - $s dd of=$f 2>/dev/null </dev/null </dev/null </dev/null; then # ucfq $file - if [[ $file == */* ]]; then - apt-file find -x "$file"\$ + if [[ $file == /* ]]; then + dpkg -S "$file" + elif [[ $file == */* ]]; then + apt-file $arg find -x "$file"\$ else - apt-file find -x /"$file"\$ + apt-file $arg find -x /"$file"\$ update-alternatives --list "$file" 2>/dev/null fi }