Adds an option to not attempt to sync the CHECKUPDATES_DB. This provides a way to very quickly get a list of outdated packages provided there is a different mechanism to update CHECKUPDATES_DB already in place such as a crontab entry or systemd.timer. Signed-off-by: Samir Benmendil <me@rmz.io> --- src/checkupdates.sh.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/checkupdates.sh.in b/src/checkupdates.sh.in index 67ff144..027600f 100644 --- a/src/checkupdates.sh.in +++ b/src/checkupdates.sh.in @@ -65,8 +65,8 @@ Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary __EOF__ } -OPT_SHORT='dh' -OPT_LONG=('download' 'help' 'nocolor') +OPT_SHORT='dnh' +OPT_LONG=('download' 'help' 'nocolor' 'norefresh') if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 @@ -74,10 +74,13 @@ fi set -- "${OPTRET[@]}" unset OPT_SHORT OPT_LONG OPTRET +SYNC=1 while :; do case $1 in -d|--download) DOWNLOAD_CACHE=1 ;; + -n|--nosync) + SYNC=0 ;; -h|--help) usage exit 0 ;; @@ -112,10 +115,12 @@ if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then DBPath="@localstatedir@/lib/pacman/" fi -mkdir -p "$CHECKUPDATES_DB" -ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null -if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then - die 'Cannot fetch updates' +if (( ${SYNC} )); then + mkdir -p "$CHECKUPDATES_DB" + ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null + if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then + die 'Cannot fetch updates' + fi fi mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]') -- 2.30.0