summaryrefslogtreecommitdiff
path: root/checkVersions
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-04-12 09:40:24 +0200
committerErich Eckner <git@eckner.net>2016-04-12 09:45:19 +0200
commitf074db5a8818fafc491f3c62238432d024e37bcb (patch)
tree86d2e132df74b7e91e8c901b58479c31bd3d3337 /checkVersions
parent158d1cd7a748a712128b76f3143d56f77e6b6664 (diff)
downloadarchlinuxewe-f074db5a8818fafc491f3c62238432d024e37bcb.tar.xz
schneller Variante von checkVersions
Diffstat (limited to 'checkVersions')
-rwxr-xr-xcheckVersions80
1 files changed, 72 insertions, 8 deletions
diff --git a/checkVersions b/checkVersions
index 97a41973e..7f6c0e4d1 100755
--- a/checkVersions
+++ b/checkVersions
@@ -1,13 +1,70 @@
#!/bin/bash
me="$(readlink -f $0)"
-cd $(dirname ${me})
+cd $(dirname "${me}")
+versionenDatei="/var/cache/$(basename "$(dirname "${me}")").lastVersions"
+
+usage() {
+ >&2 echo 'Verwendung: '
+ >&2 echo " $0"' [-f|--force]'
+ >&2 echo ' -f|--force: prüfe Versionen unhabhängig von Zeit der letzten Prüfung'
+ exit 1
+}
+
+[ ! -r "${versionenDatei}" ] && force=true || force=false
+
+eval set -- "$(getopt -o f --long force -n "$(basename "$0")" -- "$@" || echo "usage")"
+args=("$@")
+
+while true
+do
+ case $1 in
+ -f|--force)
+ force=true
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ >&2 echo "FEHLER: Verstehe Option \"$1\" doch nicht! Ich beende."
+ rm -rf "${tmpDir}"
+ usage
+ esac
+done
+
+versionenErmitteln=${force}
+[ $(head -n1 "${versionenDatei}") -le $[$(date "+%s")-300] ] && versionenErmitteln=true
+versionenSchreiben=${versionenErmitteln}
+[ ! -w "${versionenDatei}" ] && versionenSchreiben=false
if [ $# -eq 0 ]
then
- ${me} $(echo */PKGBUILD | tr " " "\n" | sed "s|/PKGBUILD||")
- exit $?
-elif [ $# -eq 1 ]
+ if ${versionenSchreiben}
+ then
+ tmpFile="$(mktemp /tmp/versionen.XXXXXX)"
+ date "+%s" > "${tmpFile}"
+ set -o pipefail
+ ${me} "${args[@]}" $(echo */PKGBUILD | tr " " "\n" | sed "s|/PKGBUILD||") | tee -a "${tmpFile}"
+ err=$?
+ set +o pipefail
+ cat "${tmpFile}" > "${versionenDatei}"
+ rm "${tmpFile}"
+ elif ! ${versionenErmitteln}
+ then
+ cat "${versionenDatei}" | \
+ ( \
+ read dummy
+ cat
+ )
+ err=$?
+ else
+ ${me} "${args[@]}" $(echo */PKGBUILD | tr " " "\n" | sed "s|/PKGBUILD||")
+ err=$?
+ fi
+ exit ${err}
+elif [ $# -eq 1 ] && ${versionenErmitteln}
then
. $1/PKGBUILD
@@ -188,18 +245,25 @@ then
if ! ${srcKnown}
then
- echo "Unknown src: '${source[@]}'"
+ echo "$1: Unknown src: '${source[@]}'"
exit 1
fi
if [ ! "${pkgver}" == "${remVer}" ]
then
- echo "${pkgname} ist neuer verfügbar: ${remVer} vs. ${pkgver}"
+ echo "$1: ${pkgname} ist neuer verfügbar: ${remVer} vs. ${pkgver}"
fi
-else
- echo $* | \
+elif ${versionenErmitteln}
+then
+ echo "$@" | \
tr " " "\n" | \
parallel -j0 $0 {} \;
exit $?
+
+else
+ for s in "$@"
+ do
+ grep "^${s}:" "${versionenDatei}"
+ done
fi