From 55d4c5dfa585c18e73df923fca872d18441183a7 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Mon, 23 Nov 2026 11:22:02 -0600 Subject: [PATCH] feat(offload): ship LICENSE and THIRD-PARTY-NOTICES in packages - add `notices` named context holding the release THIRD-PARTY-NOTICES - static: copy THIRD-PARTY-NOTICES into archive doc/, fail without it - deb: install LICENSE and notices under /usr/share/doc, point copyright at them - rpm: %license LICENSE and THIRD-PARTY-NOTICES - verify: check the files in the static archives, debs and rpms - dh_compress gzips usr/share/doc files over 4k, which breaks the verify check - exclude both files from dh_compress Signed-off-by: Nick Sieger --- docker-bake.hcl | 2 +- pkg/offload/Dockerfile | 15 ++++++++++++--- pkg/offload/deb/copyright | 3 ++- pkg/offload/deb/rules | 6 ++++++ pkg/offload/rpm/docker-offload-plugin.spec | 4 ++++ pkg/offload/scripts/pkg-deb-build.sh | 8 ++++++++ pkg/offload/scripts/pkg-rpm-build.sh | 9 +++++++++ pkg/offload/scripts/pkg-static-build.sh | 7 ++++++- pkg/offload/verify.Dockerfile | 6 ++++++ 9 files changed, 54 insertions(+), 6 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index 179f72e3..c147ad7e 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -697,7 +697,7 @@ target "_pkg-agent" { # The source repo is private, so there is no PKG_REPO/PKG_REF clone. Offload is not in PKGS_BASE. # The offload repo adds it through PKGS_EXTRA in a remote override, and sets the VERSION, COMMIT, -# BUILD and DATE args, the build-env secret and the src named context there. +# BUILD and DATE args, the build-env secret and the src and notices named contexts there. target "_pkg-offload" { args = { PKG_NAME = PKG_NAME != null && PKG_NAME != "" ? PKG_NAME : "docker-offload-plugin" diff --git a/pkg/offload/Dockerfile b/pkg/offload/Dockerfile index 7fed2605..2759a1a2 100644 --- a/pkg/offload/Dockerfile +++ b/pkg/offload/Dockerfile @@ -38,6 +38,10 @@ FROM scratch AS scripts # Go dependencies already vendored. There is no git clone fallback. FROM scratch AS src +# THIRD-PARTY-NOTICES of the release, passed in by the caller as the notices named context. The +# file is at the root of the context. There is no fallback, the build fails without it. +FROM scratch AS notices + # cross compilation helper FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx @@ -75,9 +79,11 @@ ARG SOURCE_DATE_EPOCH RUN --mount=type=bind,source=scripts/pkg-deb-build.sh,target=/usr/local/bin/pkg-deb-build \ --mount=type=bind,from=scripts,source=gen-deb-changelog.sh,target=/usr/local/bin/gen-deb-changelog \ --mount=type=bind,from=src,target=/root/package/offload,rw \ + --mount=type=bind,from=notices,target=/root/package/notices \ --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ --mount=type=secret,id=build-env,target=/run/secrets/build-env \ - OUTDIR=/out SRCDIR=./offload BUILD_ENV_FILE=/run/secrets/build-env pkg-deb-build + OUTDIR=/out SRCDIR=./offload NOTICESDIR=./notices \ + BUILD_ENV_FILE=/run/secrets/build-env pkg-deb-build # rpm FROM ${DISTRO_IMAGE} AS builder-rpm @@ -107,9 +113,11 @@ ARG PKG_RPM_RELEASE ARG SOURCE_DATE_EPOCH RUN --mount=type=bind,source=scripts/pkg-rpm-build.sh,target=/usr/local/bin/pkg-rpm-build \ --mount=type=bind,from=src,target=/usr/local/src/offload,rw \ + --mount=type=bind,from=notices,target=/usr/local/src/notices \ --mount=type=bind,from=go,source=/usr/local/go,target=/usr/local/go \ --mount=type=secret,id=build-env,target=/run/secrets/build-env \ - OUTDIR=/out SRCDIR=/usr/local/src/offload BUILD_ENV_FILE=/run/secrets/build-env pkg-rpm-build + OUTDIR=/out SRCDIR=/usr/local/src/offload NOTICESDIR=/usr/local/src/notices \ + BUILD_ENV_FILE=/run/secrets/build-env pkg-rpm-build # static # Compiles from source, like the deb and rpm builders, and archives the unsigned binary. @@ -129,9 +137,10 @@ 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=write-sha256sum.sh,target=/usr/local/bin/write-sha256sum \ --mount=type=bind,from=src,target=/usr/local/src/offload,rw \ + --mount=type=bind,from=notices,target=/usr/local/src/notices \ --mount=type=bind,from=go-build,source=/usr/local/go,target=/usr/local/go,rw \ --mount=type=secret,id=build-env,target=/run/secrets/build-env \ - OUTDIR=/out BUILDDIR=/build SRCDIR=/usr/local/src/offload \ + OUTDIR=/out BUILDDIR=/build SRCDIR=/usr/local/src/offload NOTICESDIR=/usr/local/src/notices \ BUILD_ENV_FILE=/run/secrets/build-env pkg-static-build FROM builder-${DISTRO_TYPE} AS build-pkg diff --git a/pkg/offload/deb/copyright b/pkg/offload/deb/copyright index d723d73b..6cd69a9d 100644 --- a/pkg/offload/deb/copyright +++ b/pkg/offload/deb/copyright @@ -5,4 +5,5 @@ Source: https://docs.docker.com/offload/ Files: * Copyright: Docker, Inc. License: Proprietary - All rights reserved. + All rights reserved. See LICENSE in this directory for the license text, and + THIRD-PARTY-NOTICES for the licenses of the bundled third-party code. diff --git a/pkg/offload/deb/rules b/pkg/offload/deb/rules index 1113126e..5583de5d 100755 --- a/pkg/offload/deb/rules +++ b/pkg/offload/deb/rules @@ -18,8 +18,14 @@ override_dh_strip: override_dh_dwz: +# dh_compress gzips files over 4k in usr/share/doc. Keep the license files readable as installed. +override_dh_compress: + dh_compress -X LICENSE -X THIRD-PARTY-NOTICES + override_dh_auto_install: install -D -p -m 0755 $(CURDIR)/offload/dist/docker-offload debian/docker-offload-plugin/usr/libexec/docker/cli-plugins/docker-offload + install -D -p -m 0644 $(CURDIR)/offload/LICENSE debian/docker-offload-plugin/usr/share/doc/docker-offload-plugin/LICENSE + install -D -p -m 0644 $(CURDIR)/notices/THIRD-PARTY-NOTICES debian/docker-offload-plugin/usr/share/doc/docker-offload-plugin/THIRD-PARTY-NOTICES %: dh $@ diff --git a/pkg/offload/rpm/docker-offload-plugin.spec b/pkg/offload/rpm/docker-offload-plugin.spec index 364beaad..ca2ad88a 100644 --- a/pkg/offload/rpm/docker-offload-plugin.spec +++ b/pkg/offload/rpm/docker-offload-plugin.spec @@ -34,8 +34,12 @@ test "$ver" = "%{_origversion}" && echo "PASS: docker-offload version OK" || { e %install install -D -p -m 0755 %{_srcdir}/dist/docker-offload ${RPM_BUILD_ROOT}%{_libexecdir}/docker/cli-plugins/docker-offload +install -D -p -m 0644 %{_srcdir}/LICENSE docker-offload-plugin-docs/LICENSE +install -D -p -m 0644 %{_noticesdir}/THIRD-PARTY-NOTICES docker-offload-plugin-docs/THIRD-PARTY-NOTICES %files +%license docker-offload-plugin-docs/LICENSE +%license docker-offload-plugin-docs/THIRD-PARTY-NOTICES %{_libexecdir}/docker/cli-plugins/docker-offload %changelog diff --git a/pkg/offload/scripts/pkg-deb-build.sh b/pkg/offload/scripts/pkg-deb-build.sh index 8416ceeb..83612b17 100755 --- a/pkg/offload/scripts/pkg-deb-build.sh +++ b/pkg/offload/scripts/pkg-deb-build.sh @@ -33,6 +33,7 @@ : "${SOURCE_DATE_EPOCH=}" : "${SRCDIR=./offload}" +: "${NOTICESDIR=./notices}" : "${OUTDIR=/out}" : "${BUILD_ENV_FILE=}" @@ -59,6 +60,13 @@ if [ ! -f "${SRCDIR}/Makefile" ]; then exit 1 fi +for doc in "${SRCDIR}/LICENSE" "${NOTICESDIR}/THIRD-PARTY-NOTICES"; do + if [ ! -s "$doc" ]; then + echo >&2 "error: ${doc} is missing or empty; pass the source tree as the src named context and the release notices as the notices named context" + exit 1 + fi +done + mkdir -p "$OUTDIR" if ! command -v xx-info &> /dev/null; then diff --git a/pkg/offload/scripts/pkg-rpm-build.sh b/pkg/offload/scripts/pkg-rpm-build.sh index 957ede16..0d15b201 100755 --- a/pkg/offload/scripts/pkg-rpm-build.sh +++ b/pkg/offload/scripts/pkg-rpm-build.sh @@ -32,6 +32,7 @@ : "${SOURCE_DATE_EPOCH=}" : "${SRCDIR=/usr/local/src/offload}" +: "${NOTICESDIR=/usr/local/src/notices}" : "${OUTDIR=/out}" : "${BUILD_ENV_FILE=}" @@ -58,6 +59,13 @@ if [ ! -f "${SRCDIR}/Makefile" ]; then exit 1 fi +for doc in "${SRCDIR}/LICENSE" "${NOTICESDIR}/THIRD-PARTY-NOTICES"; do + if [ ! -s "$doc" ]; then + echo >&2 "error: ${doc} is missing or empty; pass the source tree as the src named context and the release notices as the notices named context" + exit 1 + fi +done + mkdir -p "$OUTDIR" if ! command -v xx-info &> /dev/null; then @@ -79,6 +87,7 @@ rpmDefine=( --define "_origversion ${VERSION}" --define "_release ${PKG_RPM_RELEASE:-1}" --define "_srcdir ${SRCDIR}" + --define "_noticesdir ${NOTICESDIR}" --define "_commit ${COMMIT:-$nil}" --define "_buildnum ${BUILD:-$nil}" --define "_date ${DATE:-$nil}" diff --git a/pkg/offload/scripts/pkg-static-build.sh b/pkg/offload/scripts/pkg-static-build.sh index a6abd095..eba892f2 100755 --- a/pkg/offload/scripts/pkg-static-build.sh +++ b/pkg/offload/scripts/pkg-static-build.sh @@ -24,6 +24,7 @@ : "${BUILDDIR=/work/build}" : "${SRCDIR=/usr/local/src/offload}" +: "${NOTICESDIR=/usr/local/src/notices}" : "${OUTDIR=/out}" set -e @@ -71,6 +72,10 @@ for doc in LICENSE README.md; do exit 1 fi done +if [ ! -s "${NOTICESDIR}/THIRD-PARTY-NOTICES" ]; then + echo >&2 "error: no THIRD-PARTY-NOTICES in ${NOTICESDIR}; pass the release notices as the notices named context" + exit 1 +fi pkgoutput="$OUTDIR/static/$(xx-info os)/$(xx-info arch)" if [ -n "$(xx-info variant)" ]; then @@ -83,7 +88,7 @@ mkdir -p "$workdir/cli-plugins" "$workdir/doc" ( set -x cp "$bin" "$workdir/cli-plugins/" - cp "${SRCDIR}/LICENSE" "${SRCDIR}/README.md" "$workdir/doc/" + cp "${SRCDIR}/LICENSE" "${SRCDIR}/README.md" "${NOTICESDIR}/THIRD-PARTY-NOTICES" "$workdir/doc/" ) if [ "$(xx-info os)" = "windows" ]; then pkgfile="${pkgoutput}/${PKG_NAME}_${VERSION#v}.zip" diff --git a/pkg/offload/verify.Dockerfile b/pkg/offload/verify.Dockerfile index 67b91bd2..170ade92 100644 --- a/pkg/offload/verify.Dockerfile +++ b/pkg/offload/verify.Dockerfile @@ -55,6 +55,9 @@ RUN --mount=from=bin,target=/build <