build: update directive and prepare tasks to new structure.
This commit is contained in:
parent
17cee26dc0
commit
b614bdda36
8 changed files with 57 additions and 17 deletions
|
|
@ -5,6 +5,9 @@
|
|||
package prepare
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/roddhjav/apparmor.d/pkg/paths"
|
||||
"github.com/roddhjav/apparmor.d/pkg/prebuild"
|
||||
)
|
||||
|
|
@ -26,21 +29,39 @@ func (p Ignore) Apply() ([]string, error) {
|
|||
res := []string{}
|
||||
for _, name := range []string{"main", prebuild.Distribution} {
|
||||
for _, ignore := range prebuild.Ignore.Read(name) {
|
||||
profile := prebuild.Root.Join(ignore)
|
||||
if profile.NotExist() {
|
||||
files, err := prebuild.RootApparmord.ReadDirRecursiveFiltered(nil, paths.FilterNames(ignore))
|
||||
// Ignore file from share/
|
||||
path := prebuild.Root.Join(ignore)
|
||||
if path.Exist() {
|
||||
if err := path.RemoveAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Ignore file from apparmor.d/
|
||||
profile := strings.TrimPrefix(ignore, prebuild.Src+"/")
|
||||
if strings.HasPrefix(ignore, prebuild.Src) {
|
||||
path = prebuild.RootApparmord.Join(profile)
|
||||
}
|
||||
if path.Exist() {
|
||||
if err := path.RemoveAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
} else {
|
||||
files, err := prebuild.RootApparmord.ReadDirRecursiveFiltered(nil, paths.FilterNames(profile))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if len(files) == 0 {
|
||||
return res, fmt.Errorf("%s.ignore: no files found for '%s'", name, profile)
|
||||
}
|
||||
for _, path := range files {
|
||||
if err := path.RemoveAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err := profile.RemoveAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
res = append(res, prebuild.IgnoreDir.Join(name+".ignore").String())
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ func (p Merge) Apply() ([]string, error) {
|
|||
|
||||
files, err = filepath.Glob(prebuild.RootApparmord.Join(dirRemoved).String())
|
||||
if err != nil {
|
||||
return []string{}, err
|
||||
return res, err
|
||||
}
|
||||
for _, file := range files {
|
||||
if err := paths.New(file).RemoveAll(); err != nil {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ func (p Overwrite) Apply() ([]string, error) {
|
|||
continue
|
||||
}
|
||||
if err := origin.Rename(dest); err != nil {
|
||||
|
||||
return res, err
|
||||
}
|
||||
originRel, err := origin.RelFrom(dest)
|
||||
|
|
|
|||
|
|
@ -33,14 +33,15 @@ func (p Synchronise) Apply() ([]string, error) {
|
|||
}
|
||||
}
|
||||
if p.Path == "" {
|
||||
for _, name := range []string{"apparmor.d", "share"} {
|
||||
if err := paths.CopyTo(paths.New(name), prebuild.Root.Join(name)); err != nil {
|
||||
return res, err
|
||||
}
|
||||
if err := paths.CopyTo(paths.New("share"), prebuild.Root.Join("share")); err != nil {
|
||||
return res, err
|
||||
}
|
||||
if err := paths.CopyTo(prebuild.SrcApparmord, prebuild.RootApparmord); err != nil {
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
file := paths.New(p.Path)
|
||||
destination, err := file.RelFrom(paths.New("apparmor.d"))
|
||||
destination, err := file.RelFrom(prebuild.SrcApparmord)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue