generated from falcosecurity/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added AlmaLinux drivekit and added RockyLinux 9
Signed-off-by: Daniele De Lorenzi <daniele.delorenzi@fastnetserv.net>
- Loading branch information
Showing
3 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package builder | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"github.com/falcosecurity/driverkit/pkg/kernelrelease" | ||
) | ||
|
||
//go:embed templates/almalinux.sh | ||
var almaTemplate string | ||
|
||
// TargetTypeAlma identifies the Alma target. | ||
const TargetTypeAlma Type = "alma" | ||
|
||
func init() { | ||
BuilderByTarget[TargetTypeAlma] = &alma{} | ||
} | ||
|
||
type almaTemplateData struct { | ||
commonTemplateData | ||
KernelDownloadURL string | ||
} | ||
|
||
// alma is a driverkit target. | ||
type alma struct { | ||
} | ||
|
||
func (c *alma) Name() string { | ||
return TargetTypeAlma.String() | ||
} | ||
|
||
func (c *alma) TemplateScript() string { | ||
return almaTemplate | ||
} | ||
|
||
func (c *alma) URLs(_ Config, kr kernelrelease.KernelRelease) ([]string, error) { | ||
return fetchAlmaKernelURLS(kr), nil | ||
} | ||
|
||
func (c *alma) TemplateData(cfg Config, kr kernelrelease.KernelRelease, urls []string) interface{} { | ||
return almaTemplateData{ | ||
commonTemplateData: cfg.toTemplateData(c, kr), | ||
KernelDownloadURL: urls[0], | ||
} | ||
} | ||
|
||
func fetchAlmaKernelURLS(kr kernelrelease.KernelRelease) []string { | ||
almaReleases := []string{ | ||
"8", | ||
"8.6", | ||
"9", | ||
"9.0", | ||
} | ||
|
||
urls := []string{} | ||
for _, r := range almaReleases { | ||
if r >= "9" { | ||
urls = append(urls, fmt.Sprintf( | ||
"https://repo.almalinux.org/almalinux/%s/AppStream/%s/os/Packages/kernel-devel-%s%s.rpm", | ||
r, | ||
kr.Architecture.ToNonDeb(), | ||
kr.Fullversion, | ||
kr.FullExtraversion, | ||
)) | ||
}else{ | ||
urls = append(urls, fmt.Sprintf( | ||
"https://repo.almalinux.org/almalinux/%s/BaseOS/%s/os/Packages/kernel-devel-%s%s.rpm", | ||
r, | ||
kr.Architecture.ToNonDeb(), | ||
kr.Fullversion, | ||
kr.FullExtraversion, | ||
)) | ||
} | ||
} | ||
return urls | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
rm -Rf {{ .DriverBuildDir }} | ||
mkdir {{ .DriverBuildDir }} | ||
rm -Rf /tmp/module-download | ||
mkdir -p /tmp/module-download | ||
|
||
curl --silent -SL {{ .ModuleDownloadURL }} | tar -xzf - -C /tmp/module-download | ||
mv /tmp/module-download/*/driver/* {{ .DriverBuildDir }} | ||
|
||
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile | ||
bash /driverkit/fill-driver-config.sh {{ .DriverBuildDir }} | ||
|
||
# Fetch the kernel | ||
mkdir /tmp/kernel-download | ||
cd /tmp/kernel-download | ||
curl --silent -o kernel-devel.rpm -SL {{ .KernelDownloadURL }} | ||
rpm2cpio kernel-devel.rpm | cpio --extract --make-directories | ||
rm -Rf /tmp/kernel | ||
mkdir -p /tmp/kernel | ||
mv usr/src/kernels/*/* /tmp/kernel | ||
|
||
{{ if .BuildModule }} | ||
# Build the module | ||
cd {{ .DriverBuildDir }} | ||
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel | ||
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }} | ||
strip -g {{ .ModuleFullPath }} | ||
# Print results | ||
modinfo {{ .ModuleFullPath }} | ||
{{ end }} | ||
|
||
{{ if .BuildProbe }} | ||
# Build the eBPF probe | ||
cd {{ .DriverBuildDir }}/bpf | ||
make KERNELDIR=/tmp/kernel | ||
ls -l probe.o | ||
{{ end }} |