Skip to content

archive: omit the ./ entry from release tarballs - #2491

Merged
mjcheetham merged 1 commit into
mainfrom
copilot/fix-released-tarballs-entries
Oct 29, 2026
Merged

mjcheetham merged 1 commit into
mainfrom
copilot/fix-released-tarballs-entries

Conversation

Copilot AI commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The Linux and macOS release tarballs begin with a ./ directory entry because archive.sh runs tar -C <dir> .. The entry serves no purpose. When users extract with the documented tar -xf <tarball> -C /usr/local/bin, it also makes tar apply the archived directory's mode and mtime to the existing destination directory.

  • build/linux/archive.sh, build/macos/archive.sh

    • The payload and symbols tar calls (four in total) now list the directory's entries by name instead of .:

      (cd "$BINDIR" && shopt -s dotglob && tar -czf "$PAYLOAD_TARBALL" -- *) || die "..."
    • Only the ./ entry is removed. Every other archived file is the same as before.

  • Why not -C "$DIR" *: tar applies -C itself, so the shell would expand * in the caller's working directory, not in $DIR. The glob has to expand inside $DIR, hence the subshell.

  • && chaining: bash ignores set -e for a subshell on the left of ||. Without &&, a failed cd would fall through and archive the wrong directory.

  • shopt -s dotglob: * skips hidden files by default, and the old . form included them.

  • --: a file name starting with - is not parsed as a tar option.

Behaviour change

An empty source directory now fails with "Failed to create binaries archive" (or "symbols"), because the glob matches nothing. Before, it produced a tarball containing only ./. For the payload this is arguably better. A real publish always puts .dbg, .pdb or .dSYM files in the symbols directory. Please flag it if you want an empty symbols directory skipped instead.

Review notes

  • The solution-wide dotnet build and dotnet test do not run these scripts, because the distribution projects are Build Project="false" in git-credential-manager.slnx. The scripts are exercised by dotnet build build/linux and dotnet build build/macos.
  • I couldn't run the macOS script end to end on a Linux host, because lib-cli.sh rejects osx-* runtimes there. It differs from the Linux script only in help text and comments. Its exact tar lines were checked under bsdtar, which is libarchive-based like macOS's tar.

Copilot AI linked an issue Oct 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix tarballs by removing current directory entry archive: omit the ./ entry from release tarballs Oct 29, 2026
Copilot AI requested a review from mjcheetham October 29, 2026 10:07
@mjcheetham
mjcheetham requested a balanced review from Copilot October 29, 2026 10:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are blocking the Linux and macOS release-archive changes.

No open issues 🎉

What changed in this PR

Addresses #2476 by omitting the root ./ entry from Linux and macOS release tarballs, preventing extraction from applying its permissions and timestamp to the destination directory.

Changes:

  • Archive named entries for both binaries and debug symbols instead of archiving ..
  • Preserve hidden files and protect filenames beginning with - from option parsing.
  • Expand filenames inside each source directory, with failure handling if changing directories fails.
File Description
build/​macos/​archive.sh Updates both macOS archive commands and documents the globbing approach.
build/​linux/​archive.sh Applies the same archive creation changes and explanation for Linux.

Review effort: Balanced

The Linux and macOS archive scripts ran `tar -C <dir> .`, which records
the current directory itself as a `./` entry at the top of the payload
and symbols tarballs. The entry serves no purpose, and when a tarball is
extracted with `tar -xf <tarball> -C <dir>`, as documented in the
install guide, it makes tar apply the archived directory's mode and
mtime to the destination directory.

List the directory's entries by name instead. The glob has to expand
inside the source directory, since tar applies -C itself rather than the
shell, so cd in a subshell. Chain it with `&&` because errexit is
ignored for a subshell on the left of `||`, and a failed cd must not
archive the wrong directory. Pass `--` so a file name starting with `-`
isn't treated as an option.

The published binaries and symbols contain no hidden files, so the
plain `*` glob archives everything that `.` did. Avoid shell-specific
options such as bash's `shopt -s dotglob`, to stay shell agnostic.

The set of archived files is unchanged apart from the removed entry.
An empty source directory now fails to archive instead of producing a
tarball containing only `./`.

Assisted-by: GitHub Copilot
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>
@mjcheetham
mjcheetham force-pushed the copilot/fix-released-tarballs-entries branch from 909a34b to 3ce88f2 Compare October 29, 2026 11:30
@mjcheetham
mjcheetham marked this pull request as ready for review October 29, 2026 11:31
@mjcheetham
mjcheetham requested a review from a team as a code owner October 29, 2026 11:31
@mjcheetham
mjcheetham requested a review from dscho October 29, 2026 12:08

@dscho dscho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me!

@mjcheetham
mjcheetham merged commit cd336c1 into main Oct 29, 2026
24 checks passed
@mjcheetham
mjcheetham deleted the copilot/fix-released-tarballs-entries branch October 29, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Released tarballs contain an entry for the current directory

4 participants