diff --git a/bpm_utils/config.go b/bpm_utils/config.go index d50e7f3..1a6482d 100644 --- a/bpm_utils/config.go +++ b/bpm_utils/config.go @@ -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) { diff --git a/bpm_utils/package_utils.go b/bpm_utils/package_utils.go index 15304a8..416f143 100644 --- a/bpm_utils/package_utils.go +++ b/bpm_utils/package_utils.go @@ -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 diff --git a/main.go b/main.go index b88e2c8..99f668e 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ import ( /* A simple-to-use package manager */ /* ---------------------------------- */ -var bpmVer = "0.3.0" +var bpmVer = "0.3.1" var subcommand = "help" var subcommandArgs []string @@ -139,6 +139,10 @@ func resolveCommand() { fmt.Println("----------------") verb := "install" if pkgInfo.Type == "source" { + if _, err := os.Stat("/bin/fakeroot"); os.IsNotExist(err) { + fmt.Printf("Skipping... cannot %s package (%s) due to fakeroot not being installed") + continue + } verb = "build" } if !forceInstall { @@ -313,19 +317,21 @@ func printHelp() { fmt.Println("\033[1m---- Command List ----\033[0m") fmt.Println("-> bpm version | shows information on the installed version of bpm") fmt.Println("-> bpm info [-R] | shows information on an installed package") - fmt.Println(" -R= lets you define the root path which will be used") + fmt.Println(" -R= lets you define the root path which will be used") fmt.Println("-> bpm list [-R, -c, -n] | lists all installed packages") - fmt.Println(" -R= lets you define the root path which will be used") + fmt.Println(" -R= lets you define the root path which will be used") fmt.Println(" -c lists the amount of installed packages") fmt.Println(" -n lists only the names of installed packages") - fmt.Println("-> bpm install [-R, -y, -f, -b] | installs the following files") - fmt.Println(" -R= lets you define the root path which will be used") + fmt.Println("-> bpm install [-R, -y, -f, -o, -c, -b, -k] | installs the following files") + fmt.Println(" -R= lets you define the root path which will be used") fmt.Println(" -y skips the confirmation prompt") fmt.Println(" -f skips dependency and architecture checking") - fmt.Println(" -b creates a binary package for a source package after compilation and saves it in /var/lib/bpm/compiled") - fmt.Println(" -k keeps the temp directory created by BPM after source package installation") + fmt.Println(" -o= set the binary package output directory (defaults to /var/lib/bpm/compiled)") + fmt.Println(" -c= set the compilation directory (defaults to /var/tmp)") + fmt.Println(" -b creates a binary package from a source package after compilation and saves it in the binary package output directory") + fmt.Println(" -k keeps the compilation directory created by BPM after source package installation") fmt.Println("-> bpm remove [-R, -y] | removes the following packages") - fmt.Println(" -R= lets you define the root path which will be used") + fmt.Println(" -R= lets you define the root path which will be used") fmt.Println(" -y skips the confirmation prompt") fmt.Println("-> bpm file [-R] | shows what packages the following packages are managed by") fmt.Println(" -R= lets you define the root path which will be used") @@ -347,6 +353,8 @@ func resolveFlags() { installFlagSet := flag.NewFlagSet("Install flags", flag.ExitOnError) installFlagSet.StringVar(&rootDir, "R", "/", "Set the destination root") installFlagSet.BoolVar(&yesAll, "y", false, "Skip confirmation prompts") + installFlagSet.StringVar(&bpm_utils.BPMConfig.BinaryOutputDir, "o", bpm_utils.BPMConfig.BinaryOutputDir, "Set the binary output directory") + installFlagSet.StringVar(&bpm_utils.BPMConfig.CompilationDir, "c", bpm_utils.BPMConfig.CompilationDir, "Set the compilation directory") installFlagSet.BoolVar(&buildSource, "b", false, "Build binary package from source package") installFlagSet.BoolVar(&skipCheck, "s", false, "Skip check function during source compilation") installFlagSet.BoolVar(&keepTempDir, "k", false, "Keep temporary directory after source compilation") diff --git a/test_packages/x86_64/bpm/bpm.bpm b/test_packages/x86_64/bpm/bpm.bpm deleted file mode 100644 index 476435c..0000000 Binary files a/test_packages/x86_64/bpm/bpm.bpm and /dev/null differ diff --git a/test_packages/x86_64/bpm/files/etc/bpm.conf b/test_packages/x86_64/bpm/files/etc/bpm.conf deleted file mode 100644 index c1151a8..0000000 --- a/test_packages/x86_64/bpm/files/etc/bpm.conf +++ /dev/null @@ -1,3 +0,0 @@ ---- -compilation_env: [] -silent_compilation: false \ No newline at end of file diff --git a/test_packages/x86_64/bpm/files/usr/bin/bpm b/test_packages/x86_64/bpm/files/usr/bin/bpm deleted file mode 100755 index 2d80fe6..0000000 Binary files a/test_packages/x86_64/bpm/files/usr/bin/bpm and /dev/null differ diff --git a/test_packages/x86_64/bpm/files/usr/share/licenses/bpm/LICENSE b/test_packages/x86_64/bpm/files/usr/share/licenses/bpm/LICENSE deleted file mode 100644 index cd242a5..0000000 --- a/test_packages/x86_64/bpm/files/usr/share/licenses/bpm/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 CapCreeperGR - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/test_packages/x86_64/bpm/pkg.info b/test_packages/x86_64/bpm/pkg.info deleted file mode 100644 index c99f5dd..0000000 --- a/test_packages/x86_64/bpm/pkg.info +++ /dev/null @@ -1,8 +0,0 @@ -name: bpm -description: The Bubble Package Manager -version: 0.3.0 -url: https://gitlab.com/bubble-package-manager/bpm/ -license: GPL3 -architecture: x86_64 -type: binary -keep: etc/bpm.conf \ No newline at end of file diff --git a/test_packages/x86_64/hello/files/usr/bin/hello b/test_packages/x86_64/hello/files/usr/bin/hello deleted file mode 100755 index c9dee84..0000000 Binary files a/test_packages/x86_64/hello/files/usr/bin/hello and /dev/null differ diff --git a/test_packages/x86_64/hello/hello.bpm b/test_packages/x86_64/hello/hello.bpm deleted file mode 100644 index 613e2e1..0000000 Binary files a/test_packages/x86_64/hello/hello.bpm and /dev/null differ diff --git a/test_packages/x86_64/hello/pkg.info b/test_packages/x86_64/hello/pkg.info deleted file mode 100644 index 485efd0..0000000 --- a/test_packages/x86_64/hello/pkg.info +++ /dev/null @@ -1,5 +0,0 @@ -name: hello -description: A simple hello world program -version: 1.0 -architecture: x86_64 -type: binary \ No newline at end of file