forked from GoogleContainerTools/distroless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateWorkspaceSnapshots.sh
executable file
·171 lines (151 loc) · 10.8 KB
/
updateWorkspaceSnapshots.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
#/bin/sh
set -o errexit
set -o xtrace
cp checksums.bzl checksums.bzl~
cp package_bundle_amd64_debian10.versions package_bundle_amd64_debian10.versions~
cp package_bundle_arm_debian10.versions package_bundle_arm_debian10.versions~
cp package_bundle_arm64_debian10.versions package_bundle_arm64_debian10.versions~
cp package_bundle_s390x_debian10.versions package_bundle_s390x_debian10.versions~
cp package_bundle_ppc64le_debian10.versions package_bundle_ppc64le_debian10.versions~
cp package_bundle_amd64_debian11.versions package_bundle_amd64_debian11.versions~
cp package_bundle_arm_debian11.versions package_bundle_arm_debian11.versions~
cp package_bundle_arm64_debian11.versions package_bundle_arm64_debian11.versions~
cp package_bundle_s390x_debian11.versions package_bundle_s390x_debian11.versions~
cp package_bundle_ppc64le_debian11.versions package_bundle_ppc64le_debian11.versions~
YEAR=`date +"%Y"`
MONTH=`date +"%m"`
# Fetch all the latest snapshot versions for the current month
DEBIAN_SNAPSHOT=`curl -s "https://snapshot.debian.org/archive/debian/?year=$YEAR;month=$MONTH" 2>&1 | grep -oE "[0-9]+T[0-9]+Z" | tail -n1`
DEBIAN_SECURITY_SNAPSHOT=`curl -s "https://snapshot.debian.org/archive/debian-security/?year=$YEAR;month=$MONTH" 2>&1 | grep -oE "[0-9]+T[0-9]+Z" | tail -n1`
if [ -z "$DEBIAN_SNAPSHOT" ]
then
echo "No debian snapshot version found";
exit 0
fi
if [ -z "$DEBIAN_SECURITY_SNAPSHOT" ]
then
echo "No debian security snapshot version found";
exit 0
fi
cat > checksums.bzl <<EOF
# WARNING!!!
# DO NOT MODIFY THIS FILE DIRECTLY.
# TO GENERATE THIS RUN: ./updateWorkspaceSnapshots.sh
BASE_ARCHITECTURES = ["amd64", "arm64"]
# Exceptions:
# - s390x doesn't have libunwind8.
# https://github.com/GoogleContainerTools/distroless/pull/612#issue-500157699
# - ppc64le doesn't have stretch security-channel.
# https://github.com/GoogleContainerTools/distroless/pull/637#issuecomment-728139611
# - arm needs someone with available hardware to generate:
# //experimental/python2.7/ld.so.arm.cache
ARCHITECTURES = BASE_ARCHITECTURES + ["arm", "s390x", "ppc64le"]
VERSIONS = [
("debian10", "buster"),
("debian11", "bullseye"),
]
DEBIAN_SNAPSHOT = "$DEBIAN_SNAPSHOT"
DEBIAN_SECURITY_SNAPSHOT = "$DEBIAN_SECURITY_SNAPSHOT"
SHA256s = {
"amd64": {
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster-updates/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/buster/updates/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian11": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye-updates/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/bullseye-security/main/binary-amd64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"arm": {
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster-updates/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/buster/updates/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian11": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye-updates/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/bullseye-security/main/binary-armhf/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"arm64": {
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster-updates/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/buster/updates/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian11": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye-updates/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/bullseye-security/main/binary-arm64/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"s390x": {
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster-updates/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/buster/updates/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian11": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye-updates/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/bullseye-security/main/binary-s390x/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"ppc64le": {
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster-updates/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/buster/updates/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian11": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/bullseye-updates/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/bullseye-security/main/binary-ppc64el/Packages.xz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
}
EOF
# Rebuild package set
bazel clean
bazel build //package_manager:dpkg_parser.par
bazel build @package_bundle_amd64_debian10//file:packages.bzl
bazel build @package_bundle_arm_debian10//file:packages.bzl
bazel build @package_bundle_arm64_debian10//file:packages.bzl
bazel build @package_bundle_s390x_debian10//file:packages.bzl
bazel build @package_bundle_ppc64le_debian10//file:packages.bzl
bazel build @package_bundle_amd64_debian11//file:packages.bzl
bazel build @package_bundle_arm_debian11//file:packages.bzl
bazel build @package_bundle_arm64_debian11//file:packages.bzl
bazel build @package_bundle_s390x_debian11//file:packages.bzl
bazel build @package_bundle_ppc64le_debian11//file:packages.bzl
# Check if any of the version lock files are updated
if diff -w package_bundle_amd64_debian10.versions package_bundle_amd64_debian10.versions~ &&
diff -w package_bundle_arm_debian10.versions package_bundle_arm_debian10.versions~ &&
diff -w package_bundle_arm64_debian10.versions package_bundle_arm64_debian10.versions~ &&
diff -w package_bundle_s390x_debian10.versions package_bundle_s390x_debian10.versions~ &&
diff -w package_bundle_ppc64le_debian10.versions package_bundle_ppc64le_debian10.versions~ &&
diff -w package_bundle_amd64_debian11.versions package_bundle_amd64_debian11.versions~ &&
diff -w package_bundle_arm_debian11.versions package_bundle_arm_debian11.versions~ &&
diff -w package_bundle_arm64_debian11.versions package_bundle_arm64_debian11.versions~ &&
diff -w package_bundle_s390x_debian11.versions package_bundle_s390x_debian11.versions~ &&
diff -w package_bundle_ppc64le_debian11.versions package_bundle_ppc64le_debian11.versions~; then
echo "No changes detected to package_bundle versions."
mv checksums.bzl~ checksums.bzl
mv package_bundle_amd64_debian10.versions~ package_bundle_amd64_debian10.versions
mv package_bundle_arm_debian10.versions~ package_bundle_arm_debian10.versions
mv package_bundle_arm64_debian10.versions~ package_bundle_arm64_debian10.versions
mv package_bundle_s390x_debian10.versions~ package_bundle_s390x_debian10.versions
mv package_bundle_ppc64le_debian10.versions~ package_bundle_ppc64le_debian10.versions
mv package_bundle_amd64_debian11.versions~ package_bundle_amd64_debian11.versions
mv package_bundle_arm_debian11.versions~ package_bundle_arm_debian11.versions
mv package_bundle_arm64_debian11.versions~ package_bundle_arm64_debian11.versions
mv package_bundle_s390x_debian11.versions~ package_bundle_s390x_debian11.versions
mv package_bundle_ppc64le_debian11.versions~ package_bundle_ppc64le_debian11.versions
else
echo "Changes detected to package_bundle version files. Please update snapshots."
rm *~
fi