diff --git a/scripts/check-kernel-commit b/scripts/check-kernel-commit index 6a612cd..4cf4dde 100755 --- a/scripts/check-kernel-commit +++ b/scripts/check-kernel-commit @@ -5,27 +5,44 @@ usage() echo "Check whether a given list of commit is available in" echo "a given list of branches." echo - echo "Usage: ${0##*/} branches commit_hash..." + echo "Usage: ${0##*/} [branches.conf] commit_hash..." echo echo "Parametes:" - echo " branches: file with the list of branches to be checked" + echo " branches.conf: file with the list of branches to be checked" echo " commit_hash: hash of the commint to be found" } -if [ $# -lt 2 ] ; then +fetch_branches() +{ + local CACHED_BRANCHES=/tmp/branches.conf + local URL="https://kerncvs.suse.de/branches.conf" + local EXPIRE=7 + branches=$CACHED_BRANCHES + if [[ $(find "$CACHED_BRANCHES" -mtime -$EXPIRE -print 2>/dev/null) ]]; then + echo "Using cached $CACHED_BRANCHES" >&2 + return + fi + curl "$URL" >$CACHED_BRANCHES +} + +if [ $# -lt 1 ] ; then usage exit 1 fi branches=$1 -shift; -KBC_CHECK_HASHES="$*" - if [ ! -f "$branches" ] ; then - "Error: Can't find the file with the list of branches: $branches" - exit 1 + echo "Branches file not specified, trying to fetch it..." >&2 + if ! fetch_branches ; then + "Error: Can't find the file with the list of branches: $branches nor fetch it" + exit 1 + fi +else + shift; fi +KBC_CHECK_HASHES="$*" + check_branch() { verbose=0