-
Notifications
You must be signed in to change notification settings - Fork 2
/
target.go
69 lines (63 loc) · 1.82 KB
/
target.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package aptsources // import "go.tianon.xyz/aptsources"
import (
"strings"
)
var (
DefaultTypes = []string{"deb", "deb-src"}
DefaultDebianURIs = []string{"http://deb.debian.org/debian"}
DefaultDebianSecurityURIs = []string{"http://security.debian.org"}
DefaultUbuntuURIs = []string{"http://archive.ubuntu.com/ubuntu"}
)
func DebianSources(suite string, components ...string) Sources {
suite = strings.TrimSuffix(suite, "-security")
source := Source{
Types: DefaultTypes,
URIs: DefaultDebianURIs,
Suites: []string{suite},
Components: components,
}
switch suite {
case "experimental", "rc-buggy":
source.Suites = append([]string{"sid"}, source.Suites...)
fallthrough
case "sid", "unstable":
return New(source)
}
origSuite := suite
for _, suffix := range []string{"backports", "lts"} {
suffix = "-" + suffix
if strings.HasSuffix(suite, suffix) {
suite = suite[:len(suite)-len(suffix)]
source.Suites = append([]string{suite}, source.Suites...)
}
}
source.Suites = append(source.Suites, suite+"-updates")
sources := New(source, Source{
Types: source.Types,
URIs: DefaultDebianSecurityURIs,
Suites: []string{suite + "/updates"},
Components: source.Components,
})
switch suite {
case "squeeze":
if origSuite != suite+"-lts" {
sources = sources.Append(Source{
Types: source.Types,
URIs: source.URIs,
Suites: []string{suite + "-lts"},
Components: source.Components,
})
}
}
return sources
}
func UbuntuSources(suite string, components ...string) Sources {
suite = strings.TrimSuffix(suite, "-updates")
suite = strings.TrimSuffix(suite, "-security")
return New(Source{
Types: DefaultTypes,
URIs: DefaultUbuntuURIs,
Suites: []string{suite, suite + "-updates", suite + "-security"},
Components: components,
})
}