mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 10:36:12 +00:00
Ensure package downloads stay in the temporary directory
This commit is contained in:
@@ -357,8 +357,8 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
|||||||
switch download.Type {
|
switch download.Type {
|
||||||
case "", "file":
|
case "", "file":
|
||||||
filepath := path.Join(tempDirectory, path.Base(downloadUrl))
|
filepath := path.Join(tempDirectory, path.Base(downloadUrl))
|
||||||
if download.Filepath != "" {
|
if download.Filepath != "" && download.Filepath[0] != '/' {
|
||||||
filepath = download.Filepath
|
filepath = path.Join(tempDirectory, download.Filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := downloadFile(downloadUrl, filepath, 0644)
|
err := downloadFile(downloadUrl, filepath, 0644)
|
||||||
@@ -389,6 +389,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
|||||||
|
|
||||||
if !download.NoExtract && (strings.Contains(filepath, ".tar") || strings.HasSuffix(filepath, ".tgz")) {
|
if !download.NoExtract && (strings.Contains(filepath, ".tar") || strings.HasSuffix(filepath, ".tgz")) {
|
||||||
cmd := exec.Command("tar", "xvf", filepath, "--strip-components="+strconv.Itoa(download.ExtractStripComponents))
|
cmd := exec.Command("tar", "xvf", filepath, "--strip-components="+strconv.Itoa(download.ExtractStripComponents))
|
||||||
|
cmd.Dir = tempDirectory
|
||||||
if download.ExtractToBPMSource {
|
if download.ExtractToBPMSource {
|
||||||
cmd.Args = append(cmd.Args, "-C", path.Join(tempDirectory, "source"))
|
cmd.Args = append(cmd.Args, "-C", path.Join(tempDirectory, "source"))
|
||||||
}
|
}
|
||||||
@@ -439,6 +440,7 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("git", "clone", "--depth=1", downloadUrl)
|
cmd := exec.Command("git", "clone", "--depth=1", downloadUrl)
|
||||||
|
cmd.Dir = tempDirectory
|
||||||
if gitBranch != "" {
|
if gitBranch != "" {
|
||||||
cmd.Args = slices.Insert(cmd.Args, len(cmd.Args)-1, "--branch="+gitBranch)
|
cmd.Args = slices.Insert(cmd.Args, len(cmd.Args)-1, "--branch="+gitBranch)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user