diff --git a/src/bpmlib/dependencies.go b/src/bpmlib/dependencies.go index 42a1f83..edca714 100644 --- a/src/bpmlib/dependencies.go +++ b/src/bpmlib/dependencies.go @@ -5,7 +5,7 @@ import ( "strings" ) -func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string) (dependants []string) { +func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string, skipMultipleProviders bool) (dependants []string) { // Get installed package names pkgs, ok := localPackageInformation[rootDir] if !ok { @@ -37,6 +37,10 @@ func (pkgInfo *PackageInfo) GetPackageDependants(rootDir string) (dependants []s // Loop through each virtual package 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 if slices.ContainsFunc(installedPkg.Depends, func(n string) bool { return n == vpkg diff --git a/src/bpmlib/general.go b/src/bpmlib/general.go index 36f7699..7742f78 100644 --- a/src/bpmlib/general.go +++ b/src/bpmlib/general.go @@ -218,7 +218,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages .. continue } - dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir) + dependants := action.(*RemovePackageAction).BpmPackage.PkgInfo.GetPackageDependants(rootDir, true) packageDepndants[action.(*RemovePackageAction).BpmPackage.PkgInfo.Name] = dependants } diff --git a/src/bpmlib/operations.go b/src/bpmlib/operations.go index 0d204c5..65565c2 100644 --- a/src/bpmlib/operations.go +++ b/src/bpmlib/operations.go @@ -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 { // Get all installed packages installedPackageNames, err := GetInstalledPackages(operation.RootDir) diff --git a/src/bpmlib/packages.go b/src/bpmlib/packages.go index 210c675..1553043 100644 --- a/src/bpmlib/packages.go +++ b/src/bpmlib/packages.go @@ -627,7 +627,7 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string { 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) // Other package relations