From d7427ab762a631228b121543d75ba10117fce90f Mon Sep 17 00:00:00 2001 From: Ruiyang Wu <58066925+ywwry66@users.noreply.github.com> Date: Fri, 31 Mar 2023 15:52:33 -0400 Subject: [PATCH] Don't save mac metadata/extended attributes for `brew bottle` This commit includes `--no-mac-metadata` `--no-acls` and `--no-xattrs` in `default_tar_args` for `brew bottle` command. Although `default_tar_args` is only active when `--only-json-tab` is not passed, in which case we don't require reproducible bottles, it is nonetheless beneficial to "regularize" tarball creation. In particular, this resolves a sporadic `brew tests --only=dev-cmd/bottle:20` failure (see https://github.com/orgs/Homebrew/discussions/4376 and https://github.com/Homebrew/brew/pull/14997). Furthermore, with `gnu tar`, `--no-acls` and `--no-xattrs` are default flags. As for "mac metadata", although I couldn't find official documentation, this post (https://superuser.com/a/61188) shares some info: - Resource forks (resource forks have been extended attributes since 10.4) - Custom icons set in Finder and the images of Icon\r files - Metadata in PSD files - Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts - Information about aliases (aliases stop working if extended attributes are removed) - Quarantine status or source URLs of files downloaded from the internet - Spotlight comments - Encoding of files saved with TextEdit - Caret position of files opened with TextMate - Skim notes None of these is supposed to be in the bottle I believe. --- Library/Homebrew/dev-cmd/bottle.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 0bba2d5d9f..7ddc7a91e9 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -232,8 +232,11 @@ module Homebrew end def self.setup_tar_and_args!(args, mtime) + # TODO: Refactor and move to extend/os # Without --only-json-tab bottles are never reproducible - default_tar_args = ["tar", [].freeze].freeze + tar_args = + OS.mac? ? ["--no-mac-metadata", "--no-acls", "--no-xattrs"].freeze : ["--no-acls", "--no-xattrs"].freeze # rubocop:disable Homebrew/MoveToExtendOS + default_tar_args = ["tar", tar_args].freeze return default_tar_args unless args.only_json_tab? # Ensure tar is set up for reproducibility.