5 Commits
Author SHA1 Message Date
CapCreeperGR 721414679d Merge branch 'develop' into 'master'
Prevent direct split-pakcage installation and hide bpm file information when using -y

See merge request bubble-package-manager/bpm!2
2024-07-12 16:04:04 +00:00
CapCreeperGR c20e74203c BPM will throw an error when attempting to install a split source package 2024-07-12 18:20:51 +03:00
CapCreeperGR 23f9a13939 Package information will no longer show up if the -y flag is enabled 2024-07-12 16:22:27 +03:00
CapCreeperGR 1d41236740 Merge branch 'develop' into 'master'
Added Makefile and changed module name

See merge request bubble-package-manager/bpm!1
2024-07-10 06:59:31 +00:00
CapCreeperGR e445863dca Added Makefile and changed module name 2024-07-10 09:48:42 +03:00
6 changed files with 76 additions and 14 deletions
+38
View File
@@ -0,0 +1,38 @@
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
ifeq ($(BINDIR),)
BINDIR := $(PREFIX)/bin
endif
ifeq ($(SYSCONFDIR),)
SYSCONFDIR := $(PREFIX)/etc
endif
ifeq ($(GO),)
GO := $(shell type -a -P go | head -n 1)
endif
build:
mkdir -p build
$(GO) build -ldflags "-w" -o build/bpm gitlab.com/bubble-package-manager/bpm
install: build/bpm config/
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(SYSCONFDIR)
cp build/bpm $(DESTDIR)$(BINDIR)/bpm
cp config/bpm.conf $(DESTDIR)$(SYSCONFDIR)/bpm.conf
compress: build/bpm config/
mkdir -p bpm/$(BINDIR)
mkdir -p bpm/$(SYSCONFDIR)
cp build/bpm bpm/$(BINDIR)/bpm
cp config/bpm.conf bpm/$(SYSCONFDIR)/bpm.conf
tar --owner=root --group=root -czf bpm.tar.gz bpm
rm -r bpm
run: build/bpm
build/bpm
clean:
rm -r build/
.PHONY: build
+9 -8
View File
@@ -15,15 +15,16 @@ BPM is still in very early development. It should not be installed on any system
## Build from source ## Build from source
BPM requires go 1.22 or above to be built properly - Download `go` from your package manager or from the go website
- Download `make` from your package manager
```sh - Run the following command to compile the project
git clone https://gitlab.com/bubble-package-manager/bpm.git ```
cd bpm make
mkdir build ```
go build -o ./build/bpm capcreepergr.me/bpm - Run the following command to install stormfetch into your system. You may also append a DESTDIR variable at the end of this line if you wish to install in a different location
```
make install PREFIX=/usr SYSCONFDIR=/etc
``` ```
You are now able to copy the executable in the ./build directory in a VM or container's /usr/bin/ directory
## How to use ## How to use
+18 -1
View File
@@ -481,6 +481,21 @@ func extractPackage(pkgInfo *PackageInfo, filename, rootDir string) (error, []st
return nil, files return nil, files
} }
func isSplitPackage(filename string) bool {
pkgInfo, err := ReadPackage(filename)
if err != nil {
return false
}
if pkgInfo.Type != "source" {
return false
}
cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf("test $(tar -tf %s | grep '^pkg.info' | wc -l) -eq 1", filename))
if err := cmd.Run(); err == nil {
return false
}
return true
}
func compilePackage(pkgInfo *PackageInfo, filename, rootDir string, binaryPkgFromSrc, skipCheck, keepTempDir bool) (error, []string) { func compilePackage(pkgInfo *PackageInfo, filename, rootDir string, binaryPkgFromSrc, skipCheck, keepTempDir bool) (error, []string) {
var files []string var files []string
if !IsPackageInstalled(pkgInfo.Name, rootDir) { if !IsPackageInstalled(pkgInfo.Name, rootDir) {
@@ -668,7 +683,6 @@ if [ $? -ne 0 ]; then
echo "Failed to run package() function in source.sh" echo "Failed to run package() function in source.sh"
fi fi
` `
err = os.WriteFile(path.Join(temp, "run.sh"), []byte(runScript), 0644) err = os.WriteFile(path.Join(temp, "run.sh"), []byte(runScript), 0644)
if err != nil { if err != nil {
return err, nil return err, nil
@@ -924,6 +938,9 @@ func InstallPackage(filename, rootDir string, force, binaryPkgFromSrc, skipCheck
} }
files = i files = i
} else if pkgInfo.Type == "source" { } else if pkgInfo.Type == "source" {
if isSplitPackage(filename) {
return errors.New("BPM is unable to install split source packages")
}
err, i := compilePackage(pkgInfo, filename, rootDir, binaryPkgFromSrc, skipCheck, keepTempDir) err, i := compilePackage(pkgInfo, filename, rootDir, binaryPkgFromSrc, skipCheck, keepTempDir)
if err != nil { if err != nil {
return err return err
+4
View File
@@ -0,0 +1,4 @@
compilation_env: []
silent_compilation: false
compilation_dir: "/var/tmp/"
binary_output_dir: "/var/lib/bpm/compiled/"
+1 -1
View File
@@ -1,4 +1,4 @@
module capcreepergr.me/bpm module gitlab.com/bubble-package-manager/bpm
go 1.22 go 1.22
+6 -4
View File
@@ -2,9 +2,9 @@ package main
import ( import (
"bufio" "bufio"
"capcreepergr.me/bpm/bpm_utils"
"flag" "flag"
"fmt" "fmt"
"gitlab.com/bubble-package-manager/bpm/bpm_utils"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@@ -17,7 +17,7 @@ import (
/* A simple-to-use package manager */ /* A simple-to-use package manager */
/* ---------------------------------- */ /* ---------------------------------- */
var bpmVer = "0.3.1" var bpmVer = "0.3.2"
var subcommand = "help" var subcommand = "help"
var subcommandArgs []string var subcommandArgs []string
@@ -135,8 +135,10 @@ func resolveCommand() {
if err != nil { if err != nil {
log.Fatalf("Could not read package\nError: %s\n", err) log.Fatalf("Could not read package\nError: %s\n", err)
} }
fmt.Print("----------------\n" + bpm_utils.CreateInfoFile(*pkgInfo, true)) if !yesAll {
fmt.Println("----------------") fmt.Print("----------------\n" + bpm_utils.CreateInfoFile(*pkgInfo, true))
fmt.Println("----------------")
}
verb := "install" verb := "install"
if pkgInfo.Type == "source" { if pkgInfo.Type == "source" {
if _, err := os.Stat("/bin/fakeroot"); os.IsNotExist(err) { if _, err := os.Stat("/bin/fakeroot"); os.IsNotExist(err) {