build: reorganise build: abi4, fallback, prebuild cli

- ABI4 by default, fallback to abi 3.
- aa-prebuild cli that can be used by other project shipping profiles.
- --file option to cli to only build one dev profile.
- add abi version filter to only & exclude directives.
This commit is contained in:
Alexandre Pujol 2024-10-02 16:22:46 +01:00
parent d6b7bef89e
commit 59ac54e2fc
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
39 changed files with 473 additions and 440 deletions

View file

@ -6,35 +6,53 @@ package prepare
import (
"github.com/roddhjav/apparmor.d/pkg/paths"
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
"github.com/roddhjav/apparmor.d/pkg/prebuild"
"github.com/roddhjav/apparmor.d/pkg/util"
)
type Synchronise struct {
cfg.Base
prebuild.Base
Path string
}
func init() {
RegisterTask(&Synchronise{
Base: cfg.Base{
Base: prebuild.Base{
Keyword: "synchronise",
Msg: "Initialize a new clean apparmor.d build directory",
},
Path: "",
})
}
func (p Synchronise) Apply() ([]string, error) {
res := []string{}
dirs := paths.PathList{cfg.RootApparmord, cfg.Root.Join("root"), cfg.Root.Join("systemd")}
dirs := paths.PathList{prebuild.RootApparmord, prebuild.Root.Join("root"), prebuild.Root.Join("systemd")}
for _, dir := range dirs {
if err := dir.RemoveAll(); err != nil {
return res, err
}
}
for _, name := range []string{"apparmor.d", "root"} {
if err := util.CopyTo(paths.New(name), cfg.Root.Join(name)); err != nil {
if p.Path == "" {
for _, name := range []string{"apparmor.d", "root"} {
if err := util.CopyTo(paths.New(name), prebuild.Root.Join(name)); 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())
}
return res, nil
}