From 17a41c65437362ea675aecd8056e1c5ceca4499b Mon Sep 17 00:00:00 2001 From: Chris Selzo Date: Fri, 5 Apr 2024 11:48:12 -0700 Subject: [PATCH] Add the --no-mac-metadata flag to `fly` tar commands On recent MacOS machines, tar files created (i.e. from `fly execute` with a local resource) include files prefixed by `._`. As a result, once you transfer this tar file to a Linux system and untar, these files may interfere with jobs. This flag will prevent that from happening. Fixes https://github.com/concourse/concourse/issues/8916 See https://github.com/cloudfoundry/bosh-utils/commit/f79167bd43f3afc154065edc95799a464a80605f for a similar fix to the `bosh` cli. --- go-archive/tarfs/shell_out.go | 7 ++++++- go-archive/tgzfs/shell_out.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/go-archive/tarfs/shell_out.go b/go-archive/tarfs/shell_out.go index 5fc9201bf67..7ba0dfa2270 100644 --- a/go-archive/tarfs/shell_out.go +++ b/go-archive/tarfs/shell_out.go @@ -8,6 +8,7 @@ import ( "io" "os" "os/exec" + "runtime" "strings" "syscall" ) @@ -38,7 +39,11 @@ func tarExtract(tarPath string, src io.Reader, dest string) error { func tarCompress(tarPath string, dest io.Writer, workDir string, paths ...string) error { out := new(bytes.Buffer) - tarCmd := exec.Command(tarPath, "-cf", "-", "--null", "-T", "-") + args := []string{"-cf", "-", "--null", "-T", "-"} + if runtime.GOOS == "darwin" { + args = append([]string{"--no-mac-metadata"}, args...) + } + tarCmd := exec.Command(tarPath, args...) tarCmd.Dir = workDir tarCmd.Stderr = out tarCmd.Stdout = dest diff --git a/go-archive/tgzfs/shell_out.go b/go-archive/tgzfs/shell_out.go index fcb4dc501f1..8776a570975 100644 --- a/go-archive/tgzfs/shell_out.go +++ b/go-archive/tgzfs/shell_out.go @@ -8,6 +8,7 @@ import ( "io" "os" "os/exec" + "runtime" "strings" "syscall" ) @@ -38,7 +39,11 @@ func tarExtract(tarPath string, src io.Reader, dest string) error { func tarCompress(tarPath string, dest io.Writer, workDir string, paths ...string) error { out := new(bytes.Buffer) - tarCmd := exec.Command(tarPath, "-czf", "-", "--null", "-T", "-") + args := []string{"-czf", "-", "--null", "-T", "-"} + if runtime.GOOS == "darwin" { + args = append([]string{"--no-mac-metadata"}, args...) + } + tarCmd := exec.Command(tarPath, args...) tarCmd.Dir = workDir tarCmd.Stderr = out tarCmd.Stdout = dest