2018-10-14 08:17:04 +00:00
|
|
|
package main
|
2017-06-12 00:41:49 +00:00
|
|
|
|
|
|
|
import (
|
2017-09-14 03:33:29 +00:00
|
|
|
"path"
|
2018-10-14 08:35:50 +00:00
|
|
|
"strings"
|
2017-06-12 00:41:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Conf struct {
|
|
|
|
Http HttpConf `ini:"http"`
|
|
|
|
Repo RepoConf `ini:"repo"`
|
|
|
|
PGP PGPConf `ini:"pgp"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type HttpConf struct {
|
|
|
|
Port int `ini:"port"`
|
|
|
|
Key string `ini:"key"`
|
|
|
|
SSL bool `ini:"ssl"`
|
|
|
|
SSLCert string `ini:"cert"`
|
|
|
|
SSLKey string `ini:"key"`
|
2018-10-14 08:14:17 +00:00
|
|
|
EnableVhosts bool `ini:"vhosts"`
|
2017-06-12 00:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RepoConf struct {
|
|
|
|
Root string `ini:"root"`
|
|
|
|
Distros string `ini:"distros"`
|
|
|
|
Architectures string `ini:"architectures"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PGPConf struct {
|
|
|
|
Key string `ini:"key"`
|
|
|
|
Passphrase string `ini:"passphrase"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c Conf) DistPath(distro string) string {
|
2020-06-14 08:29:16 +00:00
|
|
|
return path.Join("dists", distro)
|
2017-06-12 00:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Conf) ArchPath(distro, arch string) string {
|
2020-06-14 08:29:16 +00:00
|
|
|
return path.Join("dists", distro, "main/binary-"+arch)
|
2017-06-12 00:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Conf) PoolPath(distro, arch string) string {
|
2020-06-14 08:29:16 +00:00
|
|
|
return path.Join("pool/main", distro, arch)
|
2017-06-12 00:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Conf) PoolPackagePath(distro, arch, name string) string {
|
2020-06-14 08:29:16 +00:00
|
|
|
return c.RelativePoolPackagePath(distro, arch, name)
|
2017-09-14 03:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c Conf) RelativePoolPackagePath(distro, arch, name string) string {
|
2017-06-12 00:41:49 +00:00
|
|
|
name = packageName(name)
|
2017-09-14 04:23:39 +00:00
|
|
|
return path.Join("pool/main", distro, arch, name[0:1], name)
|
2017-06-12 00:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c RepoConf) DistroNames() []string {
|
|
|
|
return strings.Split(c.Distros, ",")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c RepoConf) ArchitectureNames() []string {
|
|
|
|
return strings.Split(c.Architectures, ",")
|
|
|
|
}
|