Rename BPM Repositories to BPM Databases
This commit is contained in:
parent
bf2b4e95ac
commit
815d0bb29a
@ -30,7 +30,7 @@ You are able to install bpm packages by typing the following:
|
|||||||
```sh
|
```sh
|
||||||
bpm install /path/to/package.bpm
|
bpm install /path/to/package.bpm
|
||||||
```
|
```
|
||||||
You can also use the package name directly if using repositories
|
You can also use the package name directly if using databases
|
||||||
```sh
|
```sh
|
||||||
bpm install package_name
|
bpm install package_name
|
||||||
```
|
```
|
||||||
@ -50,7 +50,7 @@ To remove all unused dependencies and clean cached files try using the cleanup c
|
|||||||
bpm cleanup
|
bpm cleanup
|
||||||
```
|
```
|
||||||
|
|
||||||
If using repositories, all packages can be updated using this simple command
|
If using databases, all packages can be updated using this simple command
|
||||||
```sh
|
```sh
|
||||||
bpm update
|
bpm update
|
||||||
```
|
```
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
ignore_packages: []
|
ignore_packages: []
|
||||||
privilege_escalator_cmd: "sudo"
|
privilege_escalator_cmd: "sudo"
|
||||||
compilation_env: []
|
compilation_env: []
|
||||||
repositories:
|
databases:
|
||||||
- name: example-repository
|
- name: example-database
|
||||||
source: https://my-repo.xyz/
|
source: https://my-database.xyz/
|
||||||
disabled: true
|
disabled: true
|
@ -39,7 +39,7 @@ var installationReason = ""
|
|||||||
var nosync = true
|
var nosync = true
|
||||||
var removeUnused = false
|
var removeUnused = false
|
||||||
var doCleanup = false
|
var doCleanup = false
|
||||||
var showRepoInfo = false
|
var showDatabaseInfo = false
|
||||||
var installSrcPkgDepends = false
|
var installSrcPkgDepends = false
|
||||||
var skipChecks = false
|
var skipChecks = false
|
||||||
var outputDirectory = ""
|
var outputDirectory = ""
|
||||||
@ -116,7 +116,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -125,13 +125,13 @@ func resolveCommand() {
|
|||||||
var info *bpmlib.PackageInfo
|
var info *bpmlib.PackageInfo
|
||||||
isFile := false
|
isFile := false
|
||||||
showInstallationReason := false
|
showInstallationReason := false
|
||||||
if showRepoInfo {
|
if showDatabaseInfo {
|
||||||
var err error
|
var err error
|
||||||
var entry *bpmlib.RepositoryEntry
|
var entry *bpmlib.BPMDatabaseEntry
|
||||||
entry, _, err = bpmlib.GetRepositoryEntry(pkg)
|
entry, _, err = bpmlib.GetDatabaseEntry(pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if entry = bpmlib.ResolveVirtualPackage(pkg); entry == nil {
|
if entry = bpmlib.ResolveVirtualPackage(pkg); entry == nil {
|
||||||
log.Fatalf("Error: could not find package (%s) in any repository\n", pkg)
|
log.Fatalf("Error: could not find package (%s) in any database\n", pkg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info = entry.Info
|
info = entry.Info
|
||||||
@ -167,7 +167,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
case list:
|
case list:
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -215,8 +215,8 @@ func resolveCommand() {
|
|||||||
for i, term := range searchTerms {
|
for i, term := range searchTerms {
|
||||||
nameResults := make([]*bpmlib.PackageInfo, 0)
|
nameResults := make([]*bpmlib.PackageInfo, 0)
|
||||||
descResults := make([]*bpmlib.PackageInfo, 0)
|
descResults := make([]*bpmlib.PackageInfo, 0)
|
||||||
for _, repo := range bpmlib.BPMConfig.Repositories {
|
for _, db := range bpmlib.BPMConfig.Databases {
|
||||||
for _, entry := range repo.Entries {
|
for _, entry := range db.Entries {
|
||||||
if strings.Contains(entry.Info.Name, term) {
|
if strings.Contains(entry.Info.Name, term) {
|
||||||
nameResults = append(nameResults, entry.Info)
|
nameResults = append(nameResults, entry.Info)
|
||||||
} else if strings.Contains(entry.Info.Description, term) {
|
} else if strings.Contains(entry.Info.Description, term) {
|
||||||
@ -271,7 +271,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -329,7 +329,7 @@ func resolveCommand() {
|
|||||||
|
|
||||||
// Read local databases if no sync
|
// Read local databases if no sync
|
||||||
if nosync {
|
if nosync {
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -411,7 +411,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -469,7 +469,7 @@ func resolveCommand() {
|
|||||||
|
|
||||||
if cleanupDependencies {
|
if cleanupDependencies {
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ func resolveCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read local databases
|
// Read local databases
|
||||||
err := bpmlib.ReadLocalDatabases()
|
err := bpmlib.ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error: could not read local databases: %s", err)
|
log.Fatalf("Error: could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ func resolveCommand() {
|
|||||||
} else {
|
} else {
|
||||||
// Ensure the required dependencies are installed
|
// Ensure the required dependencies are installed
|
||||||
if len(unmetDepends) != 0 {
|
if len(unmetDepends) != 0 {
|
||||||
log.Fatalf("Error: could not resolve dependencies: the following dependencies were not found in any repositories: " + strings.Join(unmetDepends, ", "))
|
log.Fatalf("Error: could not resolve dependencies: the following dependencies were not found in any databases: " + strings.Join(unmetDepends, ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,14 +738,14 @@ func printHelp() {
|
|||||||
fmt.Println("-> flags will be read if passed right after the subcommand otherwise they will be read as subcommand arguments")
|
fmt.Println("-> flags will be read if passed right after the subcommand otherwise they will be read as subcommand arguments")
|
||||||
fmt.Println("\033[1m---- Command List ----\033[0m")
|
fmt.Println("\033[1m---- Command List ----\033[0m")
|
||||||
fmt.Println("-> bpm version | shows information on the installed version of bpm")
|
fmt.Println("-> bpm version | shows information on the installed version of bpm")
|
||||||
fmt.Println("-> bpm info [-R, --repos] <packages...> | shows information on an installed package")
|
fmt.Println("-> bpm info [-R, --databases] <packages...> | shows information on an installed package")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" --repos show information on package in repository")
|
fmt.Println(" --databases show information on package in configured databases")
|
||||||
fmt.Println("-> bpm list [-R, -c, -n] | lists all installed packages")
|
fmt.Println("-> bpm list [-R, -c, -n] | lists all installed packages")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -c lists the amount of installed packages")
|
fmt.Println(" -c lists the amount of installed packages")
|
||||||
fmt.Println(" -n lists only the names of installed packages")
|
fmt.Println(" -n lists only the names of installed packages")
|
||||||
fmt.Println("-> bpm search <search terms...> | Searches for packages through declared repositories")
|
fmt.Println("-> bpm search <search terms...> | Searches for packages through configured databases")
|
||||||
fmt.Println("-> bpm install [-R, -v, -y, -f, --reinstall, --reinstall-all, --no-optional, --installation-reason] <packages...> | installs the following files")
|
fmt.Println("-> bpm install [-R, -v, -y, -f, --reinstall, --reinstall-all, --no-optional, --installation-reason] <packages...> | installs the following files")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -v Show additional information about what BPM is doing")
|
fmt.Println(" -v Show additional information about what BPM is doing")
|
||||||
@ -755,7 +755,7 @@ func printHelp() {
|
|||||||
fmt.Println(" --reinstall-all Same as --reinstall but also reinstalls dependencies")
|
fmt.Println(" --reinstall-all Same as --reinstall but also reinstalls dependencies")
|
||||||
fmt.Println(" --no-optional Prevents installation of optional dependencies")
|
fmt.Println(" --no-optional Prevents installation of optional dependencies")
|
||||||
fmt.Println(" --installation-reason=<manual/dependency> sets the installation reason for all newly installed packages")
|
fmt.Println(" --installation-reason=<manual/dependency> sets the installation reason for all newly installed packages")
|
||||||
fmt.Println("-> bpm update [-R, -v, -y, -f, --reinstall, --no-sync] | updates all packages that are available in the repositories")
|
fmt.Println("-> bpm update [-R, -v, -y, -f, --reinstall, --no-sync] | updates all packages that are available in the configured databases")
|
||||||
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
fmt.Println(" -R=<path> lets you define the root path which will be used")
|
||||||
fmt.Println(" -v Show additional information about what BPM is doing")
|
fmt.Println(" -v Show additional information about what BPM is doing")
|
||||||
fmt.Println(" -y skips the confirmation prompt")
|
fmt.Println(" -y skips the confirmation prompt")
|
||||||
@ -779,7 +779,7 @@ func printHelp() {
|
|||||||
fmt.Println(" --depends performs a dependency cleanup")
|
fmt.Println(" --depends performs a dependency cleanup")
|
||||||
fmt.Println(" --compilation-files performs a cleanup of compilation files")
|
fmt.Println(" --compilation-files performs a cleanup of compilation files")
|
||||||
fmt.Println(" --compiled-pkgs performs a cleanup of compilation compiled binary packages")
|
fmt.Println(" --compiled-pkgs performs a cleanup of compilation compiled binary packages")
|
||||||
fmt.Println(" --fetched-pkgs performs a cleanup of fetched packages from repositories")
|
fmt.Println(" --fetched-pkgs performs a cleanup of fetched packages from databases")
|
||||||
fmt.Println("-> bpm file [-R] <files...> | shows what packages the following packages are managed by")
|
fmt.Println("-> bpm file [-R] <files...> | shows what packages the following packages are managed by")
|
||||||
fmt.Println(" -R=<root_path> lets you define the root path which will be used")
|
fmt.Println(" -R=<root_path> lets you define the root path which will be used")
|
||||||
fmt.Println("-> bpm compile [-d, -s, -o] <source packages...> | Compile source BPM package")
|
fmt.Println("-> bpm compile [-d, -s, -o] <source packages...> | Compile source BPM package")
|
||||||
@ -802,7 +802,7 @@ func resolveFlags() {
|
|||||||
// Info flags
|
// Info flags
|
||||||
infoFlagSet := flag.NewFlagSet("Info flags", flag.ExitOnError)
|
infoFlagSet := flag.NewFlagSet("Info flags", flag.ExitOnError)
|
||||||
infoFlagSet.StringVar(&rootDir, "R", "/", "Set the destination root")
|
infoFlagSet.StringVar(&rootDir, "R", "/", "Set the destination root")
|
||||||
infoFlagSet.BoolVar(&showRepoInfo, "repos", false, "Show information on package in repository")
|
infoFlagSet.BoolVar(&showDatabaseInfo, "databases", false, "Show information on package in configured databases")
|
||||||
infoFlagSet.Usage = printHelp
|
infoFlagSet.Usage = printHelp
|
||||||
// Install flags
|
// Install flags
|
||||||
installFlagSet := flag.NewFlagSet("Install flags", flag.ExitOnError)
|
installFlagSet := flag.NewFlagSet("Install flags", flag.ExitOnError)
|
||||||
@ -845,7 +845,7 @@ func resolveFlags() {
|
|||||||
cleanupFlagSet.BoolVar(&cleanupDependencies, "depends", false, "Perform a dependency cleanup")
|
cleanupFlagSet.BoolVar(&cleanupDependencies, "depends", false, "Perform a dependency cleanup")
|
||||||
cleanupFlagSet.BoolVar(&cleanupCompilationFiles, "compilation-files", false, "Perform a cleanup of compilation files")
|
cleanupFlagSet.BoolVar(&cleanupCompilationFiles, "compilation-files", false, "Perform a cleanup of compilation files")
|
||||||
cleanupFlagSet.BoolVar(&cleanupCompiledPackages, "compiled-pkgs", false, "Perform a cleanup of compilation compiled binary packages")
|
cleanupFlagSet.BoolVar(&cleanupCompiledPackages, "compiled-pkgs", false, "Perform a cleanup of compilation compiled binary packages")
|
||||||
cleanupFlagSet.BoolVar(&cleanupFetchedPackages, "fetched-pkgs", false, "Perform a cleanup of fetched packages from repositories")
|
cleanupFlagSet.BoolVar(&cleanupFetchedPackages, "fetched-pkgs", false, "Perform a cleanup of fetched packages from databases")
|
||||||
cleanupFlagSet.Usage = printHelp
|
cleanupFlagSet.Usage = printHelp
|
||||||
// File flags
|
// File flags
|
||||||
fileFlagSet := flag.NewFlagSet("Remove flags", flag.ExitOnError)
|
fileFlagSet := flag.NewFlagSet("Remove flags", flag.ExitOnError)
|
||||||
|
@ -6,10 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type BPMConfigStruct struct {
|
type BPMConfigStruct struct {
|
||||||
IgnorePackages []string `yaml:"ignore_packages"`
|
IgnorePackages []string `yaml:"ignore_packages"`
|
||||||
PrivilegeEscalatorCmd string `yaml:"privilege_escalator_cmd"`
|
PrivilegeEscalatorCmd string `yaml:"privilege_escalator_cmd"`
|
||||||
CompilationEnvironment []string `yaml:"compilation_env"`
|
CompilationEnvironment []string `yaml:"compilation_env"`
|
||||||
Repositories []*Repository `yaml:"repositories"`
|
Databases []*BPMDatabase `yaml:"databases"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var BPMConfig BPMConfigStruct
|
var BPMConfig BPMConfigStruct
|
||||||
@ -30,9 +30,9 @@ func ReadConfig() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := len(BPMConfig.Repositories) - 1; i >= 0; i-- {
|
for i := len(BPMConfig.Databases) - 1; i >= 0; i-- {
|
||||||
if BPMConfig.Repositories[i].Disabled != nil && *BPMConfig.Repositories[i].Disabled {
|
if BPMConfig.Databases[i].Disabled != nil && *BPMConfig.Databases[i].Disabled {
|
||||||
BPMConfig.Repositories = append(BPMConfig.Repositories[:i], BPMConfig.Repositories[i+1:]...)
|
BPMConfig.Databases = append(BPMConfig.Databases[:i], BPMConfig.Databases[i+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,41 +12,41 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Repository struct {
|
type BPMDatabase struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Source string `yaml:"source"`
|
Source string `yaml:"source"`
|
||||||
Disabled *bool `yaml:"disabled"`
|
Disabled *bool `yaml:"disabled"`
|
||||||
Entries map[string]*RepositoryEntry
|
Entries map[string]*BPMDatabaseEntry
|
||||||
VirtualPackages map[string][]string
|
VirtualPackages map[string][]string
|
||||||
}
|
}
|
||||||
|
|
||||||
type RepositoryEntry struct {
|
type BPMDatabaseEntry struct {
|
||||||
Info *PackageInfo `yaml:"info"`
|
Info *PackageInfo `yaml:"info"`
|
||||||
Download string `yaml:"download"`
|
Download string `yaml:"download"`
|
||||||
DownloadSize uint64 `yaml:"download_size"`
|
DownloadSize uint64 `yaml:"download_size"`
|
||||||
InstalledSize uint64 `yaml:"installed_size"`
|
InstalledSize uint64 `yaml:"installed_size"`
|
||||||
Repository *Repository
|
Database *BPMDatabase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) ContainsPackage(pkg string) bool {
|
func (db *BPMDatabase) ContainsPackage(pkg string) bool {
|
||||||
_, ok := repo.Entries[pkg]
|
_, ok := db.Entries[pkg]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) ReadLocalDatabase() error {
|
func (db *BPMDatabase) ReadLocalDatabase() error {
|
||||||
repoFile := "/var/lib/bpm/repositories/" + repo.Name + ".bpmdb"
|
dbFile := "/var/lib/bpm/databases/" + db.Name + ".bpmdb"
|
||||||
if _, err := os.Stat(repoFile); err != nil {
|
if _, err := os.Stat(dbFile); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := os.ReadFile(repoFile)
|
bytes, err := os.ReadFile(dbFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
data := string(bytes)
|
data := string(bytes)
|
||||||
for _, b := range strings.Split(data, "---") {
|
for _, b := range strings.Split(data, "---") {
|
||||||
entry := RepositoryEntry{
|
entry := BPMDatabaseEntry{
|
||||||
Info: &PackageInfo{
|
Info: &PackageInfo{
|
||||||
Name: "",
|
Name: "",
|
||||||
Description: "",
|
Description: "",
|
||||||
@ -66,14 +66,14 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
Download: "",
|
Download: "",
|
||||||
DownloadSize: 0,
|
DownloadSize: 0,
|
||||||
InstalledSize: 0,
|
InstalledSize: 0,
|
||||||
Repository: repo,
|
Database: db,
|
||||||
}
|
}
|
||||||
err := yaml.Unmarshal([]byte(b), &entry)
|
err := yaml.Unmarshal([]byte(b), &entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create repository entries
|
// Create database entries
|
||||||
if entry.Info.IsSplitPackage() {
|
if entry.Info.IsSplitPackage() {
|
||||||
for _, splitPkg := range entry.Info.SplitPackages {
|
for _, splitPkg := range entry.Info.SplitPackages {
|
||||||
// Turn split package into json data
|
// Turn split package into json data
|
||||||
@ -100,26 +100,26 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
splitPkgClone.Url = entry.Info.Url
|
splitPkgClone.Url = entry.Info.Url
|
||||||
|
|
||||||
// Create entry for split package
|
// Create entry for split package
|
||||||
repo.Entries[splitPkg.Name] = &RepositoryEntry{
|
db.Entries[splitPkg.Name] = &BPMDatabaseEntry{
|
||||||
Info: &splitPkgClone,
|
Info: &splitPkgClone,
|
||||||
Download: entry.Download,
|
Download: entry.Download,
|
||||||
DownloadSize: entry.DownloadSize,
|
DownloadSize: entry.DownloadSize,
|
||||||
InstalledSize: 0,
|
InstalledSize: 0,
|
||||||
Repository: repo,
|
Database: db,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add virtual packages to repository
|
// Add virtual packages to database
|
||||||
for _, p := range splitPkg.Provides {
|
for _, p := range splitPkg.Provides {
|
||||||
repo.VirtualPackages[p] = append(repo.VirtualPackages[p], splitPkg.Name)
|
db.VirtualPackages[p] = append(db.VirtualPackages[p], splitPkg.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create entry for package
|
// Create entry for package
|
||||||
repo.Entries[entry.Info.Name] = &entry
|
db.Entries[entry.Info.Name] = &entry
|
||||||
|
|
||||||
// Add virtual packages to repository
|
// Add virtual packages to database
|
||||||
for _, p := range entry.Info.Provides {
|
for _, p := range entry.Info.Provides {
|
||||||
repo.VirtualPackages[p] = append(repo.VirtualPackages[p], entry.Info.Name)
|
db.VirtualPackages[p] = append(db.VirtualPackages[p], entry.Info.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +128,11 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) SyncLocalDatabase() error {
|
func (db *BPMDatabase) SyncLocalDatabaseFile() error {
|
||||||
repoFile := "/var/lib/bpm/repositories/" + repo.Name + ".bpmdb"
|
dbFile := "/var/lib/bpm/databases/" + db.Name + ".bpmdb"
|
||||||
|
|
||||||
// Get URL to database
|
// Get URL to database
|
||||||
u, err := url.JoinPath(repo.Source, "database.bpmdb")
|
u, err := url.JoinPath(db.Source, "database.bpmdb")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -147,20 +147,20 @@ func (repo *Repository) SyncLocalDatabase() error {
|
|||||||
// Load data into byte buffer
|
// Load data into byte buffer
|
||||||
buffer, err := io.ReadAll(resp.Body)
|
buffer, err := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
// Unmarshal data to ensure it is a valid BPM repository
|
// Unmarshal data to ensure it is a valid BPM database
|
||||||
err = yaml.Unmarshal(buffer, &Repository{})
|
err = yaml.Unmarshal(buffer, &BPMDatabase{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not decode repository: %s", err)
|
return fmt.Errorf("could not decode database: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create parent directories to repository file
|
// Create parent directories to database file
|
||||||
err = os.MkdirAll(path.Dir(repoFile), 0755)
|
err = os.MkdirAll(path.Dir(dbFile), 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create file and save repository data
|
// Create file and save database data
|
||||||
out, err := os.Create(repoFile)
|
out, err := os.Create(dbFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -171,14 +171,14 @@ func (repo *Repository) SyncLocalDatabase() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadLocalDatabases() (err error) {
|
func ReadLocalDatabaseFiles() (err error) {
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
// Initialize struct values
|
// Initialize struct values
|
||||||
repo.Entries = make(map[string]*RepositoryEntry)
|
db.Entries = make(map[string]*BPMDatabaseEntry)
|
||||||
repo.VirtualPackages = make(map[string][]string)
|
db.VirtualPackages = make(map[string][]string)
|
||||||
|
|
||||||
// Read database
|
// Read database
|
||||||
err = repo.ReadLocalDatabase()
|
err = db.ReadLocalDatabase()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -187,47 +187,47 @@ func ReadLocalDatabases() (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRepository(name string) *Repository {
|
func GetDatabase(name string) *BPMDatabase {
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
if repo.Name == name {
|
if db.Name == name {
|
||||||
return repo
|
return db
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRepositoryEntry(str string) (*RepositoryEntry, *Repository, error) {
|
func GetDatabaseEntry(str string) (*BPMDatabaseEntry, *BPMDatabase, error) {
|
||||||
split := strings.Split(str, "/")
|
split := strings.Split(str, "/")
|
||||||
if len(split) == 1 {
|
if len(split) == 1 {
|
||||||
pkgName := strings.TrimSpace(split[0])
|
pkgName := strings.TrimSpace(split[0])
|
||||||
if pkgName == "" {
|
if pkgName == "" {
|
||||||
return nil, nil, errors.New("could not find repository entry for this package")
|
return nil, nil, errors.New("could not find database entry for this package")
|
||||||
}
|
}
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
if repo.ContainsPackage(pkgName) {
|
if db.ContainsPackage(pkgName) {
|
||||||
return repo.Entries[pkgName], repo, nil
|
return db.Entries[pkgName], db, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil, nil, errors.New("could not find repository entry for this package")
|
return nil, nil, errors.New("could not find database entry for this package")
|
||||||
} else if len(split) == 2 {
|
} else if len(split) == 2 {
|
||||||
repoName := strings.TrimSpace(split[0])
|
dbName := strings.TrimSpace(split[0])
|
||||||
pkgName := strings.TrimSpace(split[1])
|
pkgName := strings.TrimSpace(split[1])
|
||||||
if repoName == "" || pkgName == "" {
|
if dbName == "" || pkgName == "" {
|
||||||
return nil, nil, errors.New("could not find repository entry for this package")
|
return nil, nil, errors.New("could not find database entry for this package")
|
||||||
}
|
}
|
||||||
repo := GetRepository(repoName)
|
db := GetDatabase(dbName)
|
||||||
if repo == nil || !repo.ContainsPackage(pkgName) {
|
if db == nil || !db.ContainsPackage(pkgName) {
|
||||||
return nil, nil, errors.New("could not find repository entry for this package")
|
return nil, nil, errors.New("could not find database entry for this package")
|
||||||
}
|
}
|
||||||
return repo.Entries[pkgName], repo, nil
|
return db.Entries[pkgName], db, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, nil, errors.New("could not find repository entry for this package")
|
return nil, nil, errors.New("could not find database entry for this package")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func FindReplacement(pkg string) *RepositoryEntry {
|
func FindReplacement(pkg string) *BPMDatabaseEntry {
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
for _, entry := range repo.Entries {
|
for _, entry := range db.Entries {
|
||||||
for _, replaced := range entry.Info.Replaces {
|
for _, replaced := range entry.Info.Replaces {
|
||||||
if replaced == pkg {
|
if replaced == pkg {
|
||||||
return entry
|
return entry
|
||||||
@ -239,11 +239,11 @@ func FindReplacement(pkg string) *RepositoryEntry {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResolveVirtualPackage(vpkg string) *RepositoryEntry {
|
func ResolveVirtualPackage(vpkg string) *BPMDatabaseEntry {
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
if v, ok := repo.VirtualPackages[vpkg]; ok {
|
if v, ok := db.VirtualPackages[vpkg]; ok {
|
||||||
for _, pkg := range v {
|
for _, pkg := range v {
|
||||||
return repo.Entries[pkg]
|
return db.Entries[pkg]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,12 +251,12 @@ func ResolveVirtualPackage(vpkg string) *RepositoryEntry {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) FetchPackage(pkg string) (string, error) {
|
func (db *BPMDatabase) FetchPackage(pkg string) (string, error) {
|
||||||
if !repo.ContainsPackage(pkg) {
|
if !db.ContainsPackage(pkg) {
|
||||||
return "", errors.New("could not fetch package '" + pkg + "'")
|
return "", errors.New("could not fetch package '" + pkg + "'")
|
||||||
}
|
}
|
||||||
entry := repo.Entries[pkg]
|
entry := db.Entries[pkg]
|
||||||
URL, err := url.JoinPath(repo.Source, entry.Download)
|
URL, err := url.JoinPath(db.Source, entry.Download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
@ -94,8 +94,8 @@ func resolvePackageDependenciesFromDatabase(resolved, unresolved *[]string, pkgI
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
var entry *RepositoryEntry
|
var entry *BPMDatabaseEntry
|
||||||
entry, _, err = GetRepositoryEntry(depend)
|
entry, _, err = GetDatabaseEntry(depend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if entry = ResolveVirtualPackage(depend); entry == nil {
|
if entry = ResolveVirtualPackage(depend); entry == nil {
|
||||||
if !slices.Contains(*unresolved, depend) {
|
if !slices.Contains(*unresolved, depend) {
|
||||||
|
@ -10,7 +10,7 @@ type PackageNotFoundErr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e PackageNotFoundErr) Error() string {
|
func (e PackageNotFoundErr) Error() string {
|
||||||
return "The following packages were not found in any repositories: " + strings.Join(e.packages, ", ")
|
return "The following packages were not found in any databases: " + strings.Join(e.packages, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
type DependencyNotFoundErr struct {
|
type DependencyNotFoundErr struct {
|
||||||
@ -18,7 +18,7 @@ type DependencyNotFoundErr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e DependencyNotFoundErr) Error() string {
|
func (e DependencyNotFoundErr) Error() string {
|
||||||
return "The following dependencies were not found in any repositories: " + strings.Join(e.dependencies, ", ")
|
return "The following dependencies were not found in any databases: " + strings.Join(e.dependencies, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
type PackageConflictErr struct {
|
type PackageConflictErr struct {
|
||||||
|
@ -17,7 +17,7 @@ const (
|
|||||||
ReinstallMethodAll ReinstallMethod = iota
|
ReinstallMethodAll ReinstallMethod = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
// InstallPackages installs the specified packages into the given root directory by fetching them from repositories or directly from local bpm archives
|
// InstallPackages installs the specified packages into the given root directory by fetching them from databases or directly from local bpm archives
|
||||||
func InstallPackages(rootDir string, installationReason InstallationReason, reinstallMethod ReinstallMethod, installOptionalDependencies, forceInstallation, verbose bool, packages ...string) (operation *BPMOperation, err error) {
|
func InstallPackages(rootDir string, installationReason InstallationReason, reinstallMethod ReinstallMethod, installOptionalDependencies, forceInstallation, verbose bool, packages ...string) (operation *BPMOperation, err error) {
|
||||||
// Setup operation struct
|
// Setup operation struct
|
||||||
operation = &BPMOperation{
|
operation = &BPMOperation{
|
||||||
@ -64,12 +64,12 @@ func InstallPackages(rootDir string, installationReason InstallationReason, rein
|
|||||||
BpmPackage: bpmpkg,
|
BpmPackage: bpmpkg,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
var entry *RepositoryEntry
|
var entry *BPMDatabaseEntry
|
||||||
|
|
||||||
if e, _, err := GetRepositoryEntry(pkg); err == nil {
|
if e, _, err := GetDatabaseEntry(pkg); err == nil {
|
||||||
entry = e
|
entry = e
|
||||||
} else if isVirtual, p := IsVirtualPackage(pkg, rootDir); isVirtual {
|
} else if isVirtual, p := IsVirtualPackage(pkg, rootDir); isVirtual {
|
||||||
entry, _, err = GetRepositoryEntry(p)
|
entry, _, err = GetDatabaseEntry(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pkgsNotFound = append(pkgsNotFound, pkg)
|
pkgsNotFound = append(pkgsNotFound, pkg)
|
||||||
continue
|
continue
|
||||||
@ -85,8 +85,8 @@ func InstallPackages(rootDir string, installationReason InstallationReason, rein
|
|||||||
}
|
}
|
||||||
|
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.AppendAction(&FetchPackageAction{
|
||||||
IsDependency: false,
|
IsDependency: false,
|
||||||
RepositoryEntry: entry,
|
DatabaseEntry: entry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,7 +272,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, installOptionalDependencies, forceInstallation, verbose bool) (operation *BPMOperation, err error) {
|
||||||
// Sync repositories
|
// Sync databases
|
||||||
if syncDatabase {
|
if syncDatabase {
|
||||||
err := SyncDatabase(verbose)
|
err := SyncDatabase(verbose)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -287,7 +287,7 @@ func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependenci
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not read BPM config: %s", err)
|
return nil, fmt.Errorf("could not read BPM config: %s", err)
|
||||||
}
|
}
|
||||||
err = ReadLocalDatabases()
|
err = ReadLocalDatabaseFiles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not read local databases: %s", err)
|
return nil, fmt.Errorf("could not read local databases: %s", err)
|
||||||
}
|
}
|
||||||
@ -313,11 +313,11 @@ func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependenci
|
|||||||
if slices.Contains(BPMConfig.IgnorePackages, pkg) {
|
if slices.Contains(BPMConfig.IgnorePackages, pkg) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var entry *RepositoryEntry
|
var entry *BPMDatabaseEntry
|
||||||
// Check if installed package can be replaced and install that instead
|
// Check if installed package can be replaced and install that instead
|
||||||
if e := FindReplacement(pkg); e != nil {
|
if e := FindReplacement(pkg); e != nil {
|
||||||
entry = e
|
entry = e
|
||||||
} else if entry, _, err = GetRepositoryEntry(pkg); err != nil {
|
} else if entry, _, err = GetDatabaseEntry(pkg); err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,8 +328,8 @@ func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependenci
|
|||||||
comparison := ComparePackageVersions(*entry.Info, *installedInfo)
|
comparison := ComparePackageVersions(*entry.Info, *installedInfo)
|
||||||
if comparison > 0 {
|
if comparison > 0 {
|
||||||
operation.AppendAction(&FetchPackageAction{
|
operation.AppendAction(&FetchPackageAction{
|
||||||
IsDependency: false,
|
IsDependency: false,
|
||||||
RepositoryEntry: entry,
|
DatabaseEntry: entry,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,12 +355,12 @@ func UpdatePackages(rootDir string, syncDatabase bool, installOptionalDependenci
|
|||||||
|
|
||||||
// SyncDatabase syncs all databases declared in /etc/bpm.conf
|
// SyncDatabase syncs all databases declared in /etc/bpm.conf
|
||||||
func SyncDatabase(verbose bool) (err error) {
|
func SyncDatabase(verbose bool) (err error) {
|
||||||
for _, repo := range BPMConfig.Repositories {
|
for _, db := range BPMConfig.Databases {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Printf("Fetching package database for repository (%s)...\n", repo.Name)
|
fmt.Printf("Fetching package database file for database (%s)...\n", db.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := repo.SyncLocalDatabase()
|
err := db.SyncLocalDatabaseFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ func (operation *BPMOperation) ActionsContainPackage(pkg string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else if action.GetActionType() == "fetch" {
|
} else if action.GetActionType() == "fetch" {
|
||||||
if action.(*FetchPackageAction).RepositoryEntry.Info.Name == pkg {
|
if action.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else if action.GetActionType() == "remove" {
|
} else if action.GetActionType() == "remove" {
|
||||||
@ -58,7 +58,7 @@ func (operation *BPMOperation) InsertActionAt(index int, action OperationAction)
|
|||||||
operation.Changes[pkgInfo.Name] = "upgrade"
|
operation.Changes[pkgInfo.Name] = "upgrade"
|
||||||
}
|
}
|
||||||
} else if action.GetActionType() == "fetch" {
|
} else if action.GetActionType() == "fetch" {
|
||||||
pkgInfo := action.(*FetchPackageAction).RepositoryEntry.Info
|
pkgInfo := action.(*FetchPackageAction).DatabaseEntry.Info
|
||||||
if !IsPackageInstalled(pkgInfo.Name, operation.RootDir) {
|
if !IsPackageInstalled(pkgInfo.Name, operation.RootDir) {
|
||||||
operation.Changes[pkgInfo.Name] = "install"
|
operation.Changes[pkgInfo.Name] = "install"
|
||||||
} else {
|
} else {
|
||||||
@ -77,7 +77,7 @@ func (operation *BPMOperation) RemoveAction(pkg, actionType string) {
|
|||||||
if a.GetActionType() == "install" {
|
if a.GetActionType() == "install" {
|
||||||
return a.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg
|
return a.(*InstallPackageAction).BpmPackage.PkgInfo.Name == pkg
|
||||||
} else if a.GetActionType() == "fetch" {
|
} else if a.GetActionType() == "fetch" {
|
||||||
return a.(*FetchPackageAction).RepositoryEntry.Info.Name == pkg
|
return a.(*FetchPackageAction).DatabaseEntry.Info.Name == pkg
|
||||||
} else if a.GetActionType() == "remove" {
|
} else if a.GetActionType() == "remove" {
|
||||||
return a.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg
|
return a.(*RemovePackageAction).BpmPackage.PkgInfo.Name == pkg
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func (operation *BPMOperation) GetTotalDownloadSize() uint64 {
|
|||||||
var ret uint64 = 0
|
var ret uint64 = 0
|
||||||
for _, action := range operation.Actions {
|
for _, action := range operation.Actions {
|
||||||
if action.GetActionType() == "fetch" {
|
if action.GetActionType() == "fetch" {
|
||||||
ret += action.(*FetchPackageAction).RepositoryEntry.DownloadSize
|
ret += action.(*FetchPackageAction).DatabaseEntry.DownloadSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
@ -101,7 +101,7 @@ func (operation *BPMOperation) GetTotalInstalledSize() uint64 {
|
|||||||
if action.GetActionType() == "install" {
|
if action.GetActionType() == "install" {
|
||||||
ret += action.(*InstallPackageAction).BpmPackage.GetInstalledSize()
|
ret += action.(*InstallPackageAction).BpmPackage.GetInstalledSize()
|
||||||
} else if action.GetActionType() == "fetch" {
|
} else if action.GetActionType() == "fetch" {
|
||||||
ret += action.(*FetchPackageAction).RepositoryEntry.InstalledSize
|
ret += action.(*FetchPackageAction).DatabaseEntry.InstalledSize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
@ -116,7 +116,7 @@ func (operation *BPMOperation) GetFinalActionSize(rootDir string) int64 {
|
|||||||
ret -= int64(GetPackage(action.(*InstallPackageAction).BpmPackage.PkgInfo.Name, rootDir).GetInstalledSize())
|
ret -= int64(GetPackage(action.(*InstallPackageAction).BpmPackage.PkgInfo.Name, rootDir).GetInstalledSize())
|
||||||
}
|
}
|
||||||
} else if action.GetActionType() == "fetch" {
|
} else if action.GetActionType() == "fetch" {
|
||||||
ret += int64(action.(*FetchPackageAction).RepositoryEntry.InstalledSize)
|
ret += int64(action.(*FetchPackageAction).DatabaseEntry.InstalledSize)
|
||||||
} else if action.GetActionType() == "remove" {
|
} else if action.GetActionType() == "remove" {
|
||||||
ret -= int64(action.(*RemovePackageAction).BpmPackage.GetInstalledSize())
|
ret -= int64(action.(*RemovePackageAction).BpmPackage.GetInstalledSize())
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, instal
|
|||||||
pkgInfo = action.BpmPackage.PkgInfo
|
pkgInfo = action.BpmPackage.PkgInfo
|
||||||
} else if value.GetActionType() == "fetch" {
|
} else if value.GetActionType() == "fetch" {
|
||||||
action := value.(*FetchPackageAction)
|
action := value.(*FetchPackageAction)
|
||||||
pkgInfo = action.RepositoryEntry.Info
|
pkgInfo = action.DatabaseEntry.Info
|
||||||
} else {
|
} else {
|
||||||
pos++
|
pos++
|
||||||
continue
|
continue
|
||||||
@ -148,13 +148,13 @@ func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, instal
|
|||||||
if !reinstallDependencies && IsPackageInstalled(depend, operation.RootDir) {
|
if !reinstallDependencies && IsPackageInstalled(depend, operation.RootDir) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
entry, _, err := GetRepositoryEntry(depend)
|
entry, _, err := GetDatabaseEntry(depend)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New("could not get repository entry for package (" + depend + ")")
|
return errors.New("could not get database entry for package (" + depend + ")")
|
||||||
}
|
}
|
||||||
operation.InsertActionAt(pos, &FetchPackageAction{
|
operation.InsertActionAt(pos, &FetchPackageAction{
|
||||||
IsDependency: true,
|
IsDependency: true,
|
||||||
RepositoryEntry: entry,
|
DatabaseEntry: entry,
|
||||||
})
|
})
|
||||||
pos++
|
pos++
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ func (operation *BPMOperation) ReplaceObsoletePackages() {
|
|||||||
|
|
||||||
} else if value.GetActionType() == "fetch" {
|
} else if value.GetActionType() == "fetch" {
|
||||||
action := value.(*FetchPackageAction)
|
action := value.(*FetchPackageAction)
|
||||||
pkgInfo = action.RepositoryEntry.Info
|
pkgInfo = action.DatabaseEntry.Info
|
||||||
} else {
|
} else {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ func (operation *BPMOperation) CheckForConflicts() (map[string][]string, error)
|
|||||||
allPackages = append(allPackages, pkgInfo)
|
allPackages = append(allPackages, pkgInfo)
|
||||||
} else if value.GetActionType() == "fetch" {
|
} else if value.GetActionType() == "fetch" {
|
||||||
action := value.(*FetchPackageAction)
|
action := value.(*FetchPackageAction)
|
||||||
pkgInfo := action.RepositoryEntry.Info
|
pkgInfo := action.DatabaseEntry.Info
|
||||||
allPackages = append(allPackages, pkgInfo)
|
allPackages = append(allPackages, pkgInfo)
|
||||||
} else if value.GetActionType() == "remove" {
|
} else if value.GetActionType() == "remove" {
|
||||||
action := value.(*RemovePackageAction)
|
action := value.(*RemovePackageAction)
|
||||||
@ -342,7 +342,7 @@ func (operation *BPMOperation) ShowOperationSummary() {
|
|||||||
pkgInfo = pkgInfo.GetSplitPackageInfo(value.(*InstallPackageAction).SplitPackageToInstall)
|
pkgInfo = pkgInfo.GetSplitPackageInfo(value.(*InstallPackageAction).SplitPackageToInstall)
|
||||||
}
|
}
|
||||||
} else if value.GetActionType() == "fetch" {
|
} else if value.GetActionType() == "fetch" {
|
||||||
pkgInfo = value.(*FetchPackageAction).RepositoryEntry.Info
|
pkgInfo = value.(*FetchPackageAction).DatabaseEntry.Info
|
||||||
} else {
|
} else {
|
||||||
pkgInfo = value.(*RemovePackageAction).BpmPackage.PkgInfo
|
pkgInfo = value.(*RemovePackageAction).BpmPackage.PkgInfo
|
||||||
fmt.Printf("%s: %s (Remove)\n", pkgInfo.Name, pkgInfo.GetFullVersion())
|
fmt.Printf("%s: %s (Remove)\n", pkgInfo.Name, pkgInfo.GetFullVersion())
|
||||||
@ -414,11 +414,11 @@ func (operation *BPMOperation) RunHooks(verbose bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (operation *BPMOperation) Execute(verbose, force bool) (err error) {
|
func (operation *BPMOperation) Execute(verbose, force bool) (err error) {
|
||||||
// Fetch packages from repositories
|
// Fetch packages from databases
|
||||||
if slices.ContainsFunc(operation.Actions, func(action OperationAction) bool {
|
if slices.ContainsFunc(operation.Actions, func(action OperationAction) bool {
|
||||||
return action.GetActionType() == "fetch"
|
return action.GetActionType() == "fetch"
|
||||||
}) {
|
}) {
|
||||||
fmt.Println("Fetching packages from available repositories...")
|
fmt.Println("Fetching packages from available databases...")
|
||||||
|
|
||||||
// Create map for fetched packages
|
// Create map for fetched packages
|
||||||
fetchedPackages := make(map[string]string)
|
fetchedPackages := make(map[string]string)
|
||||||
@ -428,16 +428,16 @@ func (operation *BPMOperation) Execute(verbose, force bool) (err error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get repository entry
|
// Get database entry
|
||||||
entry := action.(*FetchPackageAction).RepositoryEntry
|
entry := action.(*FetchPackageAction).DatabaseEntry
|
||||||
|
|
||||||
// Create bpmpkg variable
|
// Create bpmpkg variable
|
||||||
var bpmpkg *BPMPackage
|
var bpmpkg *BPMPackage
|
||||||
|
|
||||||
// Check if package has already been fetched from download link
|
// Check if package has already been fetched from download link
|
||||||
if _, ok := fetchedPackages[entry.Download]; !ok {
|
if _, ok := fetchedPackages[entry.Download]; !ok {
|
||||||
// Fetch package from repository
|
// Fetch package from database
|
||||||
fetchedPackage, err := entry.Repository.FetchPackage(entry.Info.Name)
|
fetchedPackage, err := entry.Database.FetchPackage(entry.Info.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New(fmt.Sprintf("could not fetch package (%s): %s\n", entry.Info.Name, err))
|
return errors.New(fmt.Sprintf("could not fetch package (%s): %s\n", entry.Info.Name, err))
|
||||||
}
|
}
|
||||||
@ -596,8 +596,8 @@ func (action *InstallPackageAction) GetActionType() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FetchPackageAction struct {
|
type FetchPackageAction struct {
|
||||||
IsDependency bool
|
IsDependency bool
|
||||||
RepositoryEntry *RepositoryEntry
|
DatabaseEntry *BPMDatabaseEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (action *FetchPackageAction) GetActionType() string {
|
func (action *FetchPackageAction) GetActionType() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user