52
52
// Please resist the temptation of optimizing the regexp by grouping
53
53
// things by hand. People will find it unreadable enough as it is.
54
var shouldExclude = regexp.MustCompile(strings.Join([]string{
54
var shouldExcludeDefault = regexp.MustCompile(strings.Join([]string{
55
55
`\.snap$`, // added
85
86
}, "|")).MatchString
88
// fake static function variables
91
exclude func(string) bool
94
func (k *keep) shouldExclude(basedir string, file string) bool {
95
if basedir == k.basedir {
100
return k.exclude(file)
106
snapignore, err := os.Open(filepath.Join(basedir, ".snapignore"))
111
scanner := bufio.NewScanner(snapignore)
114
line := scanner.Text()
115
if _, err := regexp.Compile(line); err != nil {
117
line = regexp.QuoteMeta(line)
119
lines = append(lines, line)
122
fullRegex := strings.Join(lines, "|")
123
exclude, err := regexp.Compile(fullRegex)
125
k.exclude = exclude.MatchString
127
return k.exclude(file)
130
// can't happen; can't even find a way to trigger it in testing.
131
panic(fmt.Sprintf("|-composition of valid regexps is invalid?!? Please report this bug: %#v", fullRegex))
134
var shouldExcludeDynamic = new(keep).shouldExclude
136
func shouldExclude(basedir string, file string) bool {
137
return shouldExcludeDefault(file) || shouldExcludeDynamic(basedir, file)
87
140
// small helper that return the architecture or "multi" if its multiple arches
88
141
func debArchitecture(m *packageYaml) string {
89
142
switch len(m.Architectures) {
141
194
func handleServices(buildDir string, m *packageYaml) error {
142
for _, v := range m.Services {
195
for _, v := range m.ServiceYamls {
143
196
hookName := filepath.Base(v.Name)
145
198
// handle the apparmor stuff