mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-25 23:16:13 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b07a7f8778
|
||
|
|
b2fc963389
|
||
|
|
b27e9fb0df
|
||
|
|
089bc61d58
|
+1
-1
@@ -1141,7 +1141,7 @@ func compilePackage() {
|
|||||||
} else {
|
} else {
|
||||||
// Ensure the required dependencies are installed
|
// Ensure the required dependencies are installed
|
||||||
if len(unmetDepends) != 0 {
|
if len(unmetDepends) != 0 {
|
||||||
log.Printf("Error: could not resolve dependencies: the following dependencies were not found in any databases: " + strings.Join(unmetDepends, ", "))
|
log.Printf("Error: the following dependencies were not found in any databases: %s", strings.Join(unmetDepends, ", "))
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,35 @@ func (entry *BPMDatabaseEntry) GetEntryDependants() (dependants []string) {
|
|||||||
return dependants
|
return dependants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (entry *BPMDatabaseEntry) GetEntryOptionalDependants() (dependants []string) {
|
||||||
|
dependantsMap := make(map[string][]string)
|
||||||
|
for _, db := range BPMDatabases {
|
||||||
|
for _, e := range db.Entries {
|
||||||
|
if slices.Contains(e.Info.OptionalDepends, entry.Info.Name) {
|
||||||
|
dependantsMap[e.Info.Name] = append(dependantsMap[e.Info.Name], e.Database.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get keys
|
||||||
|
keySlice := slices.Collect(maps.Keys(dependantsMap))
|
||||||
|
slices.Sort(keySlice)
|
||||||
|
|
||||||
|
// Add all dependant entries to slice in alphabetical order
|
||||||
|
for _, entryName := range keySlice {
|
||||||
|
dbs := dependantsMap[entryName]
|
||||||
|
if len(dbs) > 1 {
|
||||||
|
for _, db := range dbs {
|
||||||
|
dependants = append(dependants, db+"/"+entryName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dependants = append(dependants, entryName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependants
|
||||||
|
}
|
||||||
|
|
||||||
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableSize bool) string {
|
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableSize bool) string {
|
||||||
ret := make([]string, 0)
|
ret := make([]string, 0)
|
||||||
appendArray := func(label string, array []string, sort bool) {
|
appendArray := func(label string, array []string, sort bool) {
|
||||||
@@ -339,6 +368,10 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableS
|
|||||||
if len(dependants) > 0 {
|
if len(dependants) > 0 {
|
||||||
appendArray("Dependant packages", dependants, false)
|
appendArray("Dependant packages", dependants, false)
|
||||||
}
|
}
|
||||||
|
optionalDependants := entry.GetEntryOptionalDependants()
|
||||||
|
if len(optionalDependants) > 0 {
|
||||||
|
appendArray("Optionally dependant packages", optionalDependants, false)
|
||||||
|
}
|
||||||
appendArray("Conflicting packages", entry.Info.Conflicts, true)
|
appendArray("Conflicting packages", entry.Info.Conflicts, true)
|
||||||
appendArray("Provided packages", entry.Info.Provides, true)
|
appendArray("Provided packages", entry.Info.Provides, true)
|
||||||
appendArray("Replaces packages", entry.Info.Replaces, true)
|
appendArray("Replaces packages", entry.Info.Replaces, true)
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeOptionalD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip ignored packages
|
||||||
|
allDepends = slices.DeleteFunc(allDepends, func(depend pkgInstallationReason) bool {
|
||||||
|
return slices.Contains(MainBPMConfig.IgnorePackages, depend.PkgName)
|
||||||
|
})
|
||||||
|
|
||||||
return allDepends
|
return allDepends
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,3 +217,46 @@ func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string) (dependants []s
|
|||||||
|
|
||||||
return dependants
|
return dependants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pkgInfo *PackageInfo) GetPackageOptionalDependants(rootDir string) (dependants []string) {
|
||||||
|
// Get installed package names
|
||||||
|
pkgs, err := GetInstalledPackages(rootDir)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through all installed packages
|
||||||
|
for _, installedPkgName := range pkgs {
|
||||||
|
// Get installed BPM package
|
||||||
|
installedPkg := GetPackage(installedPkgName, rootDir)
|
||||||
|
if installedPkg == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip iteration if comparing the same packages
|
||||||
|
if installedPkg.PkgInfo.Name == pkgInfo.Name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add installed package to list if its optional dependencies include pkgName
|
||||||
|
if slices.ContainsFunc(installedPkg.PkgInfo.OptionalDepends, func(n string) bool {
|
||||||
|
return n == pkgInfo.Name
|
||||||
|
}) {
|
||||||
|
dependants = append(dependants, installedPkgName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Loop through each virtual package
|
||||||
|
for _, vpkg := range pkgInfo.Provides {
|
||||||
|
// Add installed package to list if its optional dependencies contain a provided virtual package
|
||||||
|
if slices.ContainsFunc(installedPkg.PkgInfo.OptionalDepends, func(n string) bool {
|
||||||
|
return n == vpkg
|
||||||
|
}) {
|
||||||
|
dependants = append(dependants, installedPkgName)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dependants
|
||||||
|
}
|
||||||
|
|||||||
@@ -221,6 +221,11 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
// Get packages and their dependants
|
// Get packages and their dependants
|
||||||
packageDepndants := make(map[string][]string, 0)
|
packageDepndants := make(map[string][]string, 0)
|
||||||
for _, action := range operation.Actions {
|
for _, action := range operation.Actions {
|
||||||
|
// Skip package if ignored
|
||||||
|
if slices.Contains(MainBPMConfig.IgnorePackages, action.(*RemovePackageAction).BpmPackage.PkgInfo.Name) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir)
|
dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir)
|
||||||
packageDepndants[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = dependants
|
packageDepndants[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = dependants
|
||||||
}
|
}
|
||||||
@@ -234,6 +239,14 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
packageDepndants[pkg] = required
|
packageDepndants[pkg] = required
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove dependant packages if ignored
|
||||||
|
for pkg, required := range packageDepndants {
|
||||||
|
required = slices.DeleteFunc(required, func(pkgName string) bool {
|
||||||
|
return slices.Contains(MainBPMConfig.IgnorePackages, pkgName)
|
||||||
|
})
|
||||||
|
packageDepndants[pkg] = required
|
||||||
|
}
|
||||||
|
|
||||||
// Remove empty keys from map
|
// Remove empty keys from map
|
||||||
maps.DeleteFunc(packageDepndants, func(pkg string, required []string) bool {
|
maps.DeleteFunc(packageDepndants, func(pkg string, required []string) bool {
|
||||||
return len(required) == 0
|
return len(required) == 0
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
|||||||
keepPackages = append(keepPackages, pkg.Name)
|
keepPackages = append(keepPackages, pkg.Name)
|
||||||
resolved := pkg.GetDependenciesRecursive(!cleanupMakeDepends, operation.RootDir)
|
resolved := pkg.GetDependenciesRecursive(!cleanupMakeDepends, operation.RootDir)
|
||||||
for _, value := range resolved {
|
for _, value := range resolved {
|
||||||
if !slices.Contains(keepPackages, value) {
|
if !slices.Contains(keepPackages, value) && !slices.Contains(MainBPMConfig.IgnorePackages, value) {
|
||||||
keepPackages = append(keepPackages, value)
|
keepPackages = append(keepPackages, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -545,6 +545,10 @@ func (bpmpkg *BPMPackage) CreateReadableInfo(rootDir string, humanReadableSize b
|
|||||||
if len(dependants) > 0 {
|
if len(dependants) > 0 {
|
||||||
appendArray("Dependant packages", dependants)
|
appendArray("Dependant packages", dependants)
|
||||||
}
|
}
|
||||||
|
optionalDependants := bpmpkg.PkgInfo.GetPackageOptionalDependants(rootDir)
|
||||||
|
if len(optionalDependants) > 0 {
|
||||||
|
appendArray("Optionally dependant packages", optionalDependants)
|
||||||
|
}
|
||||||
appendArray("Conflicting packages", bpmpkg.PkgInfo.Conflicts)
|
appendArray("Conflicting packages", bpmpkg.PkgInfo.Conflicts)
|
||||||
appendArray("Provided packages", bpmpkg.PkgInfo.Provides)
|
appendArray("Provided packages", bpmpkg.PkgInfo.Provides)
|
||||||
appendArray("Replaces packages", bpmpkg.PkgInfo.Replaces)
|
appendArray("Replaces packages", bpmpkg.PkgInfo.Replaces)
|
||||||
|
|||||||
@@ -76,6 +76,15 @@ func createProgressBar(max int64, description string, hideBar bool) *progressbar
|
|||||||
output = os.Stderr
|
output = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(description) < 40 {
|
||||||
|
for i := len(description); i < 40; i++ {
|
||||||
|
description += " "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(description) > 40 {
|
||||||
|
description = description[:len(description)-5] + "..."
|
||||||
|
}
|
||||||
|
|
||||||
return progressbar.NewOptions64(max,
|
return progressbar.NewOptions64(max,
|
||||||
progressbar.OptionSetDescription(description),
|
progressbar.OptionSetDescription(description),
|
||||||
progressbar.OptionSetWriter(output),
|
progressbar.OptionSetWriter(output),
|
||||||
|
|||||||
Reference in New Issue
Block a user