From cb01c96ad63e3f226d04021d7107ccd3e0e37314 Mon Sep 17 00:00:00 2001 From: EnumDev Date: Mon, 22 Jun 2026 13:56:03 +0300 Subject: [PATCH] Improve update operation new dependency resolution --- src/bpmlib/general.go | 116 ++++-------------------------------------- 1 file changed, 9 insertions(+), 107 deletions(-) diff --git a/src/bpmlib/general.go b/src/bpmlib/general.go index 9f7f6a4..541827c 100644 --- a/src/bpmlib/general.go +++ b/src/bpmlib/general.go @@ -411,12 +411,12 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla } // Search for packages - pkgsNotFound := make([]string, 0) resolvedVirtualPackages := make(map[string]string) for _, pkg := range pkgs { if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, pkg) { continue } + var entry *BPMDatabaseEntry // Check if installed package can be replaced and install that instead if e := FindReplacement(pkg); e != nil { @@ -443,115 +443,17 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla DatabaseEntry: entry, }) } - - // Check for missing dependencies - for _, depend := range entry.Info.Depends { - // Split package name and required version - dependName, _, _ := SplitPkgNameAndVersion(depend) - - if IsPackageInstalled(dependName, rootDir) && EvaluateDependency(depend, GetPackageInfo(dependName, rootDir).Version) { - continue - } - if len(GetVirtualPackageInfo(dependName, rootDir)) > 0 { - continue - } - - // Check resolved virtual packages - if resolvedPkg, ok := resolvedVirtualPackages[dependName]; ok { - dependName = resolvedPkg - } - - // Find database entry for missing dependency - dependEntry := ResolveDatabaseEntry(dependName, rootDir) - if dependEntry == nil { - pkgsNotFound = append(pkgsNotFound, depend) - continue - } - - // Skip dependency if action already exists - if ActionSliceIndex(operation.Actions, dependEntry.Info.Name) != -1 { - continue - } - - // Skip dependency if ignored in config - if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) { - continue - } - - // Ensure entry has required version - if !EvaluateDependency(depend, dependEntry.Info.Version) { - pkgsNotFound = append(pkgsNotFound, depend) - continue - } - - // Resolve virtual packages - for _, vpkg := range dependEntry.Info.Provides { - if _, ok := resolvedVirtualPackages[vpkg]; !ok { - resolvedVirtualPackages[vpkg] = dependEntry.Info.Name - } - } - - // Fetch dependency - operation.Actions = append(operation.Actions, &FetchPackageAction{ - InstallationReason: InstallationReasonDependency, - DatabaseEntry: dependEntry, - }) - } - - // Check for missing runtime dependencies - for _, depend := range entry.Info.RuntimeDepends { - // Split package name and required version - dependName, _, _ := SplitPkgNameAndVersion(depend) - - if IsPackageInstalled(dependName, rootDir) && EvaluateDependency(depend, GetPackageInfo(dependName, rootDir).Version) { - continue - } - if len(GetVirtualPackageInfo(dependName, rootDir)) > 0 { - continue - } - - // Check resolved virtual packages - if resolvedPkg, ok := resolvedVirtualPackages[dependName]; ok { - dependName = resolvedPkg - } - - // Find database entry for missing dependency - dependEntry := ResolveDatabaseEntry(dependName, rootDir) - if dependEntry == nil { - pkgsNotFound = append(pkgsNotFound, depend) - continue - } - - // Skip dependency if ignored in config - if rootDir == "/" && slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) { - continue - } - - // Ensure entry has required version - if !EvaluateDependency(depend, dependEntry.Info.Version) { - pkgsNotFound = append(pkgsNotFound, depend) - continue - } - - // Resolve virtual packages - for _, vpkg := range dependEntry.Info.Provides { - if _, ok := resolvedVirtualPackages[vpkg]; !ok { - resolvedVirtualPackages[vpkg] = dependEntry.Info.Name - } - } - - // Fetch dependency - operation.Actions = append(operation.Actions, &FetchPackageAction{ - InstallationReason: InstallationReasonDependency, - DatabaseEntry: dependEntry, - }) - } } } - // Return error if not all packages are found - if len(pkgsNotFound) != 0 { - return nil, PackageNotFoundErr{pkgsNotFound} + // Resolve dependencies + operation.ResolveDependencies(true) + if len(operation.UnresolvedDepends) != 0 { + if !forceInstallation { + return nil, DependencyNotFoundErr{operation.UnresolvedDepends} + } else if verbose { + log.Printf("Warning: %s", DependencyNotFoundErr{operation.UnresolvedDepends}) + } } // Replace obsolete packages