Skip to content

Commit

Permalink
Add the --no-mac-metadata flag to fly tar commands
Browse files Browse the repository at this point in the history
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 concourse#8916

See cloudfoundry/bosh-utils@f79167b
for a similar fix to the `bosh` cli.
  • Loading branch information
selzoc committed Apr 5, 2024
1 parent ea8bf50 commit 17a41c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion go-archive/tarfs/shell_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"os"
"os/exec"
"runtime"
"strings"
"syscall"
)
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion go-archive/tgzfs/shell_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"os"
"os/exec"
"runtime"
"strings"
"syscall"
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 17a41c6

Please sign in to comment.