build: add initial build structure for sub packages.

This commit is contained in:
Alexandre Pujol 2024-10-23 14:48:47 +01:00
parent 467b24ccee
commit a1c8260305
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
5 changed files with 391 additions and 37 deletions

View file

@ -4,17 +4,28 @@
package prebuild
import "github.com/roddhjav/apparmor.d/pkg/paths"
import (
"os"
"strings"
"github.com/roddhjav/apparmor.d/pkg/paths"
)
var (
// AppArmor ABI version
ABI uint = 0
// Root is the root directory for the build (default: .build)
Root *paths.Path = paths.New(".build")
// Root is the root directory for the build (default: ./.build)
Root *paths.Path = getRootBuild()
// RootApparmord is the final built apparmor.d directory (default: .build/apparmor.d)
RootApparmord *paths.Path = Root.Join("apparmor.d")
RootApparmord *paths.Path = Root.Join(Src)
// src is the basename of the source directory (default: apparmor.d)
Src = "apparmor.d"
// SrcApparmord is the source apparmor.d directory (default: ./apparmor.d)
SrcApparmord *paths.Path = paths.New(Src)
// DistDir is the directory where the distribution specific files are stored
DistDir *paths.Path = paths.New("dists")
@ -25,6 +36,9 @@ var (
// IgnoreDir is the directory where the ignore files are stored
IgnoreDir *paths.Path = DistDir.Join("ignore")
// PkgDir is the directory where the packages files are stored
PkgDir *paths.Path = DistDir.Join("packages")
// SystemdDir is the directory where the systemd drop-in files are stored
SystemdDir *paths.Path = paths.New("systemd")
@ -34,6 +48,29 @@ var (
// DebianHide is the path to the debian/apparmor.d.hide file
DebianHide = DebianHider{path: DebianDir.Join("apparmor.d.hide")}
// Packages are the packages to build
Packages = getPackages()
Ignore = Ignorer{}
Flags = Flagger{}
)
func getRootBuild() *paths.Path {
root, present := os.LookupEnv("BUILD")
if !present {
root = ".build"
}
return paths.New(root)
}
func getPackages() []string {
files, err := PkgDir.ReadDirRecursiveFiltered(nil, paths.FilterOutDirectories())
if err != nil {
panic(err)
}
packages := make([]string, 0, len(files))
for _, file := range files {
packages = append(packages, strings.TrimSuffix(file.Base(), ".conf"))
}
return packages
}