2024-03-25 23:38:01 +01:00
|
|
|
// apparmor.d - Full set of apparmor profiles
|
|
|
|
// Copyright (C) 2021-2024 Alexandre Pujol <alexandre@pujol.io>
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
|
2024-10-02 17:22:46 +02:00
|
|
|
package prebuild
|
2024-03-25 23:38:01 +01:00
|
|
|
|
2024-10-23 15:48:47 +02:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/roddhjav/apparmor.d/pkg/paths"
|
|
|
|
)
|
2024-03-25 23:38:01 +01:00
|
|
|
|
|
|
|
var (
|
2024-10-02 17:22:46 +02:00
|
|
|
// AppArmor ABI version
|
|
|
|
ABI uint = 0
|
|
|
|
|
2024-10-23 15:48:47 +02:00
|
|
|
// Root is the root directory for the build (default: ./.build)
|
|
|
|
Root *paths.Path = getRootBuild()
|
2024-03-25 23:38:01 +01:00
|
|
|
|
2024-10-06 21:15:13 +02:00
|
|
|
// RootApparmord is the final built apparmor.d directory (default: .build/apparmor.d)
|
2024-10-23 15:48:47 +02:00
|
|
|
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)
|
2024-03-25 23:38:01 +01:00
|
|
|
|
|
|
|
// DistDir is the directory where the distribution specific files are stored
|
|
|
|
DistDir *paths.Path = paths.New("dists")
|
|
|
|
|
|
|
|
// FlagDir is the directory where the flags are stored
|
|
|
|
FlagDir *paths.Path = DistDir.Join("flags")
|
|
|
|
|
2024-03-26 19:05:55 +01:00
|
|
|
// IgnoreDir is the directory where the ignore files are stored
|
|
|
|
IgnoreDir *paths.Path = DistDir.Join("ignore")
|
|
|
|
|
2024-10-23 15:48:47 +02:00
|
|
|
// PkgDir is the directory where the packages files are stored
|
|
|
|
PkgDir *paths.Path = DistDir.Join("packages")
|
|
|
|
|
2024-03-25 23:38:01 +01:00
|
|
|
// SystemdDir is the directory where the systemd drop-in files are stored
|
|
|
|
SystemdDir *paths.Path = paths.New("systemd")
|
|
|
|
|
2024-03-26 19:05:55 +01:00
|
|
|
// DebianDir is the directory where the debian specific files are stored
|
2024-03-27 17:26:01 +01:00
|
|
|
DebianDir *paths.Path = paths.New("debian")
|
2024-03-26 19:05:55 +01:00
|
|
|
|
2024-06-04 20:55:53 +02:00
|
|
|
// DebianHide is the path to the debian/apparmor.d.hide file
|
|
|
|
DebianHide = DebianHider{path: DebianDir.Join("apparmor.d.hide")}
|
2024-03-26 19:05:55 +01:00
|
|
|
|
2024-10-23 15:48:47 +02:00
|
|
|
// Packages are the packages to build
|
|
|
|
Packages = getPackages()
|
|
|
|
|
2024-03-26 19:05:55 +01:00
|
|
|
Ignore = Ignorer{}
|
|
|
|
Flags = Flagger{}
|
2024-03-25 23:38:01 +01:00
|
|
|
)
|
2024-10-23 15:48:47 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|