mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Allow removal of packages that depend on virtual packages with more than 1 provider
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string) (dependants []string) {
|
func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string, skipMultipleProviders bool) (dependants []string) {
|
||||||
// Get installed package names
|
// Get installed package names
|
||||||
pkgs, ok := localPackageInformation[rootDir]
|
pkgs, ok := localPackageInformation[rootDir]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -37,6 +37,10 @@ func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string) (dependants []s
|
|||||||
|
|
||||||
// Loop through each virtual package
|
// Loop through each virtual package
|
||||||
for _, vpkg := range pkgInfo.Provides {
|
for _, vpkg := range pkgInfo.Provides {
|
||||||
|
if skipMultipleProviders && len(GetVirtualPackageInfo(vpkg, rootDir)) > 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Add installed package to list if its dependencies contain a provided virtual package
|
// Add installed package to list if its dependencies contain a provided virtual package
|
||||||
if slices.ContainsFunc(installedPkg.Depends, func(n string) bool {
|
if slices.ContainsFunc(installedPkg.Depends, func(n string) bool {
|
||||||
return n == vpkg
|
return n == vpkg
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages ..
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir)
|
dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir, true)
|
||||||
packageDepndants[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = dependants
|
packageDepndants[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = dependants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,30 +194,6 @@ func (operation *BPMOperation) ResolveDependencies(installRuntimeDepends bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (operation *BPMOperation) RemoveNeededPackages() error {
|
|
||||||
removeActions := make(map[string]*RemovePackageAction)
|
|
||||||
for _, action := range slices.Clone(operation.Actions) {
|
|
||||||
if action.GetActionType() == "remove" {
|
|
||||||
removeActions[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = action.(*RemovePackageAction)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for pkg, action := range removeActions {
|
|
||||||
dependants := action.BpmPackage.PkgInfo.GetPackageDependants(operation.RootDir)
|
|
||||||
dependants = slices.DeleteFunc(dependants, func(d string) bool {
|
|
||||||
if _, ok := removeActions[d]; ok {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
if len(dependants) != 0 {
|
|
||||||
operation.RemoveAction(pkg, action.GetActionType())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
||||||
// Get all installed packages
|
// Get all installed packages
|
||||||
installedPackageNames, err := GetInstalledPackages(operation.RootDir)
|
installedPackageNames, err := GetInstalledPackages(operation.RootDir)
|
||||||
|
|||||||
@@ -627,7 +627,7 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
|||||||
builder.WriteString("\n")
|
builder.WriteString("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builderWriteArray("Dependant packages", pkgInfo.GetPackageDependants(rootDir), true)
|
builderWriteArray("Dependant packages", pkgInfo.GetPackageDependants(rootDir, false), true)
|
||||||
builderWriteArray("Optionally dependant packages", pkgInfo.GetPackageOptionalDependants(rootDir), true)
|
builderWriteArray("Optionally dependant packages", pkgInfo.GetPackageOptionalDependants(rootDir), true)
|
||||||
|
|
||||||
// Other package relations
|
// Other package relations
|
||||||
|
|||||||
Reference in New Issue
Block a user