2018-03-06 00:02:36 -08:00
|
|
|
package pm
|
|
|
|
|
2018-03-06 20:35:03 -08:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"sort"
|
|
|
|
)
|
2018-03-06 00:10:46 -08:00
|
|
|
|
2018-03-06 00:02:36 -08:00
|
|
|
// Installed tracks installed packages.
|
|
|
|
type Installed map[Name]Meta
|
2018-03-06 00:10:46 -08:00
|
|
|
|
|
|
|
// Traverse returns a chan of Meta that will be sanely sorted.
|
|
|
|
func (i Installed) Traverse() <-chan Meta {
|
|
|
|
r := make(chan Meta)
|
|
|
|
go func() {
|
|
|
|
names := Names{}
|
|
|
|
for n := range i {
|
|
|
|
names = append(names, n)
|
|
|
|
}
|
|
|
|
sort.Sort(names)
|
|
|
|
|
|
|
|
for _, n := range names {
|
|
|
|
r <- i[n]
|
|
|
|
}
|
|
|
|
close(r)
|
|
|
|
}()
|
|
|
|
return r
|
|
|
|
}
|
2018-03-06 20:35:03 -08:00
|
|
|
|
|
|
|
// Removable calculates if the packages requested in "in" can all be removed.
|
|
|
|
func (i Installed) Removable(names []string) (Metas, error) {
|
|
|
|
return nil, errors.New("NYI")
|
|
|
|
}
|