mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-01-24 03:48:13 +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 != "" {
|
||||
sync, _ := prepare.Tasks["synchronise"].(*prepare.Synchronise)
|
||||
sync.Path = file
|
||||
sync.Paths = []string{file}
|
||||
overwrite, _ := prepare.Tasks["overwrite"].(*prepare.Overwrite)
|
||||
overwrite.OneFile = true
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
|
||||
type Synchronise struct {
|
||||
prebuild.Base
|
||||
Path string
|
||||
Paths []string // File or directory to sync into the build directory.
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -20,38 +20,39 @@ func init() {
|
|||
Keyword: "synchronise",
|
||||
Msg: "Initialize a new clean apparmor.d build directory",
|
||||
},
|
||||
Path: "",
|
||||
Paths: []string{"apparmor.d", "share"},
|
||||
})
|
||||
}
|
||||
|
||||
func (p Synchronise) Apply() ([]string, error) {
|
||||
res := []string{}
|
||||
dirs := paths.PathList{prebuild.RootApparmord, prebuild.Root.Join("share"), prebuild.Root.Join("systemd")}
|
||||
for _, dir := range dirs {
|
||||
if err := dir.RemoveAll(); err != nil {
|
||||
if err := prebuild.Root.Join("systemd").RemoveAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
if err := prebuild.RootApparmord.RemoveAll(); err != nil {
|
||||
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 p.Path == "" {
|
||||
for _, name := range []string{"apparmor.d", "share"} {
|
||||
if err := paths.CopyTo(paths.New(name), prebuild.Root.Join(name)); err != nil {
|
||||
|
||||
if src.IsDir() {
|
||||
if err := paths.CopyTo(src, dst); err != nil {
|
||||
return res, err
|
||||
}
|
||||
} else {
|
||||
if err := dst.Parent().MkdirAll(); err != nil {
|
||||
return res, err
|
||||
}
|
||||
if err := src.CopyTo(dst); err != nil {
|
||||
return res, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
file := paths.New(p.Path)
|
||||
destination, err := file.RelFrom(paths.New("apparmor.d"))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
destination = prebuild.RootApparmord.JoinPath(destination)
|
||||
if err := destination.Parent().MkdirAll(); err != nil {
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue