forked from boot2docker/boot2docker
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate.sh
executable file
·171 lines (152 loc) · 4.54 KB
/
update.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
set -Eeuo pipefail
# http://tinycorelinux.net/
major='14.x'
version='14.0'
mirrors=(
https://distro.ibiblio.org/tinycorelinux
)
# https://www.kernel.org/
kernelBase='6.1'
# https://download.docker.com/linux/static/stable/x86_64/
dockerBase='24.0'
# avoid issues with slow Git HTTP interactions (*cough* sourceforge *cough*)
export GIT_HTTP_LOW_SPEED_LIMIT='100'
export GIT_HTTP_LOW_SPEED_TIME='2'
# ... or servers being down
wget() { command wget --timeout=2 "$@" -o /dev/null; }
tclLatest="$(wget -qO- 'https://distro.ibiblio.org/tinycorelinux/latest-x86_64')"
if [ $tclLatest != $version ]; then
echo "Tiny Core Linux has an update! ($tclLatest)"
exit 1
fi
kernelLatest="$(
wget -qO- 'https://www.kernel.org/releases.json' \
| jq -r '[.releases[] | select(.moniker == "longterm")] | sort_by(.version | split(".") | map(tonumber)) | reverse | .[0].version'
)"
if ! [[ $kernelLatest =~ ^$kernelBase[0-9.]+ ]]; then
echo "Linux Kernel has an update! ($kernelLatest)"
exit 1
fi
dockerLatest="$(
wget -qO- 'https://api.github.com/repos/moby/moby/releases' \
| jq -r '[.[] | select(.prerelease | not)] | sort_by(.tag_name | sub("^v"; "") | split(".") | map(tonumber)) | reverse | .[0].tag_name'
)"
if ! [[ $dockerLatest =~ ^v$dockerBase[0-9.]+ ]]; then
echo "Docker has an update! ($dockerLatest)"
exit 1
fi
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
seds=(
-e 's!^(ENV TCL_MIRRORS).*!\1 '"${mirrors[*]}"'!'
-e 's!^(ENV TCL_MAJOR).*!\1 '"$major"'!'
-e 's!^(ENV TCL_VERSION).*!\1 '"$version"'!'
)
fetch() {
local file
for file; do
local mirror
for mirror in "${mirrors[@]}"; do
if wget -qO- "$mirror/$major/$file"; then
return 0
fi
done
done
return 1
}
arch='x86_64'
rootfs='rootfs64.gz'
rootfsMd5="$(
fetch \
"$arch/archive/$version/distribution_files/$rootfs.md5.txt" \
"$arch/release/distribution_files/$rootfs.md5.txt"
)"
rootfsMd5="${rootfsMd5%% *}"
seds+=(
-e 's!^ENV TCL_ROOTFS.*!ENV TCL_ROOTFS="'"$rootfs"'" TCL_ROOTFS_MD5="'"$rootfsMd5"'"!'
)
kernelVersion="$(
wget -qO- 'https://www.kernel.org/releases.json' \
| jq -r --arg base "$kernelBase" '.releases[] | .version | select(startswith($base + "."))'
)"
seds+=(
-e 's!^(ENV LINUX_VERSION).*!\1 '"$kernelVersion"'!'
)
dockerVersion="$(
wget -qO- 'https://api.github.com/repos/moby/moby/releases' \
| jq -r --arg base "v$dockerBase" '[.[] | .tag_name | select(startswith($base + "."))][0]' \
| sed -e 's!^v!!'
)"
seds+=(
-e 's!^(ENV DOCKER_VERSION).*!\1 '"$dockerVersion"'!'
)
squashfsVersion="$(
git ls-remote --tags 'https://github.com/plougher/squashfs-tools' \
| cut -d/ -f3 \
| cut -d^ -f1 \
| grep -E '^squashfs-tools-[[:digit:]]+' \
| cut -d- -f3- \
| sort -rV \
| head -1
)"
seds+=(
-e 's!^(ENV SQUASHFS_VERSION).*!\1 '"$squashfsVersion"'!'
-e 's!^(# https://github.com/plougher/squashfs-tools/blob/).*(/squashfs-tools/Makefile#L1)$!\1'"$squashfsVersion"'\2!'
)
vboxVersion="$(
wget -qO- 'https://download.virtualbox.org/virtualbox/' \
| grep -oE 'href="[0-9.]+/?"' \
| cut -d'"' -f2 \
| cut -d/ -f1 \
| tail -1
)"
vboxSha256="$(
{
wget -qO- "https://download.virtualbox.org/virtualbox/$vboxVersion/SHA256SUMS" \
|| wget -qO- "https://www.virtualbox.org/download/hashes/$vboxVersion/SHA256SUMS"
} | awk '$2 ~ /^[*]?VBoxGuestAdditions_.*[.]iso$/ { print $1 }'
)"
seds+=(
-e 's!^(ENV VBOX_VERSION).*!\1 '"$vboxVersion"'!'
-e 's!^(ENV VBOX_SHA256).*!\1 '"$vboxSha256"'!'
)
parallelsVersion="$(
command wget -SO- --spider "$(
wget -qO- "https://download.parallels.com/website_links/$(
wget -qO- https://download.parallels.com/website_links/desktop/index.json \
| jq -r 'to_entries | sort_by(.key) | reverse | .[0].value.builds.en_US'
)" \
| jq -r '.[] | select(.category.name | startswith("Parallels Desktop")) | .contents[] | select(.name | startswith("Parallels Desktop")) | .files.DMG'
)" 2>&1 >/dev/null \
| grep -oE 'https://download.parallels.com/desktop/.* \[following]' \
| sed -re 's|.*/([0-9.-]+)/.*|\1|'
)"
seds+=(
-e 's!^(ENV PARALLELS_VERSION).*!\1 '"$parallelsVersion"'!'
)
xenVersion="$(
git ls-remote --tags 'https://github.com/xenserver/xe-guest-utilities' \
| cut -d/ -f3 \
| cut -d^ -f1 \
| grep -E '^v[[:digit:]]+' \
| cut -dv -f2- \
| sort -rV \
| head -1
)"
seds+=(
-e 's!^(ENV XEN_VERSION).*!\1 '"$xenVersion"'!'
)
ctopVersion="$(
git ls-remote --tags 'https://github.com/bcicen/ctop' \
| cut -d/ -f3 \
| cut -d^ -f1 \
| grep -E '^v[[:digit:]]+' \
| cut -dv -f2- \
| sort -rV \
| head -1
)"
seds+=(
-e 's!^(ENV CTOP_VERSION).*!\1 '"$ctopVersion"'!'
)
set -x
sed -ri "${seds[@]}" Dockerfile