mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-24 14:36:12 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2072e3856f
|
||
|
|
72f574209f
|
@@ -347,6 +347,7 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableS
|
|||||||
if entry.Info.License != "" {
|
if entry.Info.License != "" {
|
||||||
ret = append(ret, "License: "+entry.Info.License)
|
ret = append(ret, "License: "+entry.Info.License)
|
||||||
}
|
}
|
||||||
|
appendArray("Maintainers", entry.Info.Maintainers, false)
|
||||||
ret = append(ret, "Architecture: "+entry.Info.Arch)
|
ret = append(ret, "Architecture: "+entry.Info.Arch)
|
||||||
if entry.Info.Type == "source" && entry.Info.OutputArch != "" && entry.Info.OutputArch != GetArch() {
|
if entry.Info.Type == "source" && entry.Info.OutputArch != "" && entry.Info.OutputArch != GetArch() {
|
||||||
ret = append(ret, "Output architecture: "+entry.Info.OutputArch)
|
ret = append(ret, "Output architecture: "+entry.Info.OutputArch)
|
||||||
|
|||||||
@@ -113,13 +113,16 @@ func (pkgInfo *PackageInfo) getDependenciesRecursive(resolved *[]string, unresol
|
|||||||
*unresolved = stringSliceRemove(*unresolved, pkgInfo.Name)
|
*unresolved = stringSliceRemove(*unresolved, pkgInfo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) (resolved []pkgInstallationReason, unresolved []string) {
|
func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, resolvedVirtualPkgs map[string]string, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) (resolved []pkgInstallationReason, unresolved []string) {
|
||||||
// Initialize slices
|
// Initialize slices and maps
|
||||||
resolved = make([]pkgInstallationReason, 0)
|
resolved = make([]pkgInstallationReason, 0)
|
||||||
unresolved = make([]string, 0)
|
unresolved = make([]string, 0)
|
||||||
|
if resolvedVirtualPkgs == nil {
|
||||||
|
resolvedVirtualPkgs = make(map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
// Call unexported function
|
// Call unexported function
|
||||||
resolvePackageDependenciesFromDatabase(&resolved, &unresolved, pkgInfo, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose, rootDir)
|
resolvePackageDependenciesFromDatabase(&resolved, &unresolved, resolvedVirtualPkgs, pkgInfo, checkMake, 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)
|
||||||
@@ -127,10 +130,16 @@ func ResolveAllPackageDependenciesFromDatabases(pkgInfo *PackageInfo, checkMake,
|
|||||||
return resolved, unresolved
|
return resolved, unresolved
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, unresolved *[]string, pkgInfo *PackageInfo, checkMake, checkRuntime, checkOptional, ignoreInstalled, verbose bool, rootDir string) {
|
func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, unresolved *[]string, resolvedVirtualPkgs map[string]string, pkgInfo *PackageInfo, checkMake, 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)
|
||||||
|
|
||||||
|
for _, vpkg := range pkgInfo.Provides {
|
||||||
|
if _, ok := resolvedVirtualPkgs[vpkg]; !ok {
|
||||||
|
resolvedVirtualPkgs[vpkg] = pkgInfo.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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", checkRuntime, checkOptional) {
|
||||||
// Skip dependency if it has already been resolved
|
// Skip dependency if it has already been resolved
|
||||||
@@ -163,7 +172,25 @@ func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, u
|
|||||||
var entry *BPMDatabaseEntry
|
var entry *BPMDatabaseEntry
|
||||||
entry, _, err = GetDatabaseEntry(pkgIR.PkgName)
|
entry, _, err = GetDatabaseEntry(pkgIR.PkgName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if entry = ResolveVirtualPackage(pkgIR.PkgName); entry == nil {
|
if resolvedVirtualPkg, ok := resolvedVirtualPkgs[pkgIR.PkgName]; ok {
|
||||||
|
// Virtual package already resolved
|
||||||
|
|
||||||
|
// Move dependency from the unresolved slice to the resolved slice
|
||||||
|
if !slices.ContainsFunc(*resolved, func(p pkgInstallationReason) bool {
|
||||||
|
return p.PkgName == resolvedVirtualPkg
|
||||||
|
}) {
|
||||||
|
*resolved = append(*resolved, pkgInstallationReason{
|
||||||
|
PkgName: resolvedVirtualPkg,
|
||||||
|
InstallationReason: pkgIR.InstallationReason,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
*unresolved = stringSliceRemove(*unresolved, resolvedVirtualPkg)
|
||||||
|
|
||||||
|
continue
|
||||||
|
} else if entry = ResolveVirtualPackage(pkgIR.PkgName); entry != nil {
|
||||||
|
// Virtual package found in database
|
||||||
|
} else {
|
||||||
|
// Virtual package not found
|
||||||
if !slices.Contains(*unresolved, pkgIR.PkgName) {
|
if !slices.Contains(*unresolved, pkgIR.PkgName) {
|
||||||
*unresolved = append(*unresolved, pkgIR.PkgName)
|
*unresolved = append(*unresolved, pkgIR.PkgName)
|
||||||
}
|
}
|
||||||
@@ -172,7 +199,7 @@ func resolvePackageDependenciesFromDatabase(resolved *[]pkgInstallationReason, u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the dependencies of this dependency
|
// Resolve the dependencies of this dependency
|
||||||
resolvePackageDependenciesFromDatabase(resolved, unresolved, entry.Info, checkMake, checkRuntime, false, ignoreInstalled, verbose, rootDir)
|
resolvePackageDependenciesFromDatabase(resolved, unresolved, resolvedVirtualPkgs, entry.Info, checkMake, 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 {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ func (operation *BPMOperation) GetFinalActionSize(rootDir string) int64 {
|
|||||||
|
|
||||||
func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, installRuntimeDependencies, installOptionalDependencies, verbose bool) error {
|
func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, installRuntimeDependencies, installOptionalDependencies, verbose bool) error {
|
||||||
pos := 0
|
pos := 0
|
||||||
|
resolvedVirtualPkgs := make(map[string]string, 0)
|
||||||
for _, value := range slices.Clone(operation.Actions) {
|
for _, value := range slices.Clone(operation.Actions) {
|
||||||
var pkgInfo *PackageInfo
|
var pkgInfo *PackageInfo
|
||||||
if value.GetActionType() == "install" {
|
if value.GetActionType() == "install" {
|
||||||
@@ -145,7 +146,7 @@ func (operation *BPMOperation) ResolveDependencies(reinstallDependencies, instal
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
resolved, unresolved := ResolveAllPackageDependenciesFromDatabases(pkgInfo, pkgInfo.Type == "source", installRuntimeDependencies, installOptionalDependencies, !reinstallDependencies, verbose, operation.RootDir)
|
resolved, unresolved := ResolveAllPackageDependenciesFromDatabases(pkgInfo, resolvedVirtualPkgs, pkgInfo.Type == "source", installRuntimeDependencies, installOptionalDependencies, !reinstallDependencies, verbose, operation.RootDir)
|
||||||
|
|
||||||
operation.UnresolvedDepends = append(operation.UnresolvedDepends, unresolved...)
|
operation.UnresolvedDepends = append(operation.UnresolvedDepends, unresolved...)
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ type PackageInfo struct {
|
|||||||
Revision int `yaml:"revision,omitempty"`
|
Revision int `yaml:"revision,omitempty"`
|
||||||
Url string `yaml:"url,omitempty"`
|
Url string `yaml:"url,omitempty"`
|
||||||
License string `yaml:"license,omitempty"`
|
License string `yaml:"license,omitempty"`
|
||||||
|
Maintainers []string `yaml:"maintainers,omitempty"`
|
||||||
Arch string `yaml:"architecture,omitempty"`
|
Arch string `yaml:"architecture,omitempty"`
|
||||||
OutputArch string `yaml:"output_architecture,omitempty"`
|
OutputArch string `yaml:"output_architecture,omitempty"`
|
||||||
Type string `yaml:"type,omitempty"`
|
Type string `yaml:"type,omitempty"`
|
||||||
@@ -557,6 +558,7 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
|||||||
if pkgInfo.License != "" {
|
if pkgInfo.License != "" {
|
||||||
ret = append(ret, "License: "+pkgInfo.License)
|
ret = append(ret, "License: "+pkgInfo.License)
|
||||||
}
|
}
|
||||||
|
appendArray("Maintainers", pkgInfo.Maintainers)
|
||||||
ret = append(ret, "Architecture: "+pkgInfo.Arch)
|
ret = append(ret, "Architecture: "+pkgInfo.Arch)
|
||||||
if pkgInfo.Type == "source" && pkgInfo.OutputArch != "" && pkgInfo.OutputArch != GetArch() {
|
if pkgInfo.Type == "source" && pkgInfo.OutputArch != "" && pkgInfo.OutputArch != GetArch() {
|
||||||
ret = append(ret, "Output architecture: "+pkgInfo.Arch)
|
ret = append(ret, "Output architecture: "+pkgInfo.Arch)
|
||||||
|
|||||||
Reference in New Issue
Block a user