diff --git a/src/bpmlib/operations.go b/src/bpmlib/operations.go index 8375e92..e2561d4 100644 --- a/src/bpmlib/operations.go +++ b/src/bpmlib/operations.go @@ -449,7 +449,7 @@ func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[st optionalDepends = make(map[string][]string) // Find all optional dependencies - for _, value := range slices.Clone(operation.Actions) { + for _, value := range operation.Actions { var pkgInfo *PackageInfo if value.GetActionType() == "install" { action := value.(*InstallPackageAction) @@ -467,7 +467,31 @@ func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[st dependName, _, _ := SplitPkgNameAndVersion(dependSplit[0]) // Skip if dependency is already installed - if IsPackageInstalled(dependName, operation.RootDir) { + if IsPackageInstalled(dependName, operation.RootDir) || len(GetVirtualPackageInfo(dependName, operation.RootDir)) > 0 { + continue + } + + // Skip if dependency is going to be installed + if slices.IndexFunc(operation.Actions, func(action OperationAction) bool { + var pkgInfo *PackageInfo + if action.GetActionType() == "install" { + action := action.(*InstallPackageAction) + pkgInfo = action.BpmPackage.PkgInfo + } else if action.GetActionType() == "fetch" { + action := action.(*FetchPackageAction) + pkgInfo = action.DatabaseEntry.Info + } else { + return false + } + + if pkgInfo.Name == dependName { + return true + } else if slices.Contains(pkgInfo.Provides, dependName) { + return true + } + + return false + }) != -1 { continue }