mirror of
https://github.com/EnumeratedDev/bpm.git
synced 2026-09-26 07:26:12 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0ea57d500
|
||
|
|
e923aefff9
|
||
|
|
c2d420d854
|
+2
-1
@@ -6,7 +6,7 @@ toolchain go1.23.7
|
||||
|
||||
require (
|
||||
git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib v0.5.0
|
||||
github.com/adrg/strutil v0.3.1
|
||||
github.com/lithammer/fuzzysearch v1.1.8
|
||||
github.com/spf13/pflag v1.0.10
|
||||
)
|
||||
|
||||
@@ -15,5 +15,6 @@ replace git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib => ../bpmlib
|
||||
require (
|
||||
github.com/drone/envsubst v1.0.3 // indirect
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
+34
-15
@@ -1,27 +1,46 @@
|
||||
github.com/adrg/strutil v0.3.1 h1:OLvSS7CSJO8lBii4YmBt8jiK9QOtB9CzCzwl4Ic/Fz4=
|
||||
github.com/adrg/strutil v0.3.1/go.mod h1:8h90y18QLrs11IBffcGX3NW/GFBXCMcNg4M7H6MspPA=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/drone/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
|
||||
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
|
||||
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f h1:xt29M2T6STgldg+WEP51gGePQCsQvklmP2eIhPIBK3g=
|
||||
github.com/knqyf263/go-rpm-version v0.0.0-20240918084003-2afd7dc6a38f/go.mod h1:i4sF0l1fFnY1aiw08QQSwVAFxHEm311Me3WsU/X7nL0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
|
||||
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
+59
-33
@@ -16,8 +16,7 @@ import (
|
||||
|
||||
"git.enumerated.dev/bubble-package-manager/bpm/src/bpmlib"
|
||||
|
||||
"github.com/adrg/strutil"
|
||||
"github.com/adrg/strutil/metrics"
|
||||
"github.com/lithammer/fuzzysearch/fuzzy"
|
||||
flag "github.com/spf13/pflag"
|
||||
)
|
||||
|
||||
@@ -53,6 +52,7 @@ func main() {
|
||||
currentFlagSet = flag.NewFlagSet("query", flag.ExitOnError)
|
||||
currentFlagSet.StringP("root", "R", "/", "Operate on specified root directory")
|
||||
currentFlagSet.BoolP("database", "d", false, "Show package information from remote databases")
|
||||
currentFlagSet.BoolP("human-readable", "h", false, "Show package installed size in a human readable format")
|
||||
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "Show information on the specified packages", os.Args[2:])
|
||||
|
||||
showPackageInfo()
|
||||
@@ -66,6 +66,9 @@ func main() {
|
||||
currentFlagSet.Bool("manual", false, "Show packages installed as dependencies")
|
||||
currentFlagSet.Bool("depends", false, "Show packages installed as dependencies")
|
||||
currentFlagSet.Bool("make-depends", false, "Show packages installed as make dependencies")
|
||||
currentFlagSet.String("sort", "", "Sort listed packages by 'name' or 'size")
|
||||
currentFlagSet.Bool("reverse", false, "Reverse the order in which packages are listed")
|
||||
currentFlagSet.BoolP("human-readable", "h", false, "Show package installed size in a human readable format")
|
||||
setupFlagsAndHelp(currentFlagSet, fmt.Sprintf("bpm %s <options>", subcommand), "List packages", os.Args[2:])
|
||||
|
||||
showPackageList()
|
||||
@@ -172,6 +175,7 @@ func showPackageInfo() {
|
||||
// Get flags
|
||||
rootDir, _ := currentFlagSet.GetString("root")
|
||||
showDatabaseInfo, _ := currentFlagSet.GetBool("database")
|
||||
showHumanReadableSize, _ := currentFlagSet.GetBool("human-readable")
|
||||
|
||||
// Get packages
|
||||
packages := currentFlagSet.Args()
|
||||
@@ -204,30 +208,29 @@ func showPackageInfo() {
|
||||
if n != 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println(entry.CreateReadableInfo(rootDir))
|
||||
fmt.Println(entry.CreateReadableInfo(rootDir, showHumanReadableSize))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
var info *bpmlib.PackageInfo
|
||||
var bpmpkg *bpmlib.BPMPackage
|
||||
isFile := false
|
||||
if stat, err := os.Stat(pkg); err == nil && !stat.IsDir() {
|
||||
bpmpkg, err := bpmlib.ReadPackage(pkg)
|
||||
bpmpkg, err = bpmlib.ReadPackage(pkg)
|
||||
if err != nil {
|
||||
log.Printf("Error: could not read package: %s\n", err)
|
||||
exitCode = 1
|
||||
return
|
||||
}
|
||||
info = bpmpkg.PkgInfo
|
||||
isFile = true
|
||||
} else {
|
||||
if isVirtual, p := bpmlib.IsVirtualPackage(pkg, rootDir); isVirtual {
|
||||
info = bpmlib.GetPackageInfo(p, rootDir)
|
||||
bpmpkg = bpmlib.GetPackage(p, rootDir)
|
||||
} else {
|
||||
info = bpmlib.GetPackageInfo(pkg, rootDir)
|
||||
bpmpkg = bpmlib.GetPackage(pkg, rootDir)
|
||||
}
|
||||
}
|
||||
if info == nil {
|
||||
if bpmpkg == nil {
|
||||
log.Printf("Error: package (%s) is not installed\n", pkg)
|
||||
exitCode = 1
|
||||
return
|
||||
@@ -244,7 +247,7 @@ func showPackageInfo() {
|
||||
}
|
||||
fmt.Println("File: " + abs)
|
||||
}
|
||||
fmt.Println(info.CreateReadableInfo(rootDir))
|
||||
fmt.Println(bpmpkg.CreateReadableInfo(rootDir, showHumanReadableSize))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,6 +260,9 @@ func showPackageList() {
|
||||
showManual, _ := currentFlagSet.GetBool("manual")
|
||||
showDepends, _ := currentFlagSet.GetBool("depends")
|
||||
showMakeDepends, _ := currentFlagSet.GetBool("make-depends")
|
||||
sortPackages, _ := currentFlagSet.GetString("sort")
|
||||
reversePackages, _ := currentFlagSet.GetBool("reverse")
|
||||
showHumanReadableSize, _ := currentFlagSet.GetBool("human-readable")
|
||||
|
||||
if !isFlagSet(currentFlagSet, "manual") && !isFlagSet(currentFlagSet, "depends") && !isFlagSet(currentFlagSet, "make-depends") {
|
||||
showManual = true
|
||||
@@ -272,18 +278,43 @@ func showPackageList() {
|
||||
return
|
||||
}
|
||||
|
||||
installedPackages, err := bpmlib.GetInstalledPackages(rootDir)
|
||||
installedPackageNames, err := bpmlib.GetInstalledPackages(rootDir)
|
||||
if err != nil {
|
||||
log.Printf("Error: could not get installed packages: %s", err.Error())
|
||||
exitCode = 1
|
||||
return
|
||||
}
|
||||
|
||||
installedPackages := make([]*bpmlib.BPMPackage, len(installedPackageNames))
|
||||
for i, pkgName := range installedPackageNames {
|
||||
installedPackages[i] = bpmlib.GetPackage(pkgName, rootDir)
|
||||
}
|
||||
|
||||
databaseEntries := make([]*bpmlib.BPMDatabaseEntry, 0)
|
||||
for _, db := range bpmlib.BPMDatabases {
|
||||
databaseEntries = append(databaseEntries, slices.Collect(maps.Values(db.Entries))...)
|
||||
}
|
||||
|
||||
switch sortPackages {
|
||||
case "", "name":
|
||||
case "size":
|
||||
slices.SortFunc(installedPackages, func(a, b *bpmlib.BPMPackage) int {
|
||||
return int(b.GetInstalledSize() - a.GetInstalledSize())
|
||||
})
|
||||
slices.SortFunc(databaseEntries, func(a, b *bpmlib.BPMDatabaseEntry) int {
|
||||
return int(b.InstalledSize - a.InstalledSize)
|
||||
})
|
||||
default:
|
||||
log.Printf("Error: cannot sort by '%s'", sortPackages)
|
||||
exitCode = 1
|
||||
return
|
||||
}
|
||||
|
||||
if reversePackages {
|
||||
slices.Reverse(installedPackages)
|
||||
slices.Reverse(databaseEntries)
|
||||
}
|
||||
|
||||
if showPkgCount {
|
||||
if showDatabase {
|
||||
fmt.Println(len(databaseEntries))
|
||||
@@ -297,7 +328,7 @@ func showPackageList() {
|
||||
}
|
||||
} else {
|
||||
for _, pkg := range installedPackages {
|
||||
installationReason := bpmlib.GetInstallationReason(pkg, rootDir)
|
||||
installationReason := bpmlib.GetInstallationReason(pkg.PkgInfo.Name, rootDir)
|
||||
if installationReason == bpmlib.InstallationReasonManual && !showManual {
|
||||
continue
|
||||
} else if installationReason == bpmlib.InstallationReasonDependency && !showDepends {
|
||||
@@ -308,7 +339,7 @@ func showPackageList() {
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println(pkg)
|
||||
fmt.Println(pkg.PkgInfo.Name)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -321,21 +352,20 @@ func showPackageList() {
|
||||
if n != 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println(entry.CreateReadableInfo(rootDir))
|
||||
fmt.Println(entry.CreateReadableInfo(rootDir, showHumanReadableSize))
|
||||
}
|
||||
} else {
|
||||
if len(installedPackages) == 0 {
|
||||
fmt.Println("No packages have been installed")
|
||||
return
|
||||
}
|
||||
for n, pkg := range installedPackages {
|
||||
info := bpmlib.GetPackageInfo(pkg, rootDir)
|
||||
if info == nil {
|
||||
fmt.Printf("Package (%s) could not be found\n", pkg)
|
||||
for n, bpmpkg := range installedPackages {
|
||||
if bpmpkg == nil {
|
||||
fmt.Printf("Package (%s) could not be found\n", installedPackageNames[n])
|
||||
continue
|
||||
}
|
||||
|
||||
installationReason := bpmlib.GetInstallationReason(info.Name, rootDir)
|
||||
installationReason := bpmlib.GetInstallationReason(bpmpkg.PkgInfo.Name, rootDir)
|
||||
if installationReason == bpmlib.InstallationReasonManual && !showManual {
|
||||
continue
|
||||
} else if installationReason == bpmlib.InstallationReasonDependency && !showDepends {
|
||||
@@ -349,7 +379,7 @@ func showPackageList() {
|
||||
if n != 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
fmt.Println(info.CreateReadableInfo(rootDir))
|
||||
fmt.Println(bpmpkg.CreateReadableInfo(rootDir, showHumanReadableSize))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,23 +403,19 @@ func searchForPackages() {
|
||||
}
|
||||
|
||||
for i, term := range searchTerms {
|
||||
resultsMap := make(map[*bpmlib.PackageInfo]float64, 0)
|
||||
|
||||
// Loop through all packages
|
||||
// Find matches
|
||||
resultsMap := make(map[*bpmlib.BPMDatabaseEntry]int)
|
||||
for _, db := range bpmlib.BPMDatabases {
|
||||
for _, entry := range db.Entries {
|
||||
// Calculate string similarity and add to map
|
||||
similarity := strutil.Similarity(entry.Info.Name, term, metrics.NewSmithWatermanGotoh())
|
||||
if similarity > 0.8 {
|
||||
resultsMap[entry.Info] = similarity
|
||||
match := fuzzy.RankMatchNormalizedFold(term, entry.Info.Name)
|
||||
if match == -1 {
|
||||
continue
|
||||
}
|
||||
similarity = strutil.Similarity(entry.Info.Description, term, metrics.NewSmithWatermanGotoh())
|
||||
if similarity > 0.8 {
|
||||
resultsMap[entry.Info] = similarity
|
||||
}
|
||||
|
||||
resultsMap[entry] = match
|
||||
}
|
||||
}
|
||||
|
||||
if len(resultsMap) == 0 {
|
||||
log.Printf("Error: no results for term (%s) were found\n", term)
|
||||
exitCode = 1
|
||||
@@ -399,7 +425,7 @@ func searchForPackages() {
|
||||
// Sort results
|
||||
results := slices.Collect(maps.Keys(resultsMap))
|
||||
sort.Slice(results, func(i, j int) bool {
|
||||
return resultsMap[results[i]] > resultsMap[results[j]]
|
||||
return resultsMap[results[i]] < resultsMap[results[j]]
|
||||
})
|
||||
|
||||
// Print results
|
||||
@@ -409,7 +435,7 @@ func searchForPackages() {
|
||||
fmt.Printf("Results for term (%s)\n", term)
|
||||
for j := 0; j < 10 && j < len(results); j++ {
|
||||
result := results[j]
|
||||
fmt.Printf("%d) %s: %s (%s)\n", j+1, result.Name, result.Description, result.GetFullVersion())
|
||||
fmt.Printf("%d) %s/%s: %s (%s)\n", j+1, result.Database.Name, result.Info.Name, result.Info.Description, result.Info.GetFullVersion())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -280,7 +281,7 @@ func (entry *BPMDatabaseEntry) GetEntryDependants() (dependants []string) {
|
||||
return dependants
|
||||
}
|
||||
|
||||
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string) string {
|
||||
func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string, humanReadableSize bool) string {
|
||||
ret := make([]string, 0)
|
||||
appendArray := func(label string, array []string, sort bool) {
|
||||
if len(array) == 0 {
|
||||
@@ -346,5 +347,15 @@ func (entry *BPMDatabaseEntry) CreateReadableInfo(rootDir string) string {
|
||||
}
|
||||
ret = append(ret, "Installation Reason: "+installationReasonString)
|
||||
}
|
||||
if entry.Info.Type == "binary" {
|
||||
installedSize := int64(entry.InstalledSize)
|
||||
var installedSizeStr string
|
||||
if humanReadableSize {
|
||||
installedSizeStr = bytesToHumanReadable(installedSize)
|
||||
} else {
|
||||
installedSizeStr = strconv.FormatInt(installedSize, 10)
|
||||
}
|
||||
ret = append(ret, "Installed size: "+installedSizeStr)
|
||||
}
|
||||
return strings.Join(ret, "\n")
|
||||
}
|
||||
|
||||
+35
-25
@@ -507,7 +507,7 @@ func ReadPackageInfo(contents string) (*PackageInfo, error) {
|
||||
return pkgInfo, nil
|
||||
}
|
||||
|
||||
func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
||||
func (bpmpkg *BPMPackage) CreateReadableInfo(rootDir string, humanReadableSize bool) string {
|
||||
ret := make([]string, 0)
|
||||
appendArray := func(label string, array []string) {
|
||||
if len(array) == 0 {
|
||||
@@ -520,43 +520,43 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
||||
ret = append(ret, fmt.Sprintf("%s: %s", label, strings.Join(array, ", ")))
|
||||
}
|
||||
|
||||
ret = append(ret, "Name: "+pkgInfo.Name)
|
||||
ret = append(ret, "Description: "+pkgInfo.Description)
|
||||
ret = append(ret, "Version: "+pkgInfo.GetFullVersion())
|
||||
if pkgInfo.Url != "" {
|
||||
ret = append(ret, "URL: "+pkgInfo.Url)
|
||||
ret = append(ret, "Name: "+bpmpkg.PkgInfo.Name)
|
||||
ret = append(ret, "Description: "+bpmpkg.PkgInfo.Description)
|
||||
ret = append(ret, "Version: "+bpmpkg.PkgInfo.GetFullVersion())
|
||||
if bpmpkg.PkgInfo.Url != "" {
|
||||
ret = append(ret, "URL: "+bpmpkg.PkgInfo.Url)
|
||||
}
|
||||
if pkgInfo.License != "" {
|
||||
ret = append(ret, "License: "+pkgInfo.License)
|
||||
if bpmpkg.PkgInfo.License != "" {
|
||||
ret = append(ret, "License: "+bpmpkg.PkgInfo.License)
|
||||
}
|
||||
ret = append(ret, "Architecture: "+pkgInfo.Arch)
|
||||
if pkgInfo.Type == "source" && pkgInfo.OutputArch != "" && pkgInfo.OutputArch != GetArch() {
|
||||
ret = append(ret, "Output architecture: "+pkgInfo.Arch)
|
||||
ret = append(ret, "Architecture: "+bpmpkg.PkgInfo.Arch)
|
||||
if bpmpkg.PkgInfo.Type == "source" && bpmpkg.PkgInfo.OutputArch != "" && bpmpkg.PkgInfo.OutputArch != GetArch() {
|
||||
ret = append(ret, "Output architecture: "+bpmpkg.PkgInfo.Arch)
|
||||
}
|
||||
ret = append(ret, "Type: "+pkgInfo.Type)
|
||||
appendArray("Dependencies", pkgInfo.Depends)
|
||||
if pkgInfo.Type == "source" {
|
||||
appendArray("Make Dependencies", pkgInfo.MakeDepends)
|
||||
ret = append(ret, "Type: "+bpmpkg.PkgInfo.Type)
|
||||
appendArray("Dependencies", bpmpkg.PkgInfo.Depends)
|
||||
if bpmpkg.PkgInfo.Type == "source" {
|
||||
appendArray("Make Dependencies", bpmpkg.PkgInfo.MakeDepends)
|
||||
}
|
||||
appendArray("Optional dependencies", pkgInfo.OptionalDepends)
|
||||
dependants := pkgInfo.GetPackageDependants(rootDir)
|
||||
appendArray("Optional dependencies", bpmpkg.PkgInfo.OptionalDepends)
|
||||
dependants := bpmpkg.PkgInfo.GetPackageDependants(rootDir)
|
||||
if len(dependants) > 0 {
|
||||
appendArray("Dependant packages", dependants)
|
||||
}
|
||||
appendArray("Conflicting packages", pkgInfo.Conflicts)
|
||||
appendArray("Provided packages", pkgInfo.Provides)
|
||||
appendArray("Replaces packages", pkgInfo.Replaces)
|
||||
appendArray("Conflicting packages", bpmpkg.PkgInfo.Conflicts)
|
||||
appendArray("Provided packages", bpmpkg.PkgInfo.Provides)
|
||||
appendArray("Replaces packages", bpmpkg.PkgInfo.Replaces)
|
||||
|
||||
if pkgInfo.Type == "source" && len(pkgInfo.SplitPackages) != 0 {
|
||||
splitPkgs := make([]string, len(pkgInfo.SplitPackages))
|
||||
for i, splitPkgInfo := range pkgInfo.SplitPackages {
|
||||
if bpmpkg.PkgInfo.Type == "source" && len(bpmpkg.PkgInfo.SplitPackages) != 0 {
|
||||
splitPkgs := make([]string, len(bpmpkg.PkgInfo.SplitPackages))
|
||||
for i, splitPkgInfo := range bpmpkg.PkgInfo.SplitPackages {
|
||||
splitPkgs[i] = splitPkgInfo.Name
|
||||
}
|
||||
appendArray("Split Packages", splitPkgs)
|
||||
}
|
||||
|
||||
if rootDir != "" && IsPackageInstalled(pkgInfo.Name, rootDir) {
|
||||
installationReason := GetInstallationReason(pkgInfo.Name, rootDir)
|
||||
if rootDir != "" && IsPackageInstalled(bpmpkg.PkgInfo.Name, rootDir) {
|
||||
installationReason := GetInstallationReason(bpmpkg.PkgInfo.Name, rootDir)
|
||||
var installationReasonString string
|
||||
switch installationReason {
|
||||
case InstallationReasonManual:
|
||||
@@ -570,6 +570,16 @@ func (pkgInfo *PackageInfo) CreateReadableInfo(rootDir string) string {
|
||||
}
|
||||
ret = append(ret, "Installation Reason: "+installationReasonString)
|
||||
}
|
||||
if bpmpkg.PkgInfo.Type == "binary" {
|
||||
installedSize := int64(bpmpkg.GetInstalledSize())
|
||||
var installedSizeStr string
|
||||
if humanReadableSize {
|
||||
installedSizeStr = bytesToHumanReadable(installedSize)
|
||||
} else {
|
||||
installedSizeStr = strconv.FormatInt(installedSize, 10)
|
||||
}
|
||||
ret = append(ret, "Installed size: "+installedSizeStr)
|
||||
}
|
||||
return strings.Join(ret, "\n")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user