build: add support for building multiple version of the package.

This commit is contained in:
Alexandre Pujol 2025-08-12 16:11:10 +02:00
parent 2aa0d89f84
commit a5aa13923b
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
2 changed files with 26 additions and 12 deletions

View file

@ -63,27 +63,27 @@ build:
[group('build')]
[doc('Prebuild the profiles in enforced mode')]
enforce: build
@./{{build}}/prebuild
@./{{build}}/prebuild --buildir {{build}}
[group('build')]
[doc('Prebuild the profiles in complain mode')]
complain: build
@./{{build}}/prebuild --complain
./{{build}}/prebuild --buildir {{build}} --complain
[group('build')]
[doc('Prebuild the profiles in FSP mode')]
fsp: build
@./{{build}}/prebuild --full
@./{{build}}/prebuild --buildir {{build}} --full
[group('build')]
[doc('Prebuild the profiles in FSP mode (complain)')]
fsp-complain: build
@./{{build}}/prebuild --complain --full
@./{{build}}/prebuild --buildir {{build}} --complain --full
[group('build')]
[doc('Prebuild the profiles in FSP mode (debug)')]
fsp-debug: build
@./{{build}}/prebuild --complain --full --debug
@./{{build}}/prebuild --buildir {{build}} --complain --full --debug
[group('install')]
[doc('Install prebuild profiles')]

View file

@ -26,13 +26,15 @@ const (
internal built-in directives.
Options:
-h, --help Show this help message and exit.
-c, --complain Set complain flag on all profiles.
-e, --enforce Set enforce flag on all profiles.
-a, --abi ABI Target apparmor ABI.
-v, --version V Target apparmor version.
-f, --full Set AppArmor for full system policy.
-F, --file Only prebuild a given file.
-h, --help Show this help message and exit.
-c, --complain Set complain flag on all profiles.
-e, --enforce Set enforce flag on all profiles.
-a, --abi ABI Target apparmor ABI.
-v, --version V Target apparmor version.
-f, --full Set AppArmor for full system policy.
-b, --buildir DIR Root build directory.
-F, --file Only prebuild a given file.
--debug Enable debug mode.
`
)
@ -41,9 +43,11 @@ var (
complain bool
enforce bool
full bool
debug bool
abi int
version float64
file string
buildir string
)
func init() {
@ -61,6 +65,9 @@ func init() {
flag.Float64Var(&version, "version", nilVer, "Target apparmor version.")
flag.StringVar(&file, "F", "", "Only prebuild a given file.")
flag.StringVar(&file, "file", "", "Only prebuild a given file.")
flag.StringVar(&buildir, "b", "", "Root build directory.")
flag.StringVar(&buildir, "buildir", "", "Root build directory.")
flag.BoolVar(&debug, "debug", false, "Enable debug mode.")
}
func Configure() {
@ -87,6 +94,9 @@ func Configure() {
if complain {
builder.Register("complain")
if debug {
builder.Register("debug")
}
} else if enforce {
builder.Register("enforce")
}
@ -106,6 +116,10 @@ func Configure() {
if version != nilVer {
prebuild.Version = version
}
if buildir != "" {
prebuild.Root = paths.New(buildir)
prebuild.RootApparmord = prebuild.Root.Join("apparmor.d")
}
if file != "" {
sync, _ := prepare.Tasks["synchronise"].(*prepare.Synchronise)
sync.Paths = []string{file}