diff options
| author | Jesse Vincent <jesse@fsck.com> | 2026-07-16 03:32:25 +0000 |
|---|---|---|
| committer | Drew Ritter <drew@ritter.dev> | 2026-07-23 17:27:16 -0700 |
| commit | 5d5b6567a804098dca9c09ea1d6bd4dfde6397bf (patch) | |
| tree | a5f3ab549f2823b7fdf4772ff32865981c5e9b13 /scripts | |
| parent | 52f649e4ecc4f1e3673ecd3ea7e0be6fd15e0087 (diff) | |
fix(codex): make package script and its test portable beyond macOS/bsdtar
The packaging pipeline only worked on a Mac with default umask, for
three stacked reasons:
- The deterministic-metadata tar flags (--uid/--gid/--uname/--gname)
are bsdtar spellings; GNU tar rejects them, so the tar.gz archive
step died on Linux. Detect the tar flavor and use --owner=:0
--group=:0 --numeric-owner on GNU tar, which writes byte-identical
ustar headers (uid/gid 0, empty uname/gname).
- Staged file modes depended on two umasks canceling out: git archive
masks entry modes with tar.umask (git default 0002 -> 775), and the
unflagged tar extraction re-masked with the process umask (022 on
macOS -> 755, but 002 elsewhere -> 775). Pin tar.umask=0022 on the
archive call and extract with -p so staged modes are canonical
755/644 on every machine.
- The test's timestamp assertion parsed bsdtar's -tv column layout and
expected epoch 0 rendered in a US timezone ("Dec 31 1969"); GNU tar
uses different columns and UTC hosts render "1970-01-01". Assert
mtime == 0 via python3 tarfile instead, matching how the test
already checks zip timestamps.
tests/codex/test-package-codex-plugin.sh now passes on Linux/GNU tar;
the bsdtar branch preserves the exact flags that passed on macOS.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/package-codex-plugin.sh | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts/package-codex-plugin.sh b/scripts/package-codex-plugin.sh index 00399f0..5308e28 100755 --- a/scripts/package-codex-plugin.sh +++ b/scripts/package-codex-plugin.sh @@ -230,14 +230,16 @@ prepare_metadata_root() { METADATA_ROOT="$(prepare_metadata_root "$METADATA_SOURCE")" -git -C "$REPO_ROOT" archive --format=tar "$REF" -- \ +# Pin tar.umask and extract with -p so staged modes are canonical 755/644 +# regardless of the builder's git config or process umask. +git -C "$REPO_ROOT" -c tar.umask=0022 archive --format=tar "$REF" -- \ .codex-plugin \ CODE_OF_CONDUCT.md \ LICENSE \ README.md \ assets \ skills \ - | tar -xf - -C "$STAGE" + | tar -xpf - -C "$STAGE" VERSION="$(jq -r '.version // empty' "$STAGE/.codex-plugin/plugin.json")" [[ -n "$VERSION" ]] || die "could not read version from .codex-plugin/plugin.json" @@ -298,12 +300,19 @@ case "$FORMAT" in ) ;; tar.gz) - # Match the prior official archive's deterministic tar entry metadata. + # Match the prior official archive's deterministic tar entry metadata: + # ustar entries with uid/gid 0 and empty uname/gname. GNU tar and bsdtar + # (macOS) spell those flags differently. + if tar --version 2>/dev/null | grep -q 'GNU tar'; then + TAR_METADATA_FLAGS=(--owner=:0 --group=:0 --numeric-owner) + else + TAR_METADATA_FLAGS=(--uid 0 --gid 0 --uname '' --gname '') + fi TZ=UTC find "$STAGE" -exec touch -t 197001010000 {} + ( cd "$STAGE" rm -f "$OUTPUT" - COPYFILE_DISABLE=1 tar -cf - --no-recursion --format ustar --uid 0 --gid 0 --uname '' --gname '' -T "$ARCHIVE_LIST" | + COPYFILE_DISABLE=1 tar -cf - --no-recursion --format ustar "${TAR_METADATA_FLAGS[@]}" -T "$ARCHIVE_LIST" | gzip -9n >"$OUTPUT" ) ;; |
