Commit bbf488e9 authored by Sam B's avatar Sam B
Browse files

checkupdates: Provide --nosync option



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: Sam B's avatarSamir Benmendil <me@rmz.io>
parent 871ffc94
...@@ -26,6 +26,10 @@ Options ...@@ -26,6 +26,10 @@ Options
*-d, \--download*:: *-d, \--download*::
Download any pending updates to the pacman cache. Download any pending updates to the pacman cache.
*-n, \--nosync*::
Do not sync the temporary database, works best when the temporary database is
update regularly through some other means such as a cronjob or systemd timer.
*-h, \--help*:: *-h, \--help*::
Display syntax and command line options. Display syntax and command line options.
......
...@@ -58,6 +58,7 @@ Usage: ${myname} [options] ...@@ -58,6 +58,7 @@ Usage: ${myname} [options]
Options: Options:
-d, --download download pending updates to the pacman cache. -d, --download download pending updates to the pacman cache.
-n, --nosync do not sync the temporary database.
-h, --help display this help message and exit. -h, --help display this help message and exit.
Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database. Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary database.
...@@ -65,8 +66,8 @@ Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary ...@@ -65,8 +66,8 @@ Note: Export the "CHECKUPDATES_DB" variable to change the path of the temporary
__EOF__ __EOF__
} }
OPT_SHORT='dh' OPT_SHORT='dnh'
OPT_LONG=('download' 'help' 'nocolor') OPT_LONG=('download' 'help' 'nocolor' 'norefresh')
if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
exit 1 exit 1
...@@ -74,10 +75,13 @@ fi ...@@ -74,10 +75,13 @@ fi
set -- "${OPTRET[@]}" set -- "${OPTRET[@]}"
unset OPT_SHORT OPT_LONG OPTRET unset OPT_SHORT OPT_LONG OPTRET
SYNC=1
while :; do while :; do
case $1 in case $1 in
-d|--download) -d|--download)
DOWNLOAD_CACHE=1 ;; DOWNLOAD_CACHE=1 ;;
-n|--nosync)
SYNC=0 ;;
-h|--help) -h|--help)
usage usage
exit 0 ;; exit 0 ;;
...@@ -112,10 +116,12 @@ if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then ...@@ -112,10 +116,12 @@ if [[ -z "$DBPath" ]] || [[ ! -d "$DBPath" ]]; then
DBPath="@localstatedir@/lib/pacman/" DBPath="@localstatedir@/lib/pacman/"
fi fi
mkdir -p "$CHECKUPDATES_DB" if (( ${SYNC} )); then
ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null mkdir -p "$CHECKUPDATES_DB"
if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then ln -s "${DBPath}/local" "$CHECKUPDATES_DB" &> /dev/null
die 'Cannot fetch updates' if ! fakeroot -- pacman -Sy --dbpath "$CHECKUPDATES_DB" --logfile /dev/null &> /dev/null; then
die 'Cannot fetch updates'
fi
fi fi
mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]') mapfile -t updates < <(pacman -Qu --dbpath "$CHECKUPDATES_DB" 2> /dev/null | grep -v '\[.*\]')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment