From bb179518c320b304f08806865aa9e29c15ac26bd Mon Sep 17 00:00:00 2001 From: Wu Sheng Date: Thu, 26 Nov 2026 18:34:26 +0800 Subject: [PATCH] Pack and check the source release tarball with GNU tar in a Linux container npm run package-src packs the tarball with scripts/linux-tar.sh, which runs GNU tar in a pinned Linux image instead of the host's tar, and npm run release-src unpacks it with GNU tar in that image before signing, stopping on any tar warning or any AppleDouble `._*` file. The release script's tool check requires Docker with its daemon running. The 0.9.0 source tarball was packed on macOS, whose tar stored file extended attributes as AppleDouble `._*` entries: 317 of its 637 entries. GNU tar on Linux unpacks them as stray files and warns about their extended-attribute headers (apache/skywalking#14271). The container does not see macOS attributes and GNU tar creates no `._*` entries. 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. --- docs/en/contribution/release.md | 9 ++-- package.json | 4 +- scripts/linux-tar.sh | 91 +++++++++++++++++++++++++++++++++ scripts/release.sh | 2 + 4 files changed, 101 insertions(+), 5 deletions(-) create mode 100755 scripts/linux-tar.sh diff --git a/docs/en/contribution/release.md b/docs/en/contribution/release.md index 82785342..edf2982f 100644 --- a/docs/en/contribution/release.md +++ b/docs/en/contribution/release.md @@ -58,8 +58,8 @@ they read your SVN password. These settings are optional: 1. Register the fingerprint at [id.apache.org](https://id.apache.org/). 1. **Append** (never overwrite) your key to the [SkyWalking KEYS](https://dist.apache.org/repos/dist/release/skywalking/KEYS) file — **PMC only**; ask a PMC member if needed. -- **Tools**: Node >= 20, plus `git`, `svn`, `gh`, `gpg`, `shasum`, `tar` (and `license-eye`, - optional). Run `gh auth login`; for the npm publish, `npm login` as a maintainer of +- **Tools**: Node >= 20, plus `git`, `svn`, `gh`, `gpg`, `shasum`, `tar`, Docker with its daemon running + (and `license-eye`, optional). Run `gh auth login`; for the npm publish, `npm login` as a maintainer of `skywalking-backend-js`. - **Milestones**: close the current milestone and create the next one in [skywalking-nodejs](https://github.com/apache/skywalking-nodejs/milestones) and @@ -77,7 +77,10 @@ bash scripts/release.sh # the real cut 1. Check the GPG signer, required tools, and Node.js version. 1. Clone `master` with submodules and create a `prepare-release-` branch. 1. Remove `-dev`, commit the release version, and tag the release commit. -1. Build, sign, and check `skywalking-nodejs-src-.tgz{,.asc,.sha512}`. +1. Build, sign, and check `skywalking-nodejs-src-.tgz{,.asc,.sha512}`. The tarball is packed with GNU tar in a + Linux container (`scripts/linux-tar.sh`), not with the host's `tar`, so a release made on macOS carries no macOS + metadata (AppleDouble `._*` files or extended-attribute headers). Before signing, it is unpacked with GNU tar in the + same image, and the release stops if tar prints any warning or finds a `._*` entry. 1. Push the tag only after the checks pass. Add the next `-dev` commit and open the release pull request. 1. Upload the release candidate to `dist/dev/skywalking/node-js//`. diff --git a/package.json b/package.json index a27744bc..fbf334eb 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "test": "DEBUG=testcontainers* jest", "format": "prettier --write \"src/**/*.ts\"", "clean": "(rm -rf src/proto || true) && (rm -rf src/proto || true) && (rm -rf lib || true)", - "package-src": "touch skywalking-nodejs-src-$npm_package_version.tgz && tar -zcvf skywalking-nodejs-src-$npm_package_version.tgz --exclude bin --exclude .git --exclude .idea --exclude .DS_Store --exclude .github --exclude .claude --exclude node_modules --exclude skywalking-nodejs-src-$npm_package_version.tgz .", - "release-src": "npm run prepare && npm run package-src && gpg --batch --yes ${SW_GPG_KEY:+-u $SW_GPG_KEY} --armor --detach-sig skywalking-nodejs-src-$npm_package_version.tgz && shasum -a 512 skywalking-nodejs-src-$npm_package_version.tgz > skywalking-nodejs-src-$npm_package_version.tgz.sha512", + "package-src": "touch skywalking-nodejs-src-$npm_package_version.tgz && bash scripts/linux-tar.sh pack . -zcvf skywalking-nodejs-src-$npm_package_version.tgz --exclude bin --exclude .git --exclude .idea --exclude .DS_Store --exclude .github --exclude .claude --exclude node_modules --exclude skywalking-nodejs-src-$npm_package_version.tgz .", + "release-src": "npm run prepare && npm run package-src && bash scripts/linux-tar.sh verify skywalking-nodejs-src-$npm_package_version.tgz && gpg --batch --yes ${SW_GPG_KEY:+-u $SW_GPG_KEY} --armor --detach-sig skywalking-nodejs-src-$npm_package_version.tgz && shasum -a 512 skywalking-nodejs-src-$npm_package_version.tgz > skywalking-nodejs-src-$npm_package_version.tgz.sha512", "release": "bash scripts/release.sh", "release:finalize": "bash scripts/release-finalize.sh" }, diff --git a/scripts/linux-tar.sh b/scripts/linux-tar.sh new file mode 100755 index 00000000..474e8c9e --- /dev/null +++ b/scripts/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/scripts/release.sh b/scripts/release.sh index 59e57b05..78a376cd 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -141,6 +141,8 @@ if [ ${#MISSING[@]} -gt 0 ]; then err "Missing required tools: ${MISSING[*]}" exit 1 fi +# release-src packs and checks the tarball with GNU tar in a Linux container. +bash "${SCRIPT_DIR}/linux-tar.sh" check HAVE_LICENSE_EYE=true command -v license-eye >/dev/null || HAVE_LICENSE_EYE=false echo "All required tools present. node: $(node --version) npm: $(npm --version)"