diff --git a/hack/scripts/write-sha256sum.sh b/hack/scripts/write-sha256sum.sh new file mode 100755 index 00000000..17d8a8b3 --- /dev/null +++ b/hack/scripts/write-sha256sum.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +# Copyright 2026 Docker Packaging authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +if [ "$#" -ne 1 ]; then + echo >&2 "usage: write-sha256sum " + exit 1 +fi + +file="$1" +case "$file" in + */*) + dir="${file%/*}" + name="${file##*/}" + ;; + *) + dir=. + name="$file" + ;; +esac + +( + set -x + cd "$dir" + sha256sum "$name" > "${name}.sha256" +) diff --git a/pkg/agent/Dockerfile b/pkg/agent/Dockerfile index e31b22d3..10a27df3 100644 --- a/pkg/agent/Dockerfile +++ b/pkg/agent/Dockerfile @@ -192,6 +192,7 @@ ARG TARGETPLATFORM RUN --mount=type=bind,source=scripts/pkg-static-build.sh,target=/usr/local/bin/pkg-static-build \ --mount=type=bind,from=scripts,source=gen-ver.sh,target=/usr/local/bin/gen-ver \ --mount=type=bind,from=scripts,source=fix-cc.sh,target=/usr/local/bin/fix-cc \ + --mount=type=bind,from=scripts,source=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \ --mount=type=bind,from=src,source=/src,target=/usr/local/src/agent \ --mount=type=bind,from=gocross,source=/usr/local/go,target=/usr/local/go,rw \ --mount=type=bind,from=osxcross,src=/osxsdk,target=/xx-sdk \ diff --git a/pkg/agent/scripts/pkg-static-build.sh b/pkg/agent/scripts/pkg-static-build.sh index 61e63bc0..ce6768de 100755 --- a/pkg/agent/scripts/pkg-static-build.sh +++ b/pkg/agent/scripts/pkg-static-build.sh @@ -76,15 +76,18 @@ for pkgname in *; do cp "${pkgname}"/* ${SRCDIR}/LICENSE ${SRCDIR}/README.md "$workdir/${pkgname}/" ) if [ "$(xx-info os)" = "windows" ]; then + pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip" ( set -x cd "$workdir" - zip -r "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.zip" "${pkgname}" + zip -r "$pkgfile" "${pkgname}" ) else + pkgfile="${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz" ( set -x - tar -czf "${pkgoutput}/${pkgname}_${GENVER_VERSION#v}.tgz" -C "$workdir" "${pkgname}" + tar -czf "$pkgfile" -C "$workdir" "${pkgname}" ) fi + write-sha256sum "$pkgfile" done diff --git a/pkg/agent/verify.Dockerfile b/pkg/agent/verify.Dockerfile index b5d2595e..55f37565 100644 --- a/pkg/agent/verify.Dockerfile +++ b/pkg/agent/verify.Dockerfile @@ -108,7 +108,9 @@ RUN --mount=from=bin,target=/build <