Improve ignore_package functionality

This commit is contained in:
2026-04-24 18:40:08 +03:00
parent 5d0312856d
commit 2de4eea7a4
2 changed files with 66 additions and 21 deletions
+5
View File
@@ -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})
+48 -8
View File
@@ -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,30 +418,65 @@ 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 {
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 {
return nil, err
providers := GetDatabaseVirtualPackageEntry(dep)
if len(providers) == 0 {
pkgsNotFound = append(pkgsNotFound, dep)
continue
}
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 {
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 {
return nil, err
providers := GetDatabaseVirtualPackageEntry(dep)
if len(providers) == 0 {
pkgsNotFound = append(pkgsNotFound, dep)
continue
}
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,
@@ -448,6 +484,10 @@ func UpdatePackages(rootDir string, syncDatabase, allowDowngrades, forceInstalla
}
}
}
// Return error if not all packages are found
if len(pkgsNotFound) != 0 {
return nil, PackageNotFoundErr{pkgsNotFound}
}
// Replace obsolete packages