From 69fa70eab5e500c34f152c1a04bb115faff00caf Mon Sep 17 00:00:00 2001 From: Wu Sheng Date: Thu, 26 Nov 2026 18:32:42 +0800 Subject: [PATCH] Pack and check the release tarballs with GNU tar in a Linux container stage packs the source and binary tarballs with tools/releasing/linux-tar.sh, which runs GNU tar in a pinned Linux image instead of the host's tar, and unpacks each with GNU tar in that image before signing it, stopping on any tar warning or any AppleDouble `._*` file. The Maven build and the signing stay on the host. The tar, gpg and shasum lines move from the Makefile's `dist` target, which only stage used, into stage, which now runs `make build`. Preflight requires Docker with its daemon running. The 9.8.0 tarballs were packed on macOS. COPYFILE_DISABLE=1 (#828) kept the `._*` entries out, but tar still stored each file's com.apple.provenance attribute as a pax header, on all 217 entries of the binary tarball and all 13,705 of the source tarball, and GNU tar prints "Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.provenance'" once per entry (apache/skywalking#14271). The container does not see macOS attributes and GNU tar creates no `._*` entries, so there is no host flag left to forget. linux-tar.sh is one file, kept identical in the release scripts of skywalking, skywalking-java, skywalking-mcp, skywalking-swck, skywalking-helm, skywalking-client-js and skywalking-nodejs. --- CHANGES.md | 4 + Makefile | 6 -- docs/en/contribution/release-java-agent.md | 9 ++- tools/releasing/linux-tar.sh | 91 ++++++++++++++++++++++ tools/releasing/release.sh | 14 +++- 5 files changed, 112 insertions(+), 12 deletions(-) create mode 100755 tools/releasing/linux-tar.sh diff --git a/CHANGES.md b/CHANGES.md index 31ec666436..5916165bd5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,10 @@ Release Notes. * Bump the netty shaded into the agent from `4.1.124.Final` to `4.1.139.Final` (with netty-tcnative-boringssl-static `2.0.70.Final` → `2.0.84.Final`, the version netty `4.1.139.Final` is built with) to clear the netty-codec, netty-codec-http, netty-codec-http2, netty-handler and netty-handler-proxy CVEs. +* Pack the source and binary release archives with GNU tar on Linux. The 9.8.0 archives were packed on macOS and + carry macOS extended attributes, which made GNU tar print + `Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.provenance'` for every entry + (apache/skywalking#14271). All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/267?closed=1) diff --git a/Makefile b/Makefile index 09c1863bfe..c9a54db952 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,6 @@ CLI_VERSION ?= 0.13.0 # CLI version inside agent image should always use an Apac build: ./mvnw --batch-mode clean package -Dmaven.test.skip=true -.PHONY: dist -dist: build - COPYFILE_DISABLE=1 tar czf apache-skywalking-java-agent-$(TAG).tgz --exclude '._*' --exclude .DS_Store $(AGENT_PACKAGE) - gpg --armor --detach-sig apache-skywalking-java-agent-$(TAG).tgz - shasum -a 512 apache-skywalking-java-agent-$(TAG).tgz > apache-skywalking-java-agent-$(TAG).tgz.sha512 - # Docker build base.all := alpine java8 java11 java17 java21 java25 diff --git a/docs/en/contribution/release-java-agent.md b/docs/en/contribution/release-java-agent.md index d6cc028476..91a5176ff4 100644 --- a/docs/en/contribution/release-java-agent.md +++ b/docs/en/contribution/release-java-agent.md @@ -55,7 +55,7 @@ Run `./tools/releasing/release.sh` without arguments to see all available comman ### Pre-flight checks Before starting, the script verifies: -- Required tools are installed (git, gpg, svn, shasum, mvn, java, tar, gh) +- Required tools are installed (git, gpg, svn, shasum, mvn, java, tar, gh, docker), and the Docker daemon is running - GPG signing works **without password prompt** (critical for maven release) - Maven settings contain Apache server credentials - Git working tree is clean @@ -76,8 +76,11 @@ Then run `gpgconf --kill gpg-agent` and `gpg --sign /dev/null` to cache it. 4. **upload** — upload to Apache SVN `dist/dev` (prompts for SVN credentials) 5. **email vote** — print vote email template with pre-filled version, commit ID, submodule commit, and checksums -Source and binary packaging uses `COPYFILE_DISABLE=1` to prevent macOS `tar` from -generating AppleDouble metadata, and excludes existing `._*` and `.DS_Store` files. +**stage** packs the source and binary tarballs with GNU tar in a Linux container, not with the +host's `tar`, so a release made on macOS carries no macOS metadata (extended-attribute headers or +AppleDouble `._*` entries). It then unpacks each tarball with GNU tar in the same image, and +stops before signing if tar prints any warning or finds a `._*` entry. The Maven build and the +signing run on your machine. Before the long build starts, **prepare** asks for the GitHub milestone ID of the next development version, which it writes into the reset `CHANGES.md`. Look up the diff --git a/tools/releasing/linux-tar.sh b/tools/releasing/linux-tar.sh new file mode 100755 index 0000000000..474e8c9e1d --- /dev/null +++ b/tools/releasing/linux-tar.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +# Packs and checks release tarballs with GNU tar in a pinned Linux image, never with the host's tar. +# On macOS, tar can store a file's extended attributes (com.apple.provenance) as pax headers, and as +# an AppleDouble `._*` entry beside the file unless COPYFILE_DISABLE is set. GNU tar on Linux warns +# about each such header and unpacks the `._*` entries as stray files (apache/skywalking#14271). The +# container does not see macOS attributes and GNU tar creates no `._*` entries; `verify` catches a +# `._*` file that was already on disk. The release scripts of apache/skywalking, skywalking-java, +# skywalking-mcp, skywalking-swck, skywalking-helm, skywalking-client-js and skywalking-nodejs +# share this file; keep every copy identical. +# +# Usage: +# linux-tar.sh check +# Fails unless Docker is installed and its daemon is running. Run it before a long build. +# linux-tar.sh pack +# Runs GNU tar in . Only is visible in the container, so every path in the +# arguments is relative to it and stays inside it. +# linux-tar.sh verify ... +# Unpacks each tarball with GNU tar, as a user on Linux does, and fails on any warning or +# any AppleDouble `._*` entry. + +set -euo pipefail + +IMAGE="debian:bookworm-slim@sha256:e67eeead736ff7bbe258ef088bff683635c561b1fcfefad0806c1df4ab49ce0e" + +check() { + if ! command -v docker > /dev/null; then + echo "ERROR: docker is not installed. Release tarballs are packed in a Linux container." >&2 + exit 1 + fi + if ! docker info > /dev/null 2>&1; then + echo "ERROR: the Docker daemon is not running. Release tarballs are packed in a Linux container." >&2 + exit 1 + fi +} + +pack() { + local dir + dir=$(cd "$1" && pwd) + shift + docker run --rm --user "$(id -u):$(id -g)" -v "${dir}:/work" -w /work "${IMAGE}" tar "$@" +} + +verify() { + local tarball dir name + for tarball in "$@"; do + dir=$(cd "$(dirname "${tarball}")" && pwd) + name=$(basename "${tarball}") + if ! docker run --rm --user "$(id -u):$(id -g)" -v "${dir}:/work:ro" "${IMAGE}" sh -c ' + mkdir /tmp/unpacked + tar -xzf "/work/$1" -C /tmp/unpacked 2> /tmp/warnings || { cat /tmp/warnings; exit 1; } + if [ -s /tmp/warnings ]; then cat /tmp/warnings; exit 1; fi + find /tmp/unpacked -name "._*" > /tmp/appledouble || exit 1 + if [ -s /tmp/appledouble ]; then cat /tmp/appledouble; exit 1; fi' sh "${name}"; then + echo "ERROR: ${name} does not unpack cleanly with GNU tar on Linux (output above)." >&2 + exit 1 + fi + echo "${name}: unpacks cleanly with GNU tar on Linux." + done +} + +usage() { + echo "Usage: $0 check | pack | verify ..." >&2 + exit 2 +} + +command="${1:-}" +[ $# -gt 0 ] && shift +case "${command}" in + check) [ $# -eq 0 ] || usage; check ;; + pack) [ $# -ge 2 ] || usage; pack "$@" ;; + verify) [ $# -ge 1 ] || usage; verify "$@" ;; + *) usage ;; +esac diff --git a/tools/releasing/release.sh b/tools/releasing/release.sh index da8cda3f8f..12ee078d04 100755 --- a/tools/releasing/release.sh +++ b/tools/releasing/release.sh @@ -166,6 +166,8 @@ cmd_preflight() { failed=1 fi done + # stage packs and checks the release tarballs in a Linux container, after the long Maven build. + bash "${SCRIPT_DIR}/linux-tar.sh" check # Java version local java_version @@ -425,7 +427,7 @@ cmd_stage() { # Source tar info "Creating source tar..." - COPYFILE_DISABLE=1 tar czf "${product_dir}-src.tgz" \ + bash "${SCRIPT_DIR}/linux-tar.sh" pack "${SCRIPT_DIR}" czf "${product_dir}-src.tgz" \ --exclude .git \ --exclude .DS_Store \ --exclude '._*' \ @@ -433,6 +435,7 @@ cmd_stage() { --exclude .gitignore \ --exclude .gitmodules \ "${product_dir}" + bash "${SCRIPT_DIR}/linux-tar.sh" verify "${product_dir}-src.tgz" gpg --armor --detach-sig "${product_dir}-src.tgz" shasum -a 512 "${product_dir}-src.tgz" > "${product_dir}-src.tgz.sha512" @@ -440,8 +443,13 @@ cmd_stage() { # Binary tar info "Creating binary tar..." cd "${product_dir}" - export TAG="${version}" - make dist + make build + local bin_tar="${PRODUCT_NAME}-${version}.tgz" + bash "${SCRIPT_DIR}/linux-tar.sh" pack "$(pwd)" czf "${bin_tar}" --exclude '._*' --exclude .DS_Store skywalking-agent + bash "${SCRIPT_DIR}/linux-tar.sh" verify "${bin_tar}" + + gpg --armor --detach-sig "${bin_tar}" + shasum -a 512 "${bin_tar}" > "${bin_tar}.sha512" echo "" info "Release ${version} staged."