Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 12 additions & 3 deletions pkg/offload/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pkg/offload/deb/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 6 additions & 0 deletions pkg/offload/deb/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My agent flagged this:

dh_compress will gzip THIRD-PARTY-NOTICES, so the deb check fails**

  • deb/rules installs THIRD-PARTY-NOTICES and LICENSE into usr/share/doc/docker-offload-plugin/, then runs the default dh sequence.
  • In that sequence, dh_compress gzips any file in usr/share/doc larger than 4k, except copyright, web files and images. I checked this against the debhelper source on salsa.
  • A notices file for a Go plugin's dependencies will be well over 4k, so the package will contain THIRD-PARTY-NOTICES.gz. LICENSE may end up as .gz too, depending on its final text.
  • The verify.Dockerfile greps use .../THIRD-PARTY-NOTICES$, so the deb verify step fails, which then fails the release.
  • Fix either side:
    • Keep the files uncompressed. That's probably better for a compliance file. Add this to rules:
      override_dh_compress:
      	dh_compress -X LICENSE -X THIRD-PARTY-NOTICES
      
    • Or accept the Debian convention and make both greps match (\.gz)?$.


%:
dh $@
4 changes: 4 additions & 0 deletions pkg/offload/rpm/docker-offload-plugin.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions pkg/offload/scripts/pkg-deb-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

: "${SOURCE_DATE_EPOCH=}"
: "${SRCDIR=./offload}"
: "${NOTICESDIR=./notices}"
: "${OUTDIR=/out}"
: "${BUILD_ENV_FILE=}"

Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pkg/offload/scripts/pkg-rpm-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

: "${SOURCE_DATE_EPOCH=}"
: "${SRCDIR=/usr/local/src/offload}"
: "${NOTICESDIR=/usr/local/src/notices}"
: "${OUTDIR=/out}"
: "${BUILD_ENV_FILE=}"

Expand All @@ -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
Expand All @@ -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}"
Expand Down
7 changes: 6 additions & 1 deletion pkg/offload/scripts/pkg-static-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

: "${BUILDDIR=/work/build}"
: "${SRCDIR=/usr/local/src/offload}"
: "${NOTICESDIR=/usr/local/src/notices}"
: "${OUTDIR=/out}"

set -e
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions pkg/offload/verify.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ RUN --mount=from=bin,target=/build <<EOT
(
set -x
dpkg-deb --info $package
# Check the package contents, not the installed files, as some base images exclude /usr/share/doc.
dpkg-deb --contents $package | grep -E ' \./usr/share/doc/docker-offload-plugin/LICENSE$'
dpkg-deb --contents $package | grep -E ' \./usr/share/doc/docker-offload-plugin/THIRD-PARTY-NOTICES$'
apt-get update
apt-get install -y --no-install-recommends $package
)
Expand Down Expand Up @@ -93,6 +96,8 @@ RUN --mount=from=bin,target=/build <<EOT
(
set -x
rpm -qilp $package
rpm -qLp $package | grep -E '/docker-offload-plugin/LICENSE$'
rpm -qLp $package | grep -E '/docker-offload-plugin/THIRD-PARTY-NOTICES$'
dnf install -y $package
)
done
Expand Down Expand Up @@ -144,6 +149,7 @@ RUN --mount=from=bin,target=/build <<EOT
test -x "$tmp/cli-plugins/docker-offload${ext}"
test -s "$tmp/doc/LICENSE"
test -s "$tmp/doc/README.md"
test -s "$tmp/doc/THIRD-PARTY-NOTICES"
TARGETPLATFORM="${os}/${arch}" xx-verify --static "$tmp/cli-plugins/docker-offload${ext}"
if [ "$os/$arch" = "$(xx-info os)/$(xx-info arch)" ]; then
"$tmp/cli-plugins/docker-offload${ext}" docker-cli-plugin-metadata
Expand Down