From dfdf38bad88fbfde7aa036c59fdbed9dc4208a11 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Sat, 8 Nov 2025 18:49:03 +0200 Subject: [PATCH] Replace variables in download filepath during compilation --- src/bpmlib/compilation.go | 12 +++++++++--- src/bpmlib/packages.go | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bpmlib/compilation.go b/src/bpmlib/compilation.go index cc71a31..6617b21 100644 --- a/src/bpmlib/compilation.go +++ b/src/bpmlib/compilation.go @@ -438,6 +438,10 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo if err != nil { return err } + filepath, err := envsubst.Eval(strings.TrimSpace(download.Filepath), replaceVars) + if err != nil { + return err + } extractTo, err := envsubst.Eval(strings.TrimSpace(download.ExtractTo), replaceVars) if err != nil { return err @@ -458,9 +462,11 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo switch download.Type { case "", "file": - filepath := path.Join(tempDirectory, path.Base(downloadUrl)) - if download.Filepath != "" && download.Filepath[0] != '/' { - filepath = path.Join(tempDirectory, download.Filepath) + if filepath == "" { + filepath = path.Join(tempDirectory, path.Base(downloadUrl)) + } + if filepath[0] != '/' { + filepath = path.Join(tempDirectory, filepath) } err := downloadFile("Downloading file "+path.Base(filepath), downloadUrl, filepath, 0644) diff --git a/src/bpmlib/packages.go b/src/bpmlib/packages.go index 654d801..48ccf42 100644 --- a/src/bpmlib/packages.go +++ b/src/bpmlib/packages.go @@ -51,7 +51,7 @@ type PackageInfo struct { type PackageDownload struct { Url string `yaml:"url"` Type string `yaml:"type,omitempty"` - Filepath string `yaml:"filepath,omitempty,omitempty"` + Filepath string `yaml:"filepath,omitempty"` // Archive options NoExtract bool `yaml:"no_extract,omitempty"`