Added 'Binary Output' and 'Compilation Directory' config options and parameters, removed test packages and added other small improvements

This commit is contained in:
CapCreeperGR
2024-07-07 22:02:57 +03:00
parent 124802ecc1
commit f9ef17cd66
11 changed files with 26 additions and 48 deletions
+6 -1
View File
@@ -8,11 +8,16 @@ import (
type BPMConfigStruct struct {
CompilationEnv []string `yaml:"compilation_env"`
SilentCompilation bool `yaml:"silent_compilation"`
BinaryOutputDir string `yaml:"binary_output_dir"`
CompilationDir string `yaml:"compilation_dir"`
}
var BPMConfig BPMConfigStruct = BPMConfigStruct{
CompilationEnv: make([]string, 0),
SilentCompilation: false}
SilentCompilation: false,
BinaryOutputDir: "/var/lib/bpm/compiled/",
CompilationDir: "/var/tmp/",
}
func ReadConfig() {
if _, err := os.Stat("/etc/bpm.conf"); os.IsNotExist(err) {
+4 -2
View File
@@ -505,7 +505,7 @@ func compilePackage(pkgInfo *PackageInfo, filename, rootDir string, binaryPkgFro
}
tr := tar.NewReader(archive)
temp := "/var/tmp/bpm_source-" + pkgInfo.Name
temp := path.Join(BPMConfig.CompilationDir, "bpm_source-"+pkgInfo.Name)
err = os.RemoveAll(temp)
if err != nil {
return err, nil
@@ -683,6 +683,8 @@ fi
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: 65534, Gid: 65534}
cmd.Dir = temp
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "USER=nobody")
cmd.Env = append(cmd.Env, "HOME="+temp)
err = os.Mkdir(path.Join(temp, "source"), 0755)
if err != nil {
@@ -827,7 +829,7 @@ fi
return err, nil
}
if binaryPkgFromSrc {
compiledDir := path.Join(rootDir, "var/lib/bpm/compiled/")
compiledDir := path.Join(BPMConfig.BinaryOutputDir)
err = os.MkdirAll(compiledDir, 0755)
compiledInfo := PackageInfo{}
compiledInfo = *pkgInfo