to build or not to build is the question
This commit is contained in:
parent
9b401ef56b
commit
bb620b3d9b
51
wit.go
51
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 {
|
||||
|
|
Loading…
Reference in New Issue