mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-16 02:26:12 +00:00
Add optional dependency descriptions
This commit is contained in:
+15
-3
@@ -297,7 +297,9 @@ func (entry *BPMDatabaseEntry) GetEntryOptionalDependants() (dependants []string
|
|||||||
dependantsMap := make(map[string][]string)
|
dependantsMap := make(map[string][]string)
|
||||||
for _, db := range BPMDatabases {
|
for _, db := range BPMDatabases {
|
||||||
for _, e := range db.Entries {
|
for _, e := range db.Entries {
|
||||||
if slices.Contains(e.Info.OptionalDepends, entry.Info.Name) {
|
if slices.ContainsFunc(e.Info.OptionalDepends, func(n string) bool {
|
||||||
|
return strings.SplitN(n, ":", 2)[0] == entry.Info.Name
|
||||||
|
}) {
|
||||||
dependantsMap[e.Info.Name] = append(dependantsMap[e.Info.Name], e.Database.Name)
|
dependantsMap[e.Info.Name] = append(dependantsMap[e.Info.Name], e.Database.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,10 +360,20 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableS
|
|||||||
builder.WriteString("Type: " + entry.Info.Type + "\n")
|
builder.WriteString("Type: " + entry.Info.Type + "\n")
|
||||||
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("Runtime dependencies", entry.Info.RuntimeDepends, true)
|
builderWriteArray("Runtime dependencies", entry.Info.RuntimeDepends, true)
|
||||||
builderWriteArray("Optional dependencies", entry.Info.OptionalDepends, true)
|
if len(entry.Info.OptionalDepends) > 0 {
|
||||||
|
builder.WriteString("Optional dependencies:\n")
|
||||||
|
for _, depend := range entry.Info.OptionalDepends {
|
||||||
|
dependSplit := strings.SplitN(depend, ":", 2)
|
||||||
|
if len(dependSplit) == 2 {
|
||||||
|
builder.WriteString(fmt.Sprintf(" - %s (%s)\n", dependSplit[0], dependSplit[1]))
|
||||||
|
} else {
|
||||||
|
builder.WriteString(" - " + dependSplit[0] + "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
dependants := entry.GetEntryDependants()
|
dependants := entry.GetEntryDependants()
|
||||||
if len(dependants) > 0 {
|
if len(dependants) > 0 {
|
||||||
builderWriteArray("Dependant packages", dependants, false)
|
builderWriteArray("Dependant packages", dependants, false)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package bpmlib
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type pkgInstallationReason struct {
|
type pkgInstallationReason struct {
|
||||||
@@ -25,6 +26,7 @@ func (pkgInfo *PackageInfo) GetDependencies(includeMakeDepends, includeRuntimeDe
|
|||||||
}
|
}
|
||||||
if includeOptionalDepends {
|
if includeOptionalDepends {
|
||||||
for _, depend := range pkgInfo.OptionalDepends {
|
for _, depend := range pkgInfo.OptionalDepends {
|
||||||
|
depend = strings.SplitN(depend, ":", 2)[0]
|
||||||
if !slices.ContainsFunc(allDepends, func(p pkgInstallationReason) bool {
|
if !slices.ContainsFunc(allDepends, func(p pkgInstallationReason) bool {
|
||||||
return p.PkgName == depend
|
return p.PkgName == depend
|
||||||
}) {
|
}) {
|
||||||
@@ -283,7 +285,7 @@ func (pkgInfo *PackageInfo) GetPackageOptionalDependants(rootDir string) (depend
|
|||||||
|
|
||||||
// Add installed package to list if its optional dependencies include pkgName
|
// Add installed package to list if its optional dependencies include pkgName
|
||||||
if slices.ContainsFunc(installedPkg.OptionalDepends, func(n string) bool {
|
if slices.ContainsFunc(installedPkg.OptionalDepends, func(n string) bool {
|
||||||
return n == pkgInfo.Name
|
return strings.SplitN(n, ":", 2)[0] == pkgInfo.Name
|
||||||
}) {
|
}) {
|
||||||
dependants = append(dependants, installedPkg.Name)
|
dependants = append(dependants, installedPkg.Name)
|
||||||
continue
|
continue
|
||||||
@@ -293,7 +295,7 @@ func (pkgInfo *PackageInfo) GetPackageOptionalDependants(rootDir string) (depend
|
|||||||
for _, vpkg := range pkgInfo.Provides {
|
for _, vpkg := range pkgInfo.Provides {
|
||||||
// Add installed package to list if its optional dependencies contain a provided virtual package
|
// Add installed package to list if its optional dependencies contain a provided virtual package
|
||||||
if slices.ContainsFunc(installedPkg.OptionalDepends, func(n string) bool {
|
if slices.ContainsFunc(installedPkg.OptionalDepends, func(n string) bool {
|
||||||
return n == vpkg
|
return strings.SplitN(n, ":", 2)[0] == vpkg
|
||||||
}) {
|
}) {
|
||||||
dependants = append(dependants, installedPkg.Name)
|
dependants = append(dependants, installedPkg.Name)
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -485,17 +485,25 @@ func (operation *BPMOperation) GetOptionalDependencies() (optionalDepends map[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, depend := range pkgInfo.OptionalDepends {
|
for _, depend := range pkgInfo.OptionalDepends {
|
||||||
|
dependSplit := strings.SplitN(depend, ":", 2)
|
||||||
|
|
||||||
// Skip if dependency is already installed
|
// Skip if dependency is already installed
|
||||||
if IsPackageInstalled(depend, operation.RootDir) {
|
if IsPackageInstalled(dependSplit[0], operation.RootDir) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if not a new dependency of the package
|
// Skip if not a new dependency of the package
|
||||||
if installedPkg := GetPackage(pkgInfo.Name, operation.RootDir); installedPkg != nil && slices.Contains(installedPkg.PkgInfo.OptionalDepends, depend) {
|
if installedPkg := GetPackage(pkgInfo.Name, operation.RootDir); installedPkg != nil && slices.ContainsFunc(installedPkg.PkgInfo.OptionalDepends, func(n string) bool {
|
||||||
|
return strings.SplitN(n, ":", 2)[0] == dependSplit[0]
|
||||||
|
}) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
optionalDepends[pkgInfo.Name] = append(optionalDepends[pkgInfo.Name], depend)
|
if len(dependSplit) == 2 {
|
||||||
|
optionalDepends[pkgInfo.Name] = append(optionalDepends[pkgInfo.Name], fmt.Sprintf("%s (%s)", dependSplit[0], dependSplit[1]))
|
||||||
|
} else {
|
||||||
|
optionalDepends[pkgInfo.Name] = append(optionalDepends[pkgInfo.Name], dependSplit[0])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-3
@@ -574,11 +574,21 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
|||||||
builder.WriteString("Type: " + pkgInfo.Type + "\n")
|
builder.WriteString("Type: " + pkgInfo.Type + "\n")
|
||||||
builderWriteArray("Dependencies", pkgInfo.Depends, true)
|
builderWriteArray("Dependencies", pkgInfo.Depends, true)
|
||||||
if pkgInfo.Type == "source" {
|
if pkgInfo.Type == "source" {
|
||||||
builderWriteArray("Runtime Dependencies", pkgInfo.RuntimeDepends, true)
|
builderWriteArray("Runtime dependencies", pkgInfo.RuntimeDepends, true)
|
||||||
builderWriteArray("Make Dependencies", pkgInfo.MakeDepends, true)
|
builderWriteArray("Make dependencies", pkgInfo.MakeDepends, true)
|
||||||
}
|
}
|
||||||
builderWriteArray("Runtime dependencies", pkgInfo.RuntimeDepends, true)
|
builderWriteArray("Runtime dependencies", pkgInfo.RuntimeDepends, true)
|
||||||
builderWriteArray("Optional dependencies", pkgInfo.OptionalDepends, true)
|
if len(pkgInfo.OptionalDepends) > 0 {
|
||||||
|
builder.WriteString("Optional dependencies:\n")
|
||||||
|
for _, depend := range pkgInfo.OptionalDepends {
|
||||||
|
dependSplit := strings.SplitN(depend, ":", 2)
|
||||||
|
if len(dependSplit) == 2 {
|
||||||
|
builder.WriteString(fmt.Sprintf(" - %s (%s)\n", dependSplit[0], dependSplit[1]))
|
||||||
|
} else {
|
||||||
|
builder.WriteString(" - " + dependSplit[0] + "\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
dependants := pkgInfo.GetPackageDependants(rootDir)
|
dependants := pkgInfo.GetPackageDependants(rootDir)
|
||||||
if len(dependants) > 0 {
|
if len(dependants) > 0 {
|
||||||
builderWriteArray("Dependant packages", dependants, true)
|
builderWriteArray("Dependant packages", dependants, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user