diff --git a/src/bpmlib/compilation.go b/src/bpmlib/compilation.go index 0b11f3b..6e72b2c 100644 --- a/src/bpmlib/compilation.go +++ b/src/bpmlib/compilation.go @@ -60,7 +60,13 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks bo gid = os.Getgid() } - tempDirectory := path.Join(homeDir, ".cache/bpm/compilation/", bpmpkg.PkgInfo.Name) + // Set temporary directory + var tempDirectory string + if os.Getuid() == 0 { + tempDirectory = path.Join("/var/cache/bpm/compilation/", bpmpkg.PkgInfo.Name) + } else { + tempDirectory = path.Join(homeDir, ".cache/bpm/compilation/", bpmpkg.PkgInfo.Name) + } // Ensure temporary directory does not exist if _, err := os.Stat(tempDirectory); err == nil { diff --git a/src/bpmlib/operations.go b/src/bpmlib/operations.go index 1736545..0a3648b 100644 --- a/src/bpmlib/operations.go +++ b/src/bpmlib/operations.go @@ -516,7 +516,7 @@ func (operation *BPMOperation) Execute(verbose, force bool) (err error) { // Compile package if type is 'source' if bpmpkg.PkgInfo.Type == "source" { // Get path to compiled package directory - compiledDir := path.Join(operation.RootDir, "/var/lib/bpm/compiled/") + compiledDir := path.Join(operation.RootDir, "/var/cache/bpm/compiled/") // Create compiled package directory if not exists if _, err := os.Stat(compiledDir); err != nil { diff --git a/src/bpmlib/repositories.go b/src/bpmlib/repositories.go index c168f79..cafc6b1 100644 --- a/src/bpmlib/repositories.go +++ b/src/bpmlib/repositories.go @@ -266,16 +266,16 @@ func (repo *Repository) FetchPackage(pkg string) (string, error) { } defer resp.Body.Close() - err = os.MkdirAll("/var/cache/bpm/packages/", 0755) + err = os.MkdirAll("/var/cache/bpm/fetched/", 0755) if err != nil { return "", err } - out, err := os.Create("/var/cache/bpm/packages/" + path.Base(entry.Download)) + out, err := os.Create("/var/cache/bpm/fetched/" + path.Base(entry.Download)) if err != nil { return "", err } defer out.Close() _, err = io.Copy(out, resp.Body) - return "/var/cache/bpm/packages/" + path.Base(entry.Download), nil + return "/var/cache/bpm/fetched/" + path.Base(entry.Download), nil }