Skip to content

Commit 123a896

Browse files
authored
Merge pull request #495 from crazy-max/static-checksums
static: add checksum files for package archives
2 parents 71f2e0b + 7d994c2 commit 123a896

28 files changed

Lines changed: 128 additions & 29 deletions

hack/scripts/write-sha256sum.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2026 Docker Packaging authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
if [ "$#" -ne 1 ]; then
20+
echo >&2 "usage: write-sha256sum <file>"
21+
exit 1
22+
fi
23+
24+
file="$1"
25+
case "$file" in
26+
*/*)
27+
dir="${file%/*}"
28+
name="${file##*/}"
29+
;;
30+
*)
31+
dir=.
32+
name="$file"
33+
;;
34+
esac
35+
36+
(
37+
set -x
38+
cd "$dir"
39+
sha256sum "$name" > "${name}.sha256"
40+
)

pkg/agent/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ ARG TARGETPLATFORM
192192
RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \
193193
--mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
194194
--mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \
195+
--mount=type=bind,from=scripts,source=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \
195196
--mount=type=bind,from=src,source=/src,target=/usr/local/src/agent \
196197
--mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \
197198
--mount=type=bind,from=osxcross,src=/osxsdk,target=/xx-sdk \

pkg/agent/scripts/pkg-static-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ for pkgname in *; do
7676
cp "${pkgname}"/* ${SRCDIR}/LICENSE ${SRCDIR}/README.md "$workdir/${pkgname}/"
7777
)
7878
if [ "$(xx-info os)" = "windows" ]; then
79+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip"
7980
(
8081
set -x
8182
cd "$workdir"
82-
zip -r "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip" "${pkgname}"
83+
zip -r "$pkgfile" "${pkgname}"
8384
)
8485
else
86+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz"
8587
(
8688
set -x
87-
tar -czf "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz" -C "$workdir" "${pkgname}"
89+
tar -czf "$pkgfile" -C "$workdir" "${pkgname}"
8890
)
8991
fi
92+
write-sha256sum "$pkgfile"
9093
done

pkg/agent/verify.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ RUN --mount=from=bin,target=/build <<EOT
108108
for package in $(find $dir -type f -name '*.tgz'); do
109109
(
110110
set -x
111-
tar zxvf $package -C /usr/bin --strip-components=1
111+
cd "${package%/*}"
112+
sha256sum -c "${package##*/}.sha256"
113+
tar zxvf "${package##*/}" -C /usr/bin --strip-components=1
112114
)
113115
done
114116
set -x

pkg/buildx/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ ARG TARGETPLATFORM
169169
RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \
170170
--mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
171171
--mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \
172+
--mount=type=bind,from=scripts,source=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \
172173
--mount=type=bind,from=src,source=/src,target=/usr/local/src/buildx \
173174
--mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \
174175
OUTDIR=/out BUILDDIR=/build SRCDIR=/usr/local/src/buildx pkg-static-build

pkg/buildx/scripts/pkg-static-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,18 @@ for pkgname in *; do
7373
cp "${pkgname}"/* ${SRCDIR}/LICENSE ${SRCDIR}/README.md "$workdir/${pkgname}/"
7474
)
7575
if [ "$(xx-info os)" = "windows" ]; then
76+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip"
7677
(
7778
set -x
7879
cd "$workdir"
79-
zip -r "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip" "${pkgname}"
80+
zip -r "$pkgfile" "${pkgname}"
8081
)
8182
else
83+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz"
8284
(
8385
set -x
84-
tar -czf "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz" -C "$workdir" "${pkgname}"
86+
tar -czf "$pkgfile" -C "$workdir" "${pkgname}"
8587
)
8688
fi
89+
write-sha256sum "$pkgfile"
8790
done

pkg/buildx/verify.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ RUN --mount=from=bin,target=/build <<EOT
108108
for package in $(find $dir -type f -name '*.tgz'); do
109109
(
110110
set -x
111-
tar zxvf $package -C /usr/bin --strip-components=1
111+
cd "${package%/*}"
112+
sha256sum -c "${package##*/}.sha256"
113+
tar zxvf "${package##*/}" -C /usr/bin --strip-components=1
112114
)
113115
done
114116
set -x

pkg/compose/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ RUN xx-apt-get install -y gcc libc6-dev
180180
RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \
181181
--mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
182182
--mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \
183+
--mount=type=bind,from=scripts,source=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \
183184
--mount=type=bind,from=src,source=/src,target=/usr/local/src/compose \
184185
--mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \
185186
OUTDIR=/out BUILDDIR=/build SRCDIR=/usr/local/src/compose pkg-static-build
@@ -211,6 +212,7 @@ RUN xx-apt-get install -y gcc libc6-dev
211212
RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \
212213
--mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \
213214
--mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \
215+
--mount=type=bind,from=scripts,source=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \
214216
--mount=type=bind,from=src,source=/src,target=/usr/local/src/compose \
215217
--mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \
216218
--mount=type=bind,from=osxcross,src=/osxsdk,target=/xx-sdk \

pkg/compose/scripts/pkg-static-build.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,18 @@ for pkgname in *; do
7878
cp "${pkgname}"/* ${SRCDIR}/LICENSE ${SRCDIR}/README.md "$workdir/${pkgname}/"
7979
)
8080
if [ "$(xx-info os)" = "windows" ]; then
81+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip"
8182
(
8283
set -x
8384
cd "$workdir"
84-
zip -r "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip" "${pkgname}"
85+
zip -r "$pkgfile" "${pkgname}"
8586
)
8687
else
88+
pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz"
8789
(
8890
set -x
89-
tar -czf "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz" -C "$workdir" "${pkgname}"
91+
tar -czf "$pkgfile" -C "$workdir" "${pkgname}"
9092
)
9193
fi
94+
write-sha256sum "$pkgfile"
9295
done

pkg/compose/verify.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ RUN --mount=from=bin,target=/build <<EOT
108108
for package in $(find $dir -type f -name '*.tgz'); do
109109
(
110110
set -x
111-
tar zxvf $package -C /usr/bin --strip-components=1
111+
cd "${package%/*}"
112+
sha256sum -c "${package##*/}.sha256"
113+
tar zxvf "${package##*/}" -C /usr/bin --strip-components=1
112114
)
113115
done
114116
set -x

0 commit comments

Comments
 (0)