Skip to content
Closed
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
9 changes: 7 additions & 2 deletions pkg/download/artifactDownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ func ConfigureArtifactCommand(app *kingpin.Application) {
name := command.Flag("name", "The artifact name.").Short('n').Required().String()
url := command.Flag("url", "The artifact URL.").Short('u').String()
sha512 := command.Flag("sha512", "The expected sha512 of file.").String()
extractExcludePatterns := command.Flag("exclude", "Patterns of files to exclude during archive extraction").Short('e').Strings()

command.Action(func(context *kingpin.ParseContext) error {
dirPath, err := DownloadArtifact(*name, *url, *sha512)
dirPath, err := DownloadArtifact(*name, *url, *sha512, *extractExcludePatterns)
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -60,7 +61,7 @@ func GetCacheDirectoryForArtifactCustom(dirName string) (string, error) {
// * don't need to find node_modules
// * don't pollute user project dir (important in case of 1-package.json project structure)
// * simplify/speed-up tests (don't download fpm for each test project)
func DownloadArtifact(dirName string, url string, checksum string) (string, error) {
func DownloadArtifact(dirName string, url string, checksum string, extractExcludePatterns []string) (string, error) {
if len(url) == 0 {
// if no url is provided download these artifacts from Github. Otherwise use the provided url to download the artifacts.
switch dirName {
Expand Down Expand Up @@ -122,6 +123,10 @@ func DownloadArtifact(dirName string, url string, checksum string) (string, erro
// -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")
}
// add exclude files
for _, excludePattern := range extractExcludePatterns {
args = append(args, "-xr!"+excludePattern)
}
args = append(args, "-bd", archiveName, "-o"+tempUnpackDir)
command := exec.Command(path7zX, args...)
command.Dir = cacheDir
Expand Down
6 changes: 5 additions & 1 deletion pkg/download/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func DownloadFpm() (string, error) {
name,
GetGithubBaseUrl()+name+"/"+name+".7z",
checksum,
// pass empty exclude patterns
[]string{},
)
} else {
//noinspection SpellCheckingInspection
Expand Down Expand Up @@ -60,7 +62,7 @@ func DownloadWinCodeSign() (string, error) {

func downloadFromGithub(name string, version string, checksum string) (string, error) {
id := name + "-" + version
return DownloadArtifact(id, GetGithubBaseUrl()+id+"/"+id+".7z", checksum)
return DownloadArtifact(id, GetGithubBaseUrl()+id+"/"+id+".7z", checksum, []string{})
}

func GetGithubBaseUrl() string {
Expand Down Expand Up @@ -132,6 +134,8 @@ func DownloadTool(descriptor ToolDescriptor, osName util.OsName) (string, error)
descriptor.Name+"-"+descriptor.Version+"-"+osAndArch, /* ability to use cache dir on any platform (e.g. keep cache under project) */
"https://github.com/"+repository+"/releases/download/"+tagPrefix+descriptor.Version+"/"+descriptor.Name+"-v"+descriptor.Version+"-"+osAndArch+".7z",
checksum,
// pass empty exclude patterns
[]string{},
)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/linuxTools/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ func GetAppImageToolDir() (string, error) {
//noinspection SpellCheckingInspection
result, err := download.DownloadArtifact("",
download.GetGithubBaseUrl()+dirName+"/"+dirName+".7z",
"3el6RUh6XoYJCI/ZOApyb0LLU/gSxDntVZ46R6+JNEANzfSo7/TfrzCRp5KlDo35c24r3ZOP7nnw4RqHwkMRLw==")
"3el6RUh6XoYJCI/ZOApyb0LLU/gSxDntVZ46R6+JNEANzfSo7/TfrzCRp5KlDo35c24r3ZOP7nnw4RqHwkMRLw==",
[]string{},
)
if err != nil {
return "", err
}
Expand Down
Loading