X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=src%2Fpackage-manager-abstractions;h=0f4815a480587f58d3c3d18b731370c679d48b1d;hb=33796378c9b8fe2d6e30226fe0a977254b3246e8;hp=9311038c4f0b616d6b7ad1837d25a413edbfb3ff;hpb=7fa28f7a5bc32b0e2de513fa7d9ae7c245c09c05;p=distro-functions diff --git a/src/package-manager-abstractions b/src/package-manager-abstractions index 9311038..0f4815a 100644 --- a/src/package-manager-abstractions +++ b/src/package-manager-abstractions @@ -26,7 +26,7 @@ if command -v yum &> /dev/null; then $s yum -y install "$@" } # package find - pf() { + pfd() { local s; [[ $EUID != 0 ]] && s=sudo $s yum search "$@" } @@ -88,22 +88,40 @@ elif command -v apt-get &>/dev/null; then esac } pupdate() { - local s f; [[ $EUID != 0 ]] && s=sudo + local now t s f cachetime limittime; [[ $EUID != 0 ]] && s=sudo # update package list if its more than an 2 hours old f=/var/cache/apt/pkgcache.bin - if [[ ! -r $f ]] \ - || (( $(( $(date +%s) - $(stat -c %Y $f ) )) > 60*60*2 )); then + if [[ -r $f ]]; then + cachetime=$(stat -c %Y $f ) + else + cachetime=0 + fi + now=$(date +%s) + 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 ) + if (( t > limittime )); then + limittime=$t + fi + fi + done + if (( cachtime > limittime )); then $s apt-get update fi } 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() { @@ -111,24 +129,35 @@ 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" else - apt-file find -x /"$file"\$ - update-alternatives --list "$file" 2>/dev/null + if ! $all; then + arg=(--filter-origins "$(positive-origins)") + fi + if [[ $file == /* ]]; then + apt-file "${arg[@]}" find -x /"$file"\$ + update-alternatives --list "$file" 2>/dev/null + else + apt-file "${arg[@]}" find -x "$file"\$ + fi fi } pkgfiles() { @@ -205,7 +247,7 @@ elif command -v pacman &>/dev/null; then pi() { pacaur -S --noconfirm --needed --noedit "$@" } - pf() { + pfd() { pacaur -Ss "$@" } pu() {