forked from HariSekhon/Dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_for_new_versions.sh
executable file
·84 lines (68 loc) · 2.2 KB
/
check_for_new_versions.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2018-10-07 13:53:06 +0100 (Sun, 07 Oct 2018)
#
# https://github.com/harisekhon/Dockerfiles
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
# Check each directory for a check_for_new_version script in each directory and if found run it
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir2="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$srcdir2/.."
. bash-tools/utils.sh
srcdir="$srcdir2"
section "Checks for new upstream software versions"
start_time=$(date +%s)
check_for_new_version(){
local name="$1"
versions="$($name/get_versions || :)"
if [ -z "$versions" ]; then
echo "WARNING: could not determine upstream versions of $name"
fi
latest_version="$(
sed 's/\./ /g' <<< "$versions" |
sort -k1n -k2n -k3n |
sed 's/ /./g' |
tail -n 1 || :
)"
dockerfile_version="$(
egrep -i "^ARG .*${name%-*}.*_VERSION=" "$srcdir/../$name/Dockerfile" |
awk -F= '{print $2}' || :
)"
if [ -z "$dockerfile_version" ]; then
echo "WARNING: $name: failed to determine Dockerfile version"
fi
if [ "$dockerfile_version" = "$latest_version" ]; then
echo "$name up-to-date Dockerfile version / latest upstream version = $dockerfile_version / $latest_version"
else
echo "WARNING: $name: newer version available, current in Dockerfile = $dockerfile_version, latest upstream version = $latest_version"
fi
}
if [ -n "$*" ]; then
echo "Running check for: $@"
echo
for name in $@; do
check_for_new_version "$name"
done
else
echo "Finding and running check for all builds with get_versions"
echo
for dir in *; do
[ -d "$dir" ] || continue
if [ -x "$dir/get_versions" ]; then
#echo -n "$dir/check_for_new_version $dir: "
check_for_new_version "$dir"
fi
done
fi
secs=$(($(date +%s) - $start_time))
echo
section2 "Upstream checks completed in $secs secs"