deb-simple/config.go

74 lines
1.6 KiB
Go

package main
import (
"path"
"strings"
)
type Conf struct {
Fs FsConf `ini:"fs"`
Http HttpConf `ini:"http"`
Repo RepoConf `ini:"repo"`
PGP PGPConf `ini:"pgp"`
}
type FsConf struct {
Driver string `ini:"driver"`
TmpDriver string `ini:"tmpDriver"`
S3 struct {
Bucket string `ini:"bucket"`
Region string `ini:"region"`
Endpoint string `ini:"endpoint"`
ID string `ini:"id"`
Secret string `ini:"secret"`
} `ini:"s3"`
}
type HttpConf struct {
Port int `ini:"port"`
Key string `ini:"key"`
SSL bool `ini:"ssl"`
SSLCert string `ini:"cert"`
SSLKey string `ini:"key"`
EnableVhosts bool `ini:"vhosts"`
}
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 {
return path.Join("dists", distro)
}
func (c Conf) ArchPath(distro, arch string) string {
return path.Join("dists", distro, "main/binary-"+arch)
}
func (c Conf) PoolPath(distro, arch string) string {
return path.Join("pool/main", distro, arch)
}
func (c Conf) PoolPackagePath(distro, arch, name string) string {
return c.RelativePoolPackagePath(distro, arch, name)
}
func (c Conf) RelativePoolPackagePath(distro, arch, name string) string {
name = packageName(name)
return path.Join("pool/main", distro, arch, name[0:1], name)
}
func (c RepoConf) DistroNames() []string {
return strings.Split(c.Distros, ",")
}
func (c RepoConf) ArchitectureNames() []string {
return strings.Split(c.Architectures, ",")
}