Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: fix(pkg/driverbuilder): fixed bpf probe build for new libs. #283

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/driverbuilder/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ func (b *Build) ClientForRegistry(registry string) *auth.Client {

return client
}

func (b *Build) BuildModule() bool {
return len(b.ModuleFilePath) > 0
}

func (b *Build) BuildProbe() bool {
return len(b.ProbeFilePath) > 0
}
4 changes: 2 additions & 2 deletions pkg/driverbuilder/builder/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
ModuleDownloadURL: fmt.Sprintf("%s/%s.tar.gz", c.DownloadBaseURL, c.DriverVersion),
ModuleDriverName: c.DriverName,
ModuleFullPath: ModuleFullPath,
BuildModule: len(c.ModuleFilePath) > 0,
BuildProbe: len(c.ProbeFilePath) > 0,
BuildModule: c.BuildModule(),
BuildProbe: c.BuildProbe(),
GCCVersion: c.GCCVersion,
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/alinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/almalinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
5 changes: 3 additions & 2 deletions pkg/driverbuilder/builder/templates/amazonlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -26,8 +25,8 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the kernel module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}

make KERNELDIR=/tmp/kernel CC=/usr/bin/gcc-{{ .GCCVersion }} LD=/usr/bin/ld.bfd CROSS_COMPILE=""
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
# Print results
Expand All @@ -36,7 +35,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/archlinux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/lib/modules/*/build/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -31,6 +30,7 @@ sourcedir=$(find . -type d -name "{{ .KernelHeadersPattern }}" | head -n 1 | xar

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -41,7 +41,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=$sourcedir
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/flatcar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -30,6 +29,7 @@ make KCONFIG_CONFIG=/tmp/kernel.config modules_prepare

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -40,7 +40,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/opensuse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -26,6 +25,7 @@ sourcedir="$(find . -type d -name "linux-*-obj" | head -n 1 | xargs readlink -f)

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=$sourcedir
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -36,7 +36,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
8 changes: 4 additions & 4 deletions pkg/driverbuilder/builder/templates/photonos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -22,20 +21,21 @@ mkdir -p /tmp/kernel
mv usr/src/linux-headers-*/* /tmp/kernel

{{ if .BuildModule }}

# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
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 }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/redhat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -25,6 +24,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -35,7 +35,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
4 changes: 3 additions & 1 deletion pkg/driverbuilder/builder/templates/rocky.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
Expand All @@ -23,6 +22,7 @@ mv usr/src/kernels/*/* /tmp/kernel

{{ if .BuildModule }}
# Build the module
cp /driverkit/module-Makefile {{ .DriverBuildDir }}/Makefile
cd {{ .DriverBuildDir }}
make CC=/usr/bin/gcc-{{ .GCCVersion }} KERNELDIR=/tmp/kernel
mv {{ .ModuleDriverName }}.ko {{ .ModuleFullPath }}
Expand All @@ -33,7 +33,9 @@ modinfo {{ .ModuleFullPath }}

{{ if .BuildProbe }}
# Build the eBPF probe
cp /driverkit/bpf-Makefile {{ .DriverBuildDir }}/bpf/Makefile
cd {{ .DriverBuildDir }}/bpf
ln -s ../*{.c,.h} .
make KERNELDIR=/tmp/kernel
ls -l probe.o
{{ end }}
Loading