This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
forked from GoogleContainerTools/distroless
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathupdateWorkspaceSnapshots.sh
executable file
·172 lines (154 loc) · 11.5 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
172
#/bin/sh
set -o errexit
set -o xtrace
cp checksums.bzl checksums.bzl~
cp package_bundle_amd64_debian9.versions package_bundle_amd64_debian9.versions~
cp package_bundle_amd64_debian10.versions package_bundle_amd64_debian10.versions~
cp package_bundle_arm_debian9.versions package_bundle_arm_debian9.versions~
cp package_bundle_arm_debian10.versions package_bundle_arm_debian10.versions~
cp package_bundle_arm64_debian9.versions package_bundle_arm64_debian9.versions~
cp package_bundle_arm64_debian10.versions package_bundle_arm64_debian10.versions~
cp package_bundle_s390x_debian9.versions package_bundle_s390x_debian9.versions~
cp package_bundle_s390x_debian10.versions package_bundle_s390x_debian10.versions~
cp package_bundle_ppc64le_debian9.versions package_bundle_ppc64le_debian9.versions~
cp package_bundle_ppc64le_debian10.versions package_bundle_ppc64le_debian10.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 = [
("debian9", "stretch"),
("debian10", "buster"),
]
DEBIAN_SNAPSHOT = "$DEBIAN_SNAPSHOT"
DEBIAN_SECURITY_SNAPSHOT = "$DEBIAN_SECURITY_SNAPSHOT"
SHA256s = {
"amd64": {
"debian9": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch/main/binary-amd64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"backports": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-backports/main/binary-amd64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-updates/main/binary-amd64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/stretch/updates/main/binary-amd64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-amd64/Packages.gz 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.gz 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.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"arm": {
"debian9": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch/main/binary-armhf/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"backports": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-backports/main/binary-armhf/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-updates/main/binary-armhf/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/stretch/updates/main/binary-armhf/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-armhf/Packages.gz 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.gz 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.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"arm64": {
"debian9": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch/main/binary-arm64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"backports": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-backports/main/binary-arm64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-updates/main/binary-arm64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"security": "`curl -s https://snapshot.debian.org/archive/debian-security/$DEBIAN_SECURITY_SNAPSHOT/dists/stretch/updates/main/binary-arm64/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-arm64/Packages.gz 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.gz 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.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"s390x": {
"debian9": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch/main/binary-s390x/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"backports": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-backports/main/binary-s390x/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-updates/main/binary-s390x/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-s390x/Packages.gz 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.gz 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.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
"ppc64le": {
"debian9": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch/main/binary-ppc64el/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"backports": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-backports/main/binary-ppc64el/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
"updates": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/stretch-updates/main/binary-ppc64el/Packages.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
"debian10": {
"main": "`curl -s https://snapshot.debian.org/archive/debian/$DEBIAN_SNAPSHOT/dists/buster/main/binary-ppc64el/Packages.gz 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.gz 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.gz 2>&1 | sha256sum | cut -d " " -f 1`",
},
},
}
EOF
# Rebuild package set
bazel clean
bazel build --host_force_python=PY2 //package_manager:dpkg_parser.par
bazel build --host_force_python=PY2 @package_bundle_amd64_debian9//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_amd64_debian10//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_arm_debian9//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_arm_debian10//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_arm64_debian9//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_arm64_debian10//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_s390x_debian9//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_s390x_debian10//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_ppc64le_debian9//file:packages.bzl
bazel build --host_force_python=PY2 @package_bundle_ppc64le_debian10//file:packages.bzl
# Check if any of the version lock files are updated
if diff -w package_bundle_amd64_debian9.versions package_bundle_amd64_debian9.versions~ &&
diff -w package_bundle_amd64_debian10.versions package_bundle_amd64_debian10.versions~ &&
diff -w package_bundle_arm_debian9.versions package_bundle_arm_debian9.versions~ &&
diff -w package_bundle_arm_debian10.versions package_bundle_arm_debian10.versions~ &&
diff -w package_bundle_arm64_debian9.versions package_bundle_arm64_debian9.versions~ &&
diff -w package_bundle_arm64_debian10.versions package_bundle_arm64_debian10.versions~ &&
diff -w package_bundle_s390x_debian9.versions package_bundle_s390x_debian9.versions~ &&
diff -w package_bundle_s390x_debian10.versions package_bundle_s390x_debian10.versions~ &&
diff -w package_bundle_ppc64le_debian9.versions package_bundle_ppc64le_debian9.versions~ &&
diff -w package_bundle_ppc64le_debian10.versions package_bundle_ppc64le_debian10.versions~; then
echo "No changes detected to package_bundle versions."
mv checksums.bzl~ checksums.bzl
mv package_bundle_amd64_debian9.versions~ package_bundle_amd64_debian9.versions
mv package_bundle_amd64_debian10.versions~ package_bundle_amd64_debian10.versions
mv package_bundle_arm_debian9.versions~ package_bundle_arm_debian9.versions
mv package_bundle_arm_debian10.versions~ package_bundle_arm_debian10.versions
mv package_bundle_arm64_debian9.versions~ package_bundle_arm64_debian9.versions
mv package_bundle_arm64_debian10.versions~ package_bundle_arm64_debian10.versions
mv package_bundle_s390x_debian9.versions~ package_bundle_s390x_debian9.versions
mv package_bundle_s390x_debian10.versions~ package_bundle_s390x_debian10.versions
mv package_bundle_ppc64le_debian9.versions~ package_bundle_ppc64le_debian9.versions
mv package_bundle_ppc64le_debian10.versions~ package_bundle_ppc64le_debian10.versions
else
echo "Changes detected to package_bundle version files. Please update snapshots."
rm *~
fi