summaryrefslogtreecommitdiff
path: root/wit.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-22 19:11:36 -0600
committerJeff Carr <[email protected]>2024-11-22 19:11:36 -0600
commitbb620b3d9b5d28363d932db438a6c36369f3bdc5 (patch)
treeb051e69c4d7dddc6b983b274db7c4b21b5dfc5c4 /wit.go
parent9b401ef56bfc7277f0952467a11de798accc6ae8 (diff)
to build or not to build is the questionv0.0.8
Diffstat (limited to 'wit.go')
-rw-r--r--wit.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/wit.go b/wit.go
index 0f68aae..6a19efa 100644
--- a/wit.go
+++ b/wit.go
@@ -24,6 +24,57 @@ func (m *Machine) IsInstalled(name string) bool {
return false
}
+func (m *Machine) FindInstalledByName(name string) *Package {
+ loop := m.Packages.SortByName()
+ for loop.Scan() {
+ p := loop.Package()
+ if name == p.Name {
+ // log.Info("package installed:", p.Name, p.Version, p.PkgName)
+ return p
+ }
+ }
+
+ // log.Info("package not-installed:", name)
+ return nil
+}
+
+// looks to see if any package matches a name and version
+// if version == "", return the first name found
+func (m *Machine) FindVersion(name string, version string) *Package {
+ // first check all installed versions
+ loop := m.Packages.SortByName()
+ for loop.Scan() {
+ p := loop.Package()
+ if name == p.Name {
+ if version == "" {
+ return p
+ } else {
+ if version == p.Version {
+ return p
+ }
+ }
+ }
+ }
+
+ // check all wit packages
+ loop = m.Wit.SortByName()
+ for loop.Scan() {
+ p := loop.Package()
+ if name == p.Name {
+ if version == "" {
+ return p
+ } else {
+ if version == p.Version {
+ return p
+ }
+ }
+ }
+ }
+
+ // log.Info("package not-installed:", name)
+ return nil
+}
+
// read the package list file from mirrors.wit.com
func (m *Machine) InitWit() error {
if m.Wit == nil {