/
artefact.go
107 lines (87 loc) · 2.73 KB
/
artefact.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
Copyright (C) 2020-2021 Daniele Rondina <geaaru@sabayonlinux.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package specs
import (
"errors"
)
func NewPortageConverterArtefact(pkg string) *PortageConverterArtefact {
return &PortageConverterArtefact{
Tree: "",
IgnoreBuildDeps: false,
Packages: []string{pkg},
OverrideVersion: "",
}
}
func (a *PortageConverterArtefact) GetPackages() []string { return a.Packages }
func (a *PortageConverterArtefact) GetTree() string { return a.Tree }
func (a *PortageConverterArtefact) HasRuntimeMutations() bool {
ans := false
if len(a.Mutations.RuntimeDeps.Packages) > 0 || len(a.Mutations.Uses) > 0 {
ans = true
}
return ans
}
func (a *PortageConverterArtefact) HasBuildtimeMutations() bool {
if len(a.Mutations.BuildTimeDeps.Packages) > 0 {
return true
}
return false
}
func (a *PortageConverterArtefact) HasOverrideVersion(pkg string) bool {
ans := false
hasPkg := false
for _, p := range a.Packages {
if p == pkg {
hasPkg = true
break
}
}
if hasPkg && a.OverrideVersion != "" {
ans = true
}
return ans
}
func (a *PortageConverterArtefact) GetOverrideVersion() string {
return a.OverrideVersion
}
func (a *PortageConverterArtefact) IgnoreBuildtime(pkg string) bool {
_, ans := a.MapIgnoreBuildtime[pkg]
return ans
}
func (a *PortageConverterArtefact) IgnoreRuntime(pkg string) bool {
_, ans := a.MapIgnoreRuntime[pkg]
return ans
}
func (s *PortageConverterArtefact) HasRuntimeReplacement(pkg string) bool {
_, ans := s.MapReplacementsRuntime[pkg]
return ans
}
func (s *PortageConverterArtefact) HasBuildtimeReplacement(pkg string) bool {
_, ans := s.MapReplacementsBuildtime[pkg]
return ans
}
func (s *PortageConverterArtefact) GetBuildtimeReplacement(pkg string) (*PortageConverterReplacePackage, error) {
ans, ok := s.MapReplacementsBuildtime[pkg]
if ok {
return ans, nil
}
return ans, errors.New("No replacement found for key " + pkg)
}
func (s *PortageConverterArtefact) GetRuntimeReplacement(pkg string) (*PortageConverterReplacePackage, error) {
ans, ok := s.MapReplacementsRuntime[pkg]
if ok {
return ans, nil
}
return ans, errors.New("No replacement found for key " + pkg)
}