mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-25 15:06:12 +00:00
Compare commits
7
Commits
08a4e24889
..
0.6.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f23537ba7d
|
||
|
|
6e9f16837c
|
||
|
|
271e87cb77
|
||
|
|
25ccc208d7
|
||
|
|
9c7e20d27d
|
||
|
|
6206fdbf43
|
||
|
|
9e48d97dc8
|
@@ -13,7 +13,7 @@ ROOT_COMPILATION_GID ?= 65534
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
cd src/bpm; $(GO) build $(GOFLAGS) -ldflags "-w -X 'git.enumerated.dev/bubble-package-manager/bpm/src/bpm/config.BpmVersion=$(VERSION)' -X 'git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib.rootCompilationUID=$(ROOT_COMPILATION_UID)' -X 'git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib.rootCompilationGID=$(ROOT_COMPILATION_GID)'" -o ../../build/bpm git.enumerated.dev/bubble-package-manager/bpm/src/bpm
|
cd src/bpm; $(GO) build $(GOFLAGS) -ldflags "-w -X 'main.BpmVersion=$(VERSION)' -X 'github.com/EnumeratedDev/bpm/src/bpmlib.rootCompilationUID=$(ROOT_COMPILATION_UID)' -X 'github.com/EnumeratedDev/bpm/src/bpmlib.rootCompilationGID=$(ROOT_COMPILATION_GID)'" -o ../../build/bpm bpm
|
||||||
|
|
||||||
install: build/bpm config/
|
install: build/bpm config/
|
||||||
# Create directory
|
# Create directory
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
package config
|
|
||||||
|
|
||||||
var BpmVersion = "dev"
|
|
||||||
+3
-3
@@ -1,14 +1,14 @@
|
|||||||
module git.enumerated.dev/bubble-package-manager/bpm/src/bpm
|
module bpm
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib v0.5.0
|
github.com/EnumeratedDev/bpm/src/bpmlib v0.0.0
|
||||||
github.com/lithammer/fuzzysearch v1.1.8
|
github.com/lithammer/fuzzysearch v1.1.8
|
||||||
github.com/spf13/pflag v1.0.10
|
github.com/spf13/pflag v1.0.10
|
||||||
)
|
)
|
||||||
|
|
||||||
replace git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib => ../bpmlib
|
replace github.com/EnumeratedDev/bpm/src/bpmlib => ../bpmlib
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/drone/envsubst v1.0.3 // indirect
|
github.com/drone/envsubst v1.0.3 // indirect
|
||||||
|
|||||||
+11
-6
@@ -14,8 +14,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.enumerated.dev/bubble-package-manager/bpm/src/bpm/config"
|
"github.com/EnumeratedDev/bpm/src/bpmlib"
|
||||||
"git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib"
|
|
||||||
|
|
||||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
@@ -26,6 +25,8 @@ import (
|
|||||||
/* A simple-to-use package manager */
|
/* A simple-to-use package manager */
|
||||||
/* ------------------------------------------------------- */
|
/* ------------------------------------------------------- */
|
||||||
|
|
||||||
|
var BpmVersion = "dev"
|
||||||
|
|
||||||
var currentFlagSet *flag.FlagSet
|
var currentFlagSet *flag.FlagSet
|
||||||
|
|
||||||
var exitCode = 0
|
var exitCode = 0
|
||||||
@@ -47,7 +48,7 @@ func main() {
|
|||||||
switch subcommand {
|
switch subcommand {
|
||||||
case "v", "version":
|
case "v", "version":
|
||||||
fmt.Println("Bubble Package Manager (BPM)")
|
fmt.Println("Bubble Package Manager (BPM)")
|
||||||
fmt.Println("Version: " + config.BpmVersion)
|
fmt.Println("Version: " + BpmVersion)
|
||||||
case "q", "query":
|
case "q", "query":
|
||||||
// Setup flags and help
|
// Setup flags and help
|
||||||
currentFlagSet = flag.NewFlagSet("query", flag.ExitOnError)
|
currentFlagSet = flag.NewFlagSet("query", flag.ExitOnError)
|
||||||
@@ -137,6 +138,7 @@ func main() {
|
|||||||
currentFlagSet.BoolP("force", "f", false, "Bypass warnings during package update")
|
currentFlagSet.BoolP("force", "f", false, "Bypass warnings during package update")
|
||||||
currentFlagSet.BoolP("yes", "y", false, "Enter 'yes' in all prompts")
|
currentFlagSet.BoolP("yes", "y", false, "Enter 'yes' in all prompts")
|
||||||
currentFlagSet.BoolP("no-sync", "n", false, "Do not sync databases")
|
currentFlagSet.BoolP("no-sync", "n", false, "Do not sync databases")
|
||||||
|
currentFlagSet.Bool("allow-downgrades", false, "Allow package downgrades")
|
||||||
currentFlagSet.BoolP("optional", "o", false, "Install all optional dependencies")
|
currentFlagSet.BoolP("optional", "o", false, "Install all optional dependencies")
|
||||||
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Update installed packages", os.Args[2:])
|
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Update installed packages", os.Args[2:])
|
||||||
|
|
||||||
@@ -625,7 +627,7 @@ func installPackages() {
|
|||||||
// Show optional dependencies
|
// Show optional dependencies
|
||||||
if !installOptional && len(optionalDepends) != 0 {
|
if !installOptional && len(optionalDepends) != 0 {
|
||||||
// List optional dependencies
|
// List optional dependencies
|
||||||
fmt.Println("The following opitonal dependenices have been discovered:")
|
fmt.Println("The following optional dependenices have been discovered:")
|
||||||
for dependant, depends := range optionalDepends {
|
for dependant, depends := range optionalDepends {
|
||||||
fmt.Printf("%s: \n", dependant)
|
fmt.Printf("%s: \n", dependant)
|
||||||
for _, depend := range depends {
|
for _, depend := range depends {
|
||||||
@@ -894,6 +896,7 @@ func updatePackages() {
|
|||||||
force, _ := currentFlagSet.GetBool("force")
|
force, _ := currentFlagSet.GetBool("force")
|
||||||
yesAll, _ := currentFlagSet.GetBool("yes")
|
yesAll, _ := currentFlagSet.GetBool("yes")
|
||||||
noSync, _ := currentFlagSet.GetBool("no-sync")
|
noSync, _ := currentFlagSet.GetBool("no-sync")
|
||||||
|
allowDowngrades, _ := currentFlagSet.GetBool("allow-downgrades")
|
||||||
installOptional, _ := currentFlagSet.GetBool("optional")
|
installOptional, _ := currentFlagSet.GetBool("optional")
|
||||||
|
|
||||||
// Check for required permissions
|
// Check for required permissions
|
||||||
@@ -932,7 +935,7 @@ func updatePackages() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create update operation
|
// Create update operation
|
||||||
operation, err := bpmlib.UpdatePackages(rootDir, !noSync, installOptional, force, verbose)
|
operation, err := bpmlib.UpdatePackages(rootDir, !noSync, allowDowngrades, installOptional, force, verbose)
|
||||||
if errors.As(err, &bpmlib.PackageNotFoundErr{}) || errors.As(err, &bpmlib.DependencyNotFoundErr{}) || errors.As(err, &bpmlib.PackageConflictErr{}) {
|
if errors.As(err, &bpmlib.PackageNotFoundErr{}) || errors.As(err, &bpmlib.DependencyNotFoundErr{}) || errors.As(err, &bpmlib.PackageConflictErr{}) {
|
||||||
log.Printf("Error: %s", err)
|
log.Printf("Error: %s", err)
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
@@ -1016,7 +1019,7 @@ func updatePackages() {
|
|||||||
// Show optional dependencies
|
// Show optional dependencies
|
||||||
if !installOptional && len(optionalDepends) != 0 {
|
if !installOptional && len(optionalDepends) != 0 {
|
||||||
// List optional dependencies
|
// List optional dependencies
|
||||||
fmt.Println("The following opitonal dependenices have been discovered:")
|
fmt.Println("The following optional dependenices have been discovered:")
|
||||||
for dependant, depends := range optionalDepends {
|
for dependant, depends := range optionalDepends {
|
||||||
fmt.Printf("%s: \n", dependant)
|
fmt.Printf("%s: \n", dependant)
|
||||||
for _, depend := range depends {
|
for _, depend := range depends {
|
||||||
@@ -1100,6 +1103,8 @@ func getFileOwner() {
|
|||||||
// Print packages
|
// Print packages
|
||||||
if len(pkgList) == 0 {
|
if len(pkgList) == 0 {
|
||||||
fmt.Printf("%s (%s) is not owned by any packages!\n", absPath, pathType)
|
fmt.Printf("%s (%s) is not owned by any packages!\n", absPath, pathType)
|
||||||
|
exitCode = 1
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s (%s) is owned by the following packages:\n", absPath, pathType)
|
fmt.Printf("%s (%s) is owned by the following packages:\n", absPath, pathType)
|
||||||
for _, pkg := range pkgList {
|
for _, pkg := range pkgList {
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ func CompileSourcePackage(archiveFilename, outputDirectory string, skipChecks, k
|
|||||||
env = append(env, "BPM_PKG_NAME="+bpmpkg.PkgInfo.Name)
|
env = append(env, "BPM_PKG_NAME="+bpmpkg.PkgInfo.Name)
|
||||||
env = append(env, "BPM_PKG_VERSION="+bpmpkg.PkgInfo.Version)
|
env = append(env, "BPM_PKG_VERSION="+bpmpkg.PkgInfo.Version)
|
||||||
env = append(env, "BPM_PKG_REVISION="+strconv.Itoa(bpmpkg.PkgInfo.Revision))
|
env = append(env, "BPM_PKG_REVISION="+strconv.Itoa(bpmpkg.PkgInfo.Revision))
|
||||||
|
env = append(env, "BPM_PKG_URL="+bpmpkg.PkgInfo.Url)
|
||||||
env = append(env, "BPM_PKG_ARCH="+bpmpkg.PkgInfo.OutputArch)
|
env = append(env, "BPM_PKG_ARCH="+bpmpkg.PkgInfo.OutputArch)
|
||||||
env = append(env, CompilationBPMConfig.CompilationEnvironment...)
|
env = append(env, CompilationBPMConfig.CompilationEnvironment...)
|
||||||
|
|
||||||
@@ -434,10 +435,12 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
|
|||||||
// Replace variables
|
// Replace variables
|
||||||
replaceVars := func(s string) string {
|
replaceVars := func(s string) string {
|
||||||
switch s {
|
switch s {
|
||||||
case "BPM_PKG_VERSION":
|
|
||||||
return pkgInfo.Version
|
|
||||||
case "BPM_PKG_NAME":
|
case "BPM_PKG_NAME":
|
||||||
return pkgInfo.Name
|
return pkgInfo.Name
|
||||||
|
case "BPM_PKG_VERSION":
|
||||||
|
return pkgInfo.Version
|
||||||
|
case "BPM_PKG_URL":
|
||||||
|
return pkgInfo.Url
|
||||||
case "BPM_SOURCE":
|
case "BPM_SOURCE":
|
||||||
return path.Join(tempDirectory, "source/")
|
return path.Join(tempDirectory, "source/")
|
||||||
default:
|
default:
|
||||||
@@ -557,10 +560,12 @@ func downloadPackageFiles(pkgInfo *PackageInfo, tempDirectory string, verbose bo
|
|||||||
gitBranch := download.GitBranch
|
gitBranch := download.GitBranch
|
||||||
gitBranch, err := envsubst.Eval(gitBranch, func(s string) string {
|
gitBranch, err := envsubst.Eval(gitBranch, func(s string) string {
|
||||||
switch s {
|
switch s {
|
||||||
case "BPM_PKG_VERSION":
|
|
||||||
return pkgInfo.Version
|
|
||||||
case "BPM_PKG_NAME":
|
case "BPM_PKG_NAME":
|
||||||
return pkgInfo.Name
|
return pkgInfo.Name
|
||||||
|
case "BPM_PKG_VERSION":
|
||||||
|
return pkgInfo.Version
|
||||||
|
case "BPM_PKG_URL":
|
||||||
|
return pkgInfo.Url
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,11 +63,12 @@ func (db *configDatabase) ReadLocalDatabase() error {
|
|||||||
database.Name = db.Name
|
database.Name = db.Name
|
||||||
database.Source = db.Source
|
database.Source = db.Source
|
||||||
|
|
||||||
entriesToRemove := make([]string, 0)
|
|
||||||
for entryName, entry := range database.Entries {
|
for entryName, entry := range database.Entries {
|
||||||
entry.Database = database
|
entry.Database = database
|
||||||
|
|
||||||
if entry.Info.IsSplitPackage() {
|
if entry.Info.IsSplitPackage() {
|
||||||
|
delete(database.Entries, entryName)
|
||||||
|
|
||||||
// Handle split packages
|
// Handle split packages
|
||||||
for _, splitPkg := range entry.Info.SplitPackages {
|
for _, splitPkg := range entry.Info.SplitPackages {
|
||||||
// Turn split package into json data
|
// Turn split package into json data
|
||||||
@@ -106,9 +107,6 @@ func (db *configDatabase) ReadLocalDatabase() error {
|
|||||||
for _, p := range splitPkg.Provides {
|
for _, p := range splitPkg.Provides {
|
||||||
database.VirtualPackages[p] = append(database.VirtualPackages[p], splitPkg.Name)
|
database.VirtualPackages[p] = append(database.VirtualPackages[p], splitPkg.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add current entry to list for removal
|
|
||||||
entriesToRemove = append(entriesToRemove, entryName)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Add virtual packages to database
|
// Add virtual packages to database
|
||||||
@@ -118,11 +116,6 @@ func (db *configDatabase) ReadLocalDatabase() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove entries
|
|
||||||
for _, entryName := range entriesToRemove {
|
|
||||||
delete(database.Entries, entryName)
|
|
||||||
}
|
|
||||||
|
|
||||||
BPMDatabases[db.Name] = database
|
BPMDatabases[db.Name] = database
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -365,7 +365,7 @@ func CleanupCache(rootDir string, cleanupCompilationFiles, cleanupCompiledPackag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePackages fetches the newest versions of all installed packages from
|
// UpdatePackages fetches the newest versions of all installed packages from
|
||||||
func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependencies, forceInstallation, verbose bool) (operation *BPMOperation, err error) {
|
func UpdatePackages(rootDir string, syncDatabase bool, allowDowngrades bool, installOptionalDependencies, forceInstallation, verbose bool) (operation *BPMOperation, err error) {
|
||||||
// Sync databases
|
// Sync databases
|
||||||
if syncDatabase {
|
if syncDatabase {
|
||||||
err := SyncDatabase(verbose)
|
err := SyncDatabase(verbose)
|
||||||
@@ -419,7 +419,7 @@ func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependenci
|
|||||||
return nil, fmt.Errorf("could not get package info for package (%s)", pkg)
|
return nil, fmt.Errorf("could not get package info for package (%s)", pkg)
|
||||||
} else {
|
} else {
|
||||||
comparison := CompareVersions(entry.Info.GetFullVersion(), installedInfo.GetFullVersion())
|
comparison := CompareVersions(entry.Info.GetFullVersion(), installedInfo.GetFullVersion())
|
||||||
if comparison > 0 {
|
if (!allowDowngrades && comparison > 0) || (allowDowngrades && comparison != 0) {
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.AppendAction(&FetchPackageAction{
|
||||||
InstallationReason: GetInstallationReason(pkg, rootDir),
|
InstallationReason: GetInstallationReason(pkg, rootDir),
|
||||||
DatabaseEntry: entry,
|
DatabaseEntry: entry,
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
module git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib
|
module github.com/EnumeratedDev/bpm/src/bpmlib
|
||||||
|
|
||||||
go 1.24.0
|
go 1.24.0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user