diff --git a/src/bpm/main.go b/src/bpm/main.go index eaba541..32ef64b 100644 --- a/src/bpm/main.go +++ b/src/bpm/main.go @@ -124,6 +124,7 @@ func resolveCommand() { for n, pkg := range packages { var info *bpmlib.PackageInfo isFile := false + showInstallationReason := false if showRepoInfo { var err error var entry *bpmlib.RepositoryEntry @@ -147,6 +148,7 @@ func resolveCommand() { } else { info = bpmlib.GetPackageInfo(pkg, rootDir) } + showInstallationReason = true } if info == nil { log.Fatalf("Error: package (%s) is not installed\n", pkg) @@ -161,7 +163,7 @@ func resolveCommand() { } fmt.Println("File: " + abs) } - fmt.Println(bpmlib.CreateReadableInfo(true, true, true, info, rootDir)) + fmt.Println(bpmlib.CreateReadableInfo(true, true, true, showInstallationReason, info, rootDir)) } case list: // Read local databases @@ -195,7 +197,7 @@ func resolveCommand() { if n != 0 { fmt.Println() } - fmt.Println(bpmlib.CreateReadableInfo(true, true, true, info, rootDir)) + fmt.Println(bpmlib.CreateReadableInfo(true, true, true, true, info, rootDir)) } } case search: diff --git a/src/bpmlib/packages.go b/src/bpmlib/packages.go index eda206b..5c4471d 100644 --- a/src/bpmlib/packages.go +++ b/src/bpmlib/packages.go @@ -484,7 +484,7 @@ func ReadPackageInfo(contents string) (*PackageInfo, error) { return pkgInfo, nil } -func CreateReadableInfo(showArchitecture, showType, showPackageRelations bool, pkgInfo *PackageInfo, rootDir string) string { +func CreateReadableInfo(showArchitecture, showType, showPackageRelations, showInstallationReason bool, pkgInfo *PackageInfo, rootDir string) string { ret := make([]string, 0) appendArray := func(label string, array []string) { if len(array) == 0 { @@ -524,7 +524,9 @@ func CreateReadableInfo(showArchitecture, showType, showPackageRelations bool, p } appendArray("Split Packages", splitPkgs) } - ret = append(ret, "Installation Reason: "+string(GetInstallationReason(pkgInfo.Name, rootDir))) + if IsPackageInstalled(pkgInfo.Name, rootDir) && showInstallationReason { + ret = append(ret, "Installation Reason: "+string(GetInstallationReason(pkgInfo.Name, rootDir))) + } return strings.Join(ret, "\n") }