to build or not to build is the question

This commit is contained in:
Jeff Carr 2024-11-22 19:11:36 -06:00
parent 9b401ef56b
commit bb620b3d9b
1 changed files with 51 additions and 0 deletions

51
wit.go
View File

@ -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 {