1
0
Fork 0
squid-rewriter/distro/distro.go

58 lines
810 B
Go

package distro
import (
"sync"
)
const DefaultRepo = "main"
type RepoMirror struct {
Distro string
Repo string
Url string
}
type Distro interface {
GetName() string
GetRepos() []string
FetchMirrors(repos []string, repoMirrors chan<- RepoMirror, done *sync.WaitGroup)
}
var allDistros []Distro = []Distro{
Alpine{},
Arch{},
Debian{},
Fedora{},
Mint{},
Slackware{},
Ubuntu{},
}
var distrosByName map[string]Distro
func init() {
distrosByName = make(map[string]Distro)
for _, d := range allDistros {
distrosByName[d.GetName()] = d
}
}
func GetDistro(name string) Distro {
r, ok := distrosByName[name]
if !ok {
return nil
}
return r
}
func HasRepo(d Distro, name string) bool {
for _, repo := range d.GetRepos() {
if repo == name {
return true
}
}
return false
}