forked from ungleich-public/cdist
Support pacman with --maxage parameter
This commit is contained in:
parent
b12c02138d
commit
f143a70463
4 changed files with 30 additions and 19 deletions
|
@ -27,6 +27,13 @@ case "$type" in
|
|||
echo 0
|
||||
fi
|
||||
;;
|
||||
pacman)
|
||||
if [ -d "/var/lib/pacman/sync" ]; then
|
||||
echo $(($(date +"%s")-$(stat --format '%Y' /var/lib/pacman/sync)))
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
;;
|
||||
*) echo "Your specified type ($type) is currently not supported." >&2
|
||||
echo "Please contribute an implementation for it if you can." >&2
|
||||
;;
|
||||
|
|
|
@ -22,32 +22,33 @@
|
|||
#
|
||||
|
||||
type=$(cat "$__object/explorer/type")
|
||||
currage="$(cat "$__object/explorer/currage")"
|
||||
if [ -f "$__object/parameter/maxage" ]; then
|
||||
maxage="$(cat "$__object/parameter/maxage")"
|
||||
currage="$(cat "$__object/explorer/currage")"
|
||||
fi
|
||||
|
||||
if [ -n "$maxage" ] && [ "$type" != "apt" ]; then
|
||||
echo "ERROR: \"--maxage\" only supported for \"apt\" pkg-manager." >&2
|
||||
exit 1
|
||||
if [ -n "$maxage" ]; then
|
||||
if [ "$type" != "apt" -a "$type" != "pacman" ]; then
|
||||
echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2
|
||||
exit 1
|
||||
elif [ $currage -lt $maxage ]; then
|
||||
exit 0 # no need to update
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
case "$type" in
|
||||
yum) ;;
|
||||
apt) if [ -n "$maxage" ]; then
|
||||
## check if we need to update:
|
||||
if [ $currage -ge $maxage ]; then
|
||||
echo "apt-get --quiet update"
|
||||
echo "apt-cache updated (age was: $currage)" >> "$__messages_out"
|
||||
fi
|
||||
else
|
||||
echo "apt-get --quiet update"
|
||||
echo "apt-cache updated (age was: $currage)" >> "$__messages_out"
|
||||
fi
|
||||
;;
|
||||
pacman) echo "pacman --noprogressbar --sync --refresh" ;;
|
||||
apt)
|
||||
echo "apt-get --quiet update"
|
||||
echo "apt-cache updated (age was: $currage)" >> "$__messages_out"
|
||||
;;
|
||||
pacman)
|
||||
echo "pacman --noprogressbar --sync --refresh"
|
||||
echo "pacman package database synced (age was: $currage)" >> "$__messages_out"
|
||||
;;
|
||||
*)
|
||||
echo "Don't know how to manage packages on: $os" >&2
|
||||
echo "Don't know how to manage packages for type: $type" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -28,8 +28,8 @@ type
|
|||
* pacman for Arch Linux
|
||||
|
||||
maxage
|
||||
Available for package manager apt, max time in seconds since last update.
|
||||
Repo update is skipped if maxage is not reached yet.
|
||||
Available for package manager apt and pacman, max time in seconds since
|
||||
last update. Repo update is skipped if maxage is not reached yet.
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
|
@ -51,6 +51,7 @@ EXAMPLES
|
|||
|
||||
# Only update every hour:
|
||||
__package_update_index --maxage 3600 --type apt
|
||||
|
||||
# same as above (on apt-type systems):
|
||||
__package_update_index --maxage 3600
|
||||
|
||||
|
@ -58,6 +59,7 @@ AUTHORS
|
|||
-------
|
||||
| Ricardo Catalinas Jiménez <jimenezrick--@--gmail.com>
|
||||
| Thomas Eckert <tom--@--it-eckert.de>
|
||||
| Stu Zhao <z12y12l12--@--gmail.com>
|
||||
|
||||
|
||||
COPYING
|
||||
|
|
|
@ -6,6 +6,7 @@ next:
|
|||
* Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej)
|
||||
* Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux)
|
||||
* Type __package_update_index: Fix error when using OS not using apt (Stu Zhao)
|
||||
* Type __package_update_index: Support --maxage for type pacman (Stu Zhao)
|
||||
|
||||
4.10.1: 2018-06-21
|
||||
* Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak)
|
||||
|
|
Loading…
Reference in a new issue