From 128737e831cab4aedb48afe5e659997a16c5437a Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 24 Sep 2024 01:00:42 -0700 Subject: [PATCH] chore: Update extract logic for using newer 7zz/7zzs/7zr.exe binaries (#139) * Conditionally adds `-snld` flag when detecting not `7za` binary to allow extracting relative links outside of host dir (to maintain backward compatibility with legacy 7za versus newer 7zz/7zzs/7zr.exe) --- .changeset/strange-pianos-move.md | 5 +++++ pkg/download/artifactDownloader.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .changeset/strange-pianos-move.md diff --git a/.changeset/strange-pianos-move.md b/.changeset/strange-pianos-move.md new file mode 100644 index 0000000..65d355d --- /dev/null +++ b/.changeset/strange-pianos-move.md @@ -0,0 +1,5 @@ +--- +"app-builder-bin": patch +--- + +chore: Update extract logic for using newer 7zz/7zzs/7zr.exe binaries diff --git a/pkg/download/artifactDownloader.go b/pkg/download/artifactDownloader.go index 3660328..bf1e82b 100644 --- a/pkg/download/artifactDownloader.go +++ b/pkg/download/artifactDownloader.go @@ -12,7 +12,7 @@ import ( "github.com/develar/app-builder/pkg/log" "github.com/develar/app-builder/pkg/util" "github.com/develar/errors" - "github.com/develar/go-fs-util" + fsutil "github.com/develar/go-fs-util" "github.com/mitchellh/go-homedir" "go.uber.org/zap" ) @@ -115,7 +115,15 @@ func DownloadArtifact(dirName string, url string, checksum string) (string, erro return "", err } } else { - command := exec.Command(util.Get7zPath(), "x", "-bd", archiveName, "-o"+tempUnpackDir) + path7zX := util.Get7zPath() + var args []string + args = append(args, "x") + if !strings.HasSuffix(path7zX, "7za") { + // -snld flag for https://sourceforge.net/p/sevenzip/bugs/2356/ to maintain backward compatibility between versions of 7za (old) and 7zz/7zzs/7zr.exe (new) + args = append(args, "-snld") + } + args = append(args, "-bd", archiveName, "-o"+tempUnpackDir) + command := exec.Command(path7zX, args...) command.Dir = cacheDir _, err := util.Execute(command) if err != nil {