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

@ -9,9 +9,7 @@ import (
"os/exec"
"testing"
"github.com/roddhjav/apparmor.d/pkg/prebuild/builder"
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
"github.com/roddhjav/apparmor.d/pkg/prebuild/prepare"
"github.com/roddhjav/apparmor.d/pkg/prebuild"
)
func chdirGitRoot() {
@ -26,64 +24,33 @@ func chdirGitRoot() {
}
}
func Test_AAPrebuild(t *testing.T) {
func Test_main(t *testing.T) {
tests := []struct {
name string
wantErr bool
full bool
complain bool
dist string
name string
dist string
}{
{
name: "Build for Archlinux",
wantErr: false,
full: false,
complain: true,
dist: "arch",
name: "Build for Archlinux",
dist: "arch",
},
{
name: "Build for Ubuntu",
wantErr: false,
full: true,
complain: false,
dist: "ubuntu",
name: "Build for Ubuntu",
dist: "ubuntu",
},
{
name: "Build for Debian",
wantErr: false,
full: true,
complain: false,
dist: "debian",
name: "Build for Debian",
dist: "debian",
},
{
name: "Build for OpenSUSE Tumbleweed",
wantErr: false,
full: true,
complain: true,
dist: "opensuse",
name: "Build for OpenSUSE Tumbleweed",
dist: "opensuse",
},
// {
// name: "Build for Fedora",
// wantErr: true,
// full: false,
// complain: false,
// dist: "fedora",
// },
}
chdirGitRoot()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cfg.Distribution = tt.dist
if tt.full {
prepare.Register("fsp")
builder.Register("fsp")
}
if tt.complain {
builder.Register("complain")
}
if err := aaPrebuild(); (err != nil) != tt.wantErr {
t.Errorf("aaPrebuild() error = %v, wantErr %v", err, tt.wantErr)
}
prebuild.Distribution = tt.dist
main()
})
}
}