mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Add check dependencies
This commit is contained in:
+1
-1
@@ -1183,7 +1183,7 @@ func compilePackage() {
|
|||||||
|
|
||||||
// Get direct common and make dependencies
|
// Get direct common and make dependencies
|
||||||
totalDepends := make([]string, 0)
|
totalDepends := make([]string, 0)
|
||||||
for _, depend := range bpmpkg.PkgInfo.GetDependencies(true, false, false) {
|
for _, depend := range bpmpkg.PkgInfo.GetDependencies(true, !skipChecks, false, false) {
|
||||||
if !slices.Contains(totalDepends, depend.PkgName) {
|
if !slices.Contains(totalDepends, depend.PkgName) {
|
||||||
totalDepends = append(totalDepends, depend.PkgName)
|
totalDepends = append(totalDepends, depend.PkgName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -365,6 +365,7 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableS
|
|||||||
builderWriteArray("Dependencies", entry.Info.Depends, true)
|
builderWriteArray("Dependencies", entry.Info.Depends, true)
|
||||||
if entry.Info.Type == "source" {
|
if entry.Info.Type == "source" {
|
||||||
builderWriteArray("Make dependencies", entry.Info.MakeDepends, true)
|
builderWriteArray("Make dependencies", entry.Info.MakeDepends, true)
|
||||||
|
builderWriteArray("Check dependencies", entry.Info.CheckDepends, true)
|
||||||
}
|
}
|
||||||
builderWriteArray("Runtime dependencies", entry.Info.RuntimeDepends, true)
|
builderWriteArray("Runtime dependencies", entry.Info.RuntimeDepends, true)
|
||||||
if len(entry.Info.OptionalDepends) > 0 {
|
if len(entry.Info.OptionalDepends) > 0 {
|
||||||
|
|||||||
+23
-11
@@ -11,7 +11,7 @@ type pkgInstallationReason struct {
|
|||||||
InstallationReason InstallationReason
|
InstallationReason InstallationReason
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeRuntimeDepends, includeOptionalDepends bool) []pkgInstallationReason {
|
func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeCheckDepends, includeRuntimeDepends, includeOptionalDepends bool) []pkgInstallationReason {
|
||||||
allDepends := make([]pkgInstallationReason, 0)
|
allDepends := make([]pkgInstallationReason, 0)
|
||||||
|
|
||||||
for _, depend := range pkgInfo.Depends {
|
for _, depend := range pkgInfo.Depends {
|
||||||
@@ -61,6 +61,18 @@ func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeRuntimeDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if includeCheckDepends {
|
||||||
|
for _, depend := range pkgInfo.CheckDepends {
|
||||||
|
if !slices.ContainsFunc(allDepends, func(p pkgInstallationReason) bool {
|
||||||
|
return p.PkgName == depend
|
||||||
|
}) {
|
||||||
|
allDepends = append(allDepends, pkgInstallationReason{
|
||||||
|
PkgName: depend,
|
||||||
|
InstallationReason: InstallationReasonMakeDependency,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Skip ignored packages
|
// Skip ignored packages
|
||||||
allDepends = slices.DeleteFunc(allDepends, func(depend pkgInstallationReason) bool {
|
allDepends = slices.DeleteFunc(allDepends, func(depend pkgInstallationReason) bool {
|
||||||
@@ -70,23 +82,23 @@ func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeRuntimeDe
|
|||||||
return allDepends
|
return allDepends
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkgInfo *PackageInfo) GetDependenciesRecursive(includeRuntimeDepends, includeMakeDepends bool, rootDir string) (resolved []string) {
|
func (pkgInfo *PackageInfo) GetDependenciesRecursive(includeRuntimeDepends, includeCheckDepends, includeMakeDepends bool, rootDir string) (resolved []string) {
|
||||||
// Initialize slices
|
// Initialize slices
|
||||||
resolved = make([]string, 0)
|
resolved = make([]string, 0)
|
||||||
unresolved := make([]string, 0)
|
unresolved := make([]string, 0)
|
||||||
|
|
||||||
// Call unexported function
|
// Call unexported function
|
||||||
pkgInfo.getDependenciesRecursive(&resolved, &unresolved, includeRuntimeDepends, includeMakeDepends, rootDir)
|
pkgInfo.getDependenciesRecursive(&resolved, &unresolved, includeRuntimeDepends, includeMakeDepends, includeCheckDepends, rootDir)
|
||||||
|
|
||||||
return resolved
|
return resolved
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pkgInfo *PackageInfo) getDependenciesRecursive(resolved *[]string, unresolved *[]string, includeRuntimeDepends, includeMakeDepends bool, rootDir string) {
|
func (pkgInfo *PackageInfo) getDependenciesRecursive(resolved *[]string, unresolved *[]string, includeRuntimeDepends, includeMakeDepends, includeCheckDepends bool, rootDir string) {
|
||||||
// Add current package name to unresolved slice
|
// Add current package name to unresolved slice
|
||||||
*unresolved = append(*unresolved, pkgInfo.Name)
|
*unresolved = append(*unresolved, pkgInfo.Name)
|
||||||
|
|
||||||
// Loop through all dependencies
|
// Loop through all dependencies
|
||||||
for _, pkgIR := range pkgInfo.GetDependencies(includeMakeDepends, includeRuntimeDepends, false) {
|
for _, pkgIR := range pkgInfo.GetDependencies(includeMakeDepends, includeCheckDepends, includeRuntimeDepends, false) {
|
||||||
depend := pkgIR.PkgName
|
depend := pkgIR.PkgName
|
||||||
|
|
||||||
if isVirtual, p := IsVirtualPackage(depend, rootDir); isVirtual {
|
if isVirtual, p := IsVirtualPackage(depend, rootDir); isVirtual {
|
||||||
@@ -105,7 +117,7 @@ func (pkgInfo *PackageInfo) getDependenciesRecursive(resolved *[]string, unresol
|
|||||||
dependInfo := GetPackageInfo(depend, rootDir)
|
dependInfo := GetPackageInfo(depend, rootDir)
|
||||||
|
|
||||||
if dependInfo != nil {
|
if dependInfo != nil {
|
||||||
dependInfo.getDependenciesRecursive(resolved, unresolved, includeRuntimeDepends, includeMakeDepends, rootDir)
|
dependInfo.getDependenciesRecursive(resolved, unresolved, includeRuntimeDepends, includeMakeDepends, includeCheckDepends, rootDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +127,7 @@ func (pkgInfo *PackageInfo) getDependenciesRecursive(resolved *[]string, unresol
|
|||||||
*unresolved = stringSliceRemove(*unresolved, pkgInfo.Name)
|
*unresolved = stringSliceRemove(*unresolved, pkgInfo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, resolvedVirtualPkgs map[string]string, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) (resolved []pkgInstallationReason, unresolved []string) {
|
func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, resolvedVirtualPkgs map[string]string, checkMake, checkCheck, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) (resolved []pkgInstallationReason, unresolved []string) {
|
||||||
// Initialize slices and maps
|
// Initialize slices and maps
|
||||||
resolved = make([]pkgInstallationReason, 0)
|
resolved = make([]pkgInstallationReason, 0)
|
||||||
unresolved = make([]string, 0)
|
unresolved = make([]string, 0)
|
||||||
@@ -124,7 +136,7 @@ func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, resolvedVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Call unexported function
|
// Call unexported function
|
||||||
resolvePackageDependenciesFromDatabase(&resolved, &unresolved, resolvedVirtualPkgs, pkgInfo, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose, rootDir)
|
resolvePackageDependenciesFromDatabase(&resolved, &unresolved, resolvedVirtualPkgs, pkgInfo, checkMake, checkCheck, checkRuntime, checkOptional, ignoreInstalled, verbose, rootDir)
|
||||||
|
|
||||||
// Remove main package from unresolved slice
|
// Remove main package from unresolved slice
|
||||||
unresolved = stringSliceRemove(unresolved, pkgInfo.Name)
|
unresolved = stringSliceRemove(unresolved, pkgInfo.Name)
|
||||||
@@ -132,7 +144,7 @@ func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, resolvedVi
|
|||||||
return resolved, unresolved
|
return resolved, unresolved
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, unresolved *[]string, resolvedVirtualPkgs map[string]string, pkgInfo *PackageInfo, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) {
|
func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, unresolved *[]string, resolvedVirtualPkgs map[string]string, pkgInfo *PackageInfo, checkMake, checkCheck, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) {
|
||||||
// Add current package name to unresolved slice
|
// Add current package name to unresolved slice
|
||||||
*unresolved = append(*unresolved, pkgInfo.Name)
|
*unresolved = append(*unresolved, pkgInfo.Name)
|
||||||
|
|
||||||
@@ -143,7 +155,7 @@ func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through all dependencies
|
// Loop through all dependencies
|
||||||
for _, pkgIR := range pkgInfo.GetDependencies(pkgInfo.Type == "source", checkRuntime, checkOptional) {
|
for _, pkgIR := range pkgInfo.GetDependencies(pkgInfo.Type == "source", pkgInfo.Type == "source" && checkCheck, checkRuntime, checkOptional) {
|
||||||
// Skip dependency if it has already been resolved
|
// Skip dependency if it has already been resolved
|
||||||
if slices.ContainsFunc(*resolved, func(p pkgInstallationReason) bool {
|
if slices.ContainsFunc(*resolved, func(p pkgInstallationReason) bool {
|
||||||
return p.PkgName == pkgIR.PkgName
|
return p.PkgName == pkgIR.PkgName
|
||||||
@@ -201,7 +213,7 @@ func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the dependencies of this dependency
|
// Resolve the dependencies of this dependency
|
||||||
resolvePackageDependenciesFromDatabase(resolved, unresolved, resolvedVirtualPkgs, entry.Info, checkMake, checkRuntime, false, ignoreInstalled, verbose, rootDir)
|
resolvePackageDependenciesFromDatabase(resolved, unresolved, resolvedVirtualPkgs, entry.Info, checkMake, checkCheck, checkRuntime, false, ignoreInstalled, verbose, rootDir)
|
||||||
|
|
||||||
// Move dependency from the unresolved slice to the resolved slice
|
// Move dependency from the unresolved slice to the resolved slice
|
||||||
if !slices.ContainsFunc(*resolved, func(p pkgInstallationReason) bool {
|
if !slices.ContainsFunc(*resolved, func(p pkgInstallationReason) bool {
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, instal
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
resolved, unresolved := ResolveAllPackageDependenciesFromDatabases(pkgInfo, resolvedVirtualPkgs, pkgInfo.Type == "source", installRuntimeDependencies, installOptionalDependencies, !reinstallDependencies, verbose, operation.RootDir)
|
resolved, unresolved := ResolveAllPackageDependenciesFromDatabases(pkgInfo, resolvedVirtualPkgs, pkgInfo.Type == "source", pkgInfo.Type == "source" && operation.RunChecks, installRuntimeDependencies, installOptionalDependencies, !reinstallDependencies, verbose, operation.RootDir)
|
||||||
|
|
||||||
operation.UnresolvedDepends = append(operation.UnresolvedDepends, unresolved...)
|
operation.UnresolvedDepends = append(operation.UnresolvedDepends, unresolved...)
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ func (operation *BPMOperation) Cleanup(cleanupMakeDepends bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keepPackages = append(keepPackages, pkg.Name)
|
keepPackages = append(keepPackages, pkg.Name)
|
||||||
resolved := pkg.GetDependenciesRecursive(true, !cleanupMakeDepends, operation.RootDir)
|
resolved := pkg.GetDependenciesRecursive(true, !cleanupMakeDepends, !cleanupMakeDepends, operation.RootDir)
|
||||||
for _, value := range resolved {
|
for _, value := range resolved {
|
||||||
if !slices.Contains(keepPackages, value) && !slices.Contains(MainBPMConfig.IgnorePackages, value) {
|
if !slices.Contains(keepPackages, value) && !slices.Contains(MainBPMConfig.IgnorePackages, value) {
|
||||||
keepPackages = append(keepPackages, value)
|
keepPackages = append(keepPackages, value)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ type PackageInfo struct {
|
|||||||
RuntimeDepends []string `yaml:"runtime_depends,omitempty"`
|
RuntimeDepends []string `yaml:"runtime_depends,omitempty"`
|
||||||
OptionalDepends []string `yaml:"optional_depends,omitempty"`
|
OptionalDepends []string `yaml:"optional_depends,omitempty"`
|
||||||
MakeDepends []string `yaml:"make_depends,omitempty"`
|
MakeDepends []string `yaml:"make_depends,omitempty"`
|
||||||
|
CheckDepends []string `yaml:"check_depends,omitempty"`
|
||||||
Conflicts []string `yaml:"conflicts,omitempty"`
|
Conflicts []string `yaml:"conflicts,omitempty"`
|
||||||
Replaces []string `yaml:"replaces,omitempty"`
|
Replaces []string `yaml:"replaces,omitempty"`
|
||||||
Provides []string `yaml:"provides,omitempty"`
|
Provides []string `yaml:"provides,omitempty"`
|
||||||
@@ -133,14 +134,17 @@ func GetInstallationReason(pkg, rootDir string) InstallationReason {
|
|||||||
return InstallationReasonUnknown
|
return InstallationReasonUnknown
|
||||||
}
|
}
|
||||||
reason := strings.TrimSpace(string(b))
|
reason := strings.TrimSpace(string(b))
|
||||||
if reason == "manual" {
|
|
||||||
|
switch reason {
|
||||||
|
case "manual":
|
||||||
return InstallationReasonManual
|
return InstallationReasonManual
|
||||||
} else if reason == "dependency" {
|
case "dependency":
|
||||||
return InstallationReasonDependency
|
return InstallationReasonDependency
|
||||||
} else if reason == "make_dependency" {
|
case "make_dependency":
|
||||||
return InstallationReasonMakeDependency
|
return InstallationReasonMakeDependency
|
||||||
}
|
default:
|
||||||
return InstallationReasonUnknown
|
return InstallationReasonUnknown
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetInstallationReason(pkg string, reason InstallationReason, rootDir string) error {
|
func SetInstallationReason(pkg string, reason InstallationReason, rootDir string) error {
|
||||||
@@ -579,6 +583,7 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
|||||||
builderWriteArray("Dependencies", pkgInfo.Depends, true)
|
builderWriteArray("Dependencies", pkgInfo.Depends, true)
|
||||||
if pkgInfo.Type == "source" {
|
if pkgInfo.Type == "source" {
|
||||||
builderWriteArray("Make dependencies", pkgInfo.MakeDepends, true)
|
builderWriteArray("Make dependencies", pkgInfo.MakeDepends, true)
|
||||||
|
builderWriteArray("Check dependencies", pkgInfo.CheckDepends, true)
|
||||||
}
|
}
|
||||||
builderWriteArray("Runtime dependencies", pkgInfo.RuntimeDepends, true)
|
builderWriteArray("Runtime dependencies", pkgInfo.RuntimeDepends, true)
|
||||||
if len(pkgInfo.OptionalDepends) > 0 {
|
if len(pkgInfo.OptionalDepends) > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user