From a6fd5082bfbe1d4f549c7cb3246b7b238f69874c Mon Sep 17 00:00:00 2001 From: Steven Jackson Date: Thu, 8 Dec 2016 23:28:28 +0000 Subject: [PATCH] add support for pacman's --needed flag this prevents up to date packages from being reinstalled. --- packer | 13 ++++++++++++- packer.8 | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packer b/packer index 3ca650f..6278831 100644 --- a/packer +++ b/packer @@ -67,6 +67,7 @@ usage() { echo ' --noedit - do not prompt to edit files' echo ' --quickcheck - check for updates and exit' echo ' --auronly - only do actions for aur' + echo ' --needed - do not reinstall targets that are already up-to-date' echo ' --devel - update devel packages during -Su' echo ' --skipinteg - when using makepkg, do not check md5s' echo ' --preview - edit pkgbuild before sourcing' @@ -411,11 +412,20 @@ installhandling() { if existsinlocal "$pkg"; then localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)" if ! aurversionisnewer "$pkg" "$localversion"; then - echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling" + if [[ $needed ]]; then + aurtargets=${aurtargets[@]/$pkg} + echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- skipping" + else + echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling" + fi fi fi done + if [[ -z $aurtargets ]]; then + exit + fi + # Echo warning if packages are out of date for pkg in "${aurtargets[@]}" "${aurdepends[@]}"; do if isoutofdate "$pkg"; then @@ -528,6 +538,7 @@ while [[ $1 ]]; do '--noconfirm') noconfirm='1' PACOPTS+=("--noconfirm");; '--noedit') noedit='1' ;; '--auronly') auronly='1' ;; + '--needed') needed=1 ; PACOPTS+=("--needed") ;; '--quickcheck') quickcheck='1' ;; '--devel') devel='1' ;; '--skipinteg') MAKEPKGOPTS="--skipinteg" ;; diff --git a/packer.8 b/packer.8 index 23aefde..1739b6a 100644 --- a/packer.8 +++ b/packer.8 @@ -84,6 +84,11 @@ Check for updates and exit\&. Only perform commands for the AUR\&. .RE .PP +\fB\-\-needed\fR +.RS 4 +Do not reinstall the targets that are already up-to-date.\&. +.RE +.PP \fB\-\-devel\fR .RS 4 Update development packages\&. (cvs, git\&...)