-
Notifications
You must be signed in to change notification settings - Fork 226
/
Copy pathgsl.sh
executable file
·115 lines (111 loc) · 2.51 KB
/
gsl.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
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "$BASH_SOURCE")"
dir="$(basename "$PWD")"
cd ..
from="$(awk '$1 == "FROM" { print $2; exit }' "$dir/Dockerfile")" # TODO multi-stage build??
fromArches="$(bashbrew remote arches --json "$from" | jq -r '.arches | keys')"
commit="$(git -C "$dir" log -1 --format='format:%H' HEAD -- .)"
export fromArches commit dir
exec jq -r -L "$dir/../.libs" '
include "lib"
;
(env.fromArches | fromjson) as $fromArches
| (
[
$fromArches,
(.runc.arches | map_values(select(.dpkgArch)) | keys),
empty
]
| intersection
) as $intArches
| [
{
Maintainers: "Tianon Gravi <[email protected]> (@tianon)",
GitRepo: "https://github.com/tianon/dockerfiles.git",
GitCommit: env.commit,
Directory: env.dir,
},
(
(
[
.variants[] as $variant
| {
key: $variant,
value: (
if $variant != "" then .[$variant] else . end
| {
variant: $variant,
version: .version,
arches: (
[
$intArches,
(.arches | map_values(select(.dpkgArch)) | keys),
empty
]
| intersection
),
}
),
}
]
| from_entries
)
| if (.rc.version | split(".-") | tonumber? // .) <= (.[""].version | split(".-") | tonumber? // .) then
# if the RC is not newer than the current stable, skip it
del(.rc)
else . end
| map(
.variant as $variant
| {
Tags: (
.version as $version
| if $variant == "dev" then
[]
else
$version
| [ scan("(?:[.-]+|^)[^.-]*") ]
| reduce .[] as $p ([];
if length > 0 then
[ .[0] + $p, .[] ]
else [ $p ] end
)
end
| . + [
if $variant == "" then
"latest"
elif index($variant) | not then
$variant
else empty end
]
| if $version | startswith("1.7.") then
# backwards compatible "c8dind" tags for 1.7
. += map(
. + "-c8dind"
| sub("^latest-"; "")
)
else . end
),
Architectures: (.arches | join(", ")),
File: ("Dockerfile" + if $variant != "" then "." + $variant else "" end),
}
)
| reduce .[] as $e ([];
[ .[].Tags[] ] as $tags
| . += [ $e | .Tags -= $tags ]
)
| .[]
| .Tags |= join(", ")
)
]
| .[0].File as $globalFile
| map(
if .File == "Dockerfile" and ($globalFile | not) then
del(.File)
else . end
| to_entries
| map(.key + ": " + .value)
| join("\n")
)
| join("\n\n")
' "$dir/versions.json"