mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-24 11:58:12 +01:00
build: make synchronise task configurable.
Required by downtream repository.
This commit is contained in:
parent
f1182b27bb
commit
9953cf1fbd
2 changed files with 25 additions and 24 deletions
|
@ -99,7 +99,7 @@ func Configure() {
|
||||||
|
|
||||||
if file != "" {
|
if file != "" {
|
||||||
sync, _ := prepare.Tasks["synchronise"].(*prepare.Synchronise)
|
sync, _ := prepare.Tasks["synchronise"].(*prepare.Synchronise)
|
||||||
sync.Path = file
|
sync.Paths = []string{file}
|
||||||
overwrite, _ := prepare.Tasks["overwrite"].(*prepare.Overwrite)
|
overwrite, _ := prepare.Tasks["overwrite"].(*prepare.Overwrite)
|
||||||
overwrite.OneFile = true
|
overwrite.OneFile = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
type Synchronise struct {
|
type Synchronise struct {
|
||||||
prebuild.Base
|
prebuild.Base
|
||||||
Path string
|
Paths []string // File or directory to sync into the build directory.
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -20,38 +20,39 @@ func init() {
|
||||||
Keyword: "synchronise",
|
Keyword: "synchronise",
|
||||||
Msg: "Initialize a new clean apparmor.d build directory",
|
Msg: "Initialize a new clean apparmor.d build directory",
|
||||||
},
|
},
|
||||||
Path: "",
|
Paths: []string{"apparmor.d", "share"},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Synchronise) Apply() ([]string, error) {
|
func (p Synchronise) Apply() ([]string, error) {
|
||||||
res := []string{}
|
res := []string{}
|
||||||
dirs := paths.PathList{prebuild.RootApparmord, prebuild.Root.Join("share"), prebuild.Root.Join("systemd")}
|
if err := prebuild.Root.Join("systemd").RemoveAll(); err != nil {
|
||||||
for _, dir := range dirs {
|
|
||||||
if err := dir.RemoveAll(); err != nil {
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
}
|
if err := prebuild.RootApparmord.RemoveAll(); err != nil {
|
||||||
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
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, name := range p.Paths {
|
||||||
|
src := paths.New(name)
|
||||||
|
dst := prebuild.Root.Join(name)
|
||||||
|
if err := dst.RemoveAll(); err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if src.IsDir() {
|
||||||
|
if err := paths.CopyTo(src, dst); err != nil {
|
||||||
|
return res, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
file := paths.New(p.Path)
|
if err := dst.Parent().MkdirAll(); err != nil {
|
||||||
destination, err := file.RelFrom(paths.New("apparmor.d"))
|
|
||||||
if err != nil {
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
destination = prebuild.RootApparmord.JoinPath(destination)
|
if err := src.CopyTo(dst); err != nil {
|
||||||
if err := destination.Parent().MkdirAll(); err != nil {
|
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
if err := file.CopyTo(destination); err != nil {
|
|
||||||
return res, err
|
|
||||||
}
|
}
|
||||||
res = append(res, destination.String())
|
res = append(res, dst.String())
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue