From 2de4eea7a4a2a2cf7209a7f12a204c6e8e82a38e Mon Sep 17 00:00:00 2001 From: EnumDev Date: Fri, 24 Apr 2026 18:40:08 +0300 Subject: [PATCH] Improve ignore_package functionality --- src/bpmlib/dependencies.go | 5 +++ src/bpmlib/general.go | 82 ++++++++++++++++++++++++++++---------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/src/bpmlib/dependencies.go b/src/bpmlib/dependencies.go index 21c2a24..42a1f83 100644 --- a/src/bpmlib/dependencies.go +++ b/src/bpmlib/dependencies.go @@ -129,6 +129,11 @@ func ResolveDependencies(pkgInfo *PackageInfo, resolvedVirtualPackages map[strin continue } + // Skip ignored packages in config + if slices.Contains(MainBPMConfig.IgnorePackages, dependEntry.Info.Name) { + continue + } + if !slices.Contains(visited, dependEntry.Info.Name) { dfs(dependEntry.Info) resolved = append(resolved, ResolvedPackage{DatabaseEntry: dependEntry, InstallationReason: installationReason}) diff --git a/src/bpmlib/general.go b/src/bpmlib/general.go index d347dd8..36f7699 100644 --- a/src/bpmlib/general.go +++ b/src/bpmlib/general.go @@ -213,7 +213,7 @@ func RemovePackages(rootDir string, force, cleanupDependencies bool, packages .. // Get packages and their dependants packageDepndants := make(map[string][]string, 0) for _, action := range operation.Actions { - // Skip package if ignored + // Skip package if ignored in config if slices.Contains(MainBPMConfig.IgnorePackages, action.(*RemovePackageAction).BpmPackage.PkgInfo.Name) { continue } @@ -393,6 +393,7 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla } // Search for packages + pkgsNotFound := make([]string, 0) for _, pkg := range pkgs { if slices.Contains(MainBPMConfig.IgnorePackages, pkg) { continue @@ -417,39 +418,78 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla }) } - // Check for new uninstalled dependencies + // Check for missing dependencies for _, dep := range entry.Info.Depends { - if !IsPackageInstalled(dep, rootDir) && len(GetVirtualPackageInfo(dep, rootDir)) == 0 { - // Find database entry for missing dependency - depEntry, _, err := GetDatabaseEntry(dep) - if err != nil { - return nil, err + if IsPackageInstalled(dep, rootDir) { + continue + } + if len(GetVirtualPackageInfo(dep, rootDir)) > 0 { + continue + } + + // Find database entry for missing dependency + depEntry, _, err := GetDatabaseEntry(dep) + if err != nil { + providers := GetDatabaseVirtualPackageEntry(dep) + if len(providers) == 0 { + pkgsNotFound = append(pkgsNotFound, dep) + continue } - operation.AppendAction(&FetchPackageAction{ - InstallationReason: InstallationReasonDependency, - DatabaseEntry: depEntry, - }) + depEntry = providers[0] } + + // Skip dependency if ignored in config + if slices.Contains(MainBPMConfig.IgnorePackages, depEntry.Info.Name) { + continue + } + + // Fetch dependency + operation.AppendAction(&FetchPackageAction{ + InstallationReason: InstallationReasonDependency, + DatabaseEntry: depEntry, + }) } - // Check for new uninstalled runtime dependencies + // Check for missing runtime dependencies for _, dep := range entry.Info.RuntimeDepends { - if !IsPackageInstalled(dep, rootDir) && len(GetVirtualPackageInfo(dep, rootDir)) == 0 { - // Find database entry for missing dependency - depEntry, _, err := GetDatabaseEntry(dep) - if err != nil { - return nil, err + if IsPackageInstalled(dep, rootDir) { + continue + } + if len(GetVirtualPackageInfo(dep, rootDir)) > 0 { + continue + } + + // Find database entry for missing dependency + depEntry, _, err := GetDatabaseEntry(dep) + if err != nil { + providers := GetDatabaseVirtualPackageEntry(dep) + if len(providers) == 0 { + pkgsNotFound = append(pkgsNotFound, dep) + continue } - operation.AppendAction(&FetchPackageAction{ - InstallationReason: InstallationReasonDependency, - DatabaseEntry: depEntry, - }) + depEntry = providers[0] } + + // Skip dependency if ignored in config + if slices.Contains(MainBPMConfig.IgnorePackages, depEntry.Info.Name) { + continue + } + + // Fetch dependency + operation.AppendAction(&FetchPackageAction{ + InstallationReason: InstallationReasonDependency, + DatabaseEntry: depEntry, + }) } } } + // Return error if not all packages are found + if len(pkgsNotFound) != 0 { + return nil, PackageNotFoundErr{pkgsNotFound} + } + // Replace obsolete packages operation.ReplaceObsoletePackages()