Replace variables in download filepath during compilation

This commit is contained in:
2025-11-08 18:49:03 +02:00
parent 52f25c8f3f
commit dfdf38bad8
2 changed files with 10 additions and 4 deletions
+9 -3
View File
@@ -438,6 +438,10 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
if err != nil { if err != nil {
return err 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) extractTo, err := envsubst.Eval(strings.TrimSpace(download.ExtractTo), replaceVars)
if err != nil { if err != nil {
return err return err
@@ -458,9 +462,11 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
switch download.Type { switch download.Type {
case "", "file": case "", "file":
filepath := path.Join(tempDirectory, path.Base(downloadUrl)) if filepath == "" {
if download.Filepath != "" && download.Filepath[0] != '/' { filepath = path.Join(tempDirectory, path.Base(downloadUrl))
filepath = path.Join(tempDirectory, download.Filepath) }
if filepath[0] != '/' {
filepath = path.Join(tempDirectory, filepath)
} }
err := downloadFile("Downloading file "+path.Base(filepath), downloadUrl, filepath, 0644) err := downloadFile("Downloading file "+path.Base(filepath), downloadUrl, filepath, 0644)
+1 -1
View File
@@ -51,7 +51,7 @@ type PackageInfo struct {
type PackageDownload struct { type PackageDownload struct {
Url string `yaml:"url"` Url string `yaml:"url"`
Type string `yaml:"type,omitempty"` Type string `yaml:"type,omitempty"`
Filepath string `yaml:"filepath,omitempty,omitempty"` Filepath string `yaml:"filepath,omitempty"`
// Archive options // Archive options
NoExtract bool `yaml:"no_extract,omitempty"` NoExtract bool `yaml:"no_extract,omitempty"`