mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Improve optional dependency detection during package installation
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user