Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased]
*no unreleased changes*
### Fixed
* Capistrano: Do not include macOS extended attributes in tar files

## 7.3.4 / 2025-09-26
### Fixed
Expand Down
33 changes: 33 additions & 0 deletions lib/ndr_dev_support/capistrano/macos_bsdtar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'capistrano/recipes/deploy/strategy/copy'

# Do not include macOS extended attributes in capistrano tar files
#
# Without this, the system default tar (bsdtar) creates AppleDouble files with a
# ._ prefix, and the linux default tar (gnutar) generates many warnings such as:
# tar: Ignoring unknown extended header keyword 'LIBARCHIVE.xattr.com.apple.provenance'
#
# This fix works because we compress files only locally, for capistrano deployments.
# If we were compressing files remotely too, we would instead need to selectively
# redefine behaviour for local tar usage vs remote usage, e.g. by adding a
# :copy_local_tar_options variable, similar to :copy_local_tar
module CopyMacosTarSupport
private

def compress(directory, file)
if compression.compress_command[0] == 'tar' && local_tar_is_macos_bsdtar?
return macos_bsdtar_compress(directory, file)
end

super
end

def local_tar_is_macos_bsdtar?
RUBY_PLATFORM =~ /darwin/ && system('tar --version | grep -q ^bsdtar')
end

def macos_bsdtar_compress(directory, file)
compression.compress_command + [file, '--no-xattr', '--no-mac-metadata', directory]
end
end

Capistrano::Deploy::Strategy::Copy.prepend(CopyMacosTarSupport)
1 change: 1 addition & 0 deletions lib/ndr_dev_support/capistrano/ndr_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative 'assets'
require_relative 'deploy_secrets'
require_relative 'install_ruby'
require_relative 'macos_bsdtar'
require_relative 'preinstall'
require_relative 'restart'
require_relative 'revision_logger'
Expand Down