-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate-index.sh
executable file
·141 lines (117 loc) · 4.31 KB
/
generate-index.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
#!/usr/bin/env bash
set -Eeuo pipefail
tmp="$(mktemp -d)"
trap "$(printf 'rm -rf %q' "$tmp")" EXIT
cd "$tmp"
wget -qO debian 'https://github.com/docker-library/official-images/raw/master/library/debian'
export BASHBREW_LIBRARY="$PWD"
gitHubUrl="$(bashbrew cat --format '{{ .Manifest.Global.GitRepo }}' debian)"
gitHubUrl="${gitHubUrl%.git}"
rawGitUrl="$gitHubUrl/raw"
arches=( $(
bashbrew cat --format '
{{- range .Entries -}}
{{- .Architectures | join "\n" -}}
{{- "\n" -}}
{{ end }}
' debian | sort -u
) )
declare -A archCommits=()
for arch in "${arches[@]}"; do
commit="$(bashbrew --arch "$arch" cat --format '{{ .Manifest.Global.ArchGitCommit arch }}' debian)"
archCommits[$arch]="$commit"
done
_wget() {
wget -qO- -o /dev/null "$@"
}
suites=()
declare -A archSuites=() suiteArches=()
declare -A sharedMeta=(
[debuerreotype-epoch]=
[debuerreotype-version]=
[serial]=
[snapshot-url]=
)
declare -A dpkgArches=()
for arch in "${arches[@]}"; do
commit="${archCommits[$arch]}"
archSuites[$arch]="$(_wget "$rawGitUrl/$commit/suites")"
for suite in ${archSuites[$arch]}; do
if [ -z "${suiteArches[$suite]:-}" ]; then
suites+=( "$suite" )
fi
suiteArches[$suite]+=" $arch"
done
dpkgArches[$arch]="$(_wget "$rawGitUrl/$commit/dpkg-arch")"
for metaKey in "${!sharedMeta[@]}"; do
archMeta="$(_wget "$rawGitUrl/$commit/$metaKey" || :)"
if [ "$metaKey" = 'snapshot-url' ]; then
archMeta="${archMeta//debian-ports/debian}" # normalize "debian-ports" (so ports arches still match and so we clearly prefer non-ports URLs)
fi
: "${sharedMeta[$metaKey]:=$archMeta}"
if [ "${sharedMeta[$metaKey]}" != "$archMeta" ]; then
echo >&2 "error: '$arch' has inconsistent $metaKey '$archMeta'! (from '${sharedMeta[$metaKey]}')"
exit 1
fi
done
echo >&2 "- $arch: $commit"
done
echo >&2
# prints "$2$1$3$1...$N"
join() {
local sep="$1"; shift
local out; printf -v out "${sep//%/%%}%s" "$@"
echo "${out#$sep}"
}
cat <<-EOH
---
layout: default
---
# Debian Docker Image Checksums
This page includes checksums and reproducibility information of generated rootfs tarballs for [the latest version of the published Debian Docker official image](https://hub.docker.com/_/debian).
All the artifacts referenced on this page were built with [debuerreotype](https://github.com/debuerreotype/debuerreotype) version ${sharedMeta[debuerreotype-version]} (although likely with a newer commit of \`debian.sh\` from [the \`examples/\` directory](https://github.com/debuerreotype/debuerreotype/tree/master/examples)).
EOH
echo
echo '| dpkg | bashbrew | debootstrap | artifacts |'
echo '| - | - | - | - |'
for arch in "${arches[@]}"; do
dpkgArch="${dpkgArches[$arch]}"
archCommit="${archCommits[$arch]}"
artifactsLink="$gitHubUrl/tree/$archCommit"
debootstrap=
for archSuite in ${archSuites[$arch]}; do
if debootstrap="$(_wget "$rawGitUrl/$archCommit/$archSuite/rootfs.debootstrap-version")" && [ -n "$debootstrap" ]; then
break
fi
done
echo "| \`$dpkgArch\` | \`$arch\` | \`${debootstrap:-unknown}\` | [$archCommit]($artifactsLink) |"
done
echo
echo "- Build Command: \`./examples/debian-all.sh --arch <dpkg-arch> out/ '@${sharedMeta[debuerreotype-epoch]}'\`"
echo "- Snapshot URL: [${sharedMeta[snapshot-url]}](${sharedMeta[snapshot-url]%/}/)"
for version in "${suites[@]}"; do
versionArches=( ${suiteArches[$version]} )
tokenArch="${versionArches[0]}"
if ! _wget --spider "$rawGitUrl/${archCommits[$tokenArch]}/$version/rootfs.tar.xz"; then
# likely "experimental" or "rc-buggy" (and thus Dockerfile-only -- no generated rootfs)
continue
fi
uniqueTag="$version-${sharedMeta[serial]}"
tags="$(bashbrew list "debian:$uniqueTag")"
tags="$(join '`, `' $tags)"
tags='`'"$tags"'`'
echo
echo "## Image: $tags"
echo
echo '| dpkg | bashbrew | artifacts | SHA256 (`rootfs.tar.xz`) |'
echo '| - | - | - | - |'
for arch in "${versionArches[@]}"; do
archCommit="${archCommits[$arch]}"
dpkgArch="${dpkgArches[$arch]}"
rootfsSha256="$(_wget "$rawGitUrl/$archCommit/$version/rootfs.tar.xz.sha256")"
echo "| \`$dpkgArch\` | \`$arch\` | [link]($gitHubUrl/tree/$archCommit/$version) | \`$rootfsSha256\` |"
done
echo
echo "- Docker Hub: [\`debian:$uniqueTag\`](https://hub.docker.com/_/debian/tags?name=$uniqueTag)"
echo "- Build Command: \`./examples/debian.sh --arch <dpkg-arch> out/ '$version' '@${sharedMeta[debuerreotype-epoch]}'\`"
done