Skip to content

Commit

Permalink
add special opensuse paths
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Oct 10, 2024
1 parent 714a9ff commit 7f8a9f1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/util/kernel/find_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const kernelModulesPath = "/lib/modules/%s/build"
const debKernelModulesPath = "/lib/modules/%s/source"
const cosKernelModulesPath = "/usr/src/linux-headers-%s"
const centosKernelModulesPath = "/usr/src/kernels/%s"
const opensuseKernelDevelPath = "/usr/src/linux-%s"
const opensuseKernelFlavorDevelPath = "/usr/src/linux-%s-obj"

var versionCodeRegexp = regexp.MustCompile(`^#define[\t ]+LINUX_VERSION_CODE[\t ]+(\d+)$`)

Expand Down Expand Up @@ -366,12 +368,25 @@ func getDefaultHeaderDirs() []string {
return []string{}
}

return []string{
paths := []string{
fmt.Sprintf(kernelModulesPath, hi),
fmt.Sprintf(debKernelModulesPath, hi),
fmt.Sprintf(cosKernelModulesPath, hi),
fmt.Sprintf(centosKernelModulesPath, hi),
}

// opensuse special case
flavourIndex := strings.LastIndex(hi, "-")
if flavourIndex != -1 {
opensuseKernelRelease := hi[:flavourIndex]
paths = append(
paths,
fmt.Sprintf(opensuseKernelDevelPath, opensuseKernelRelease),
fmt.Sprintf(opensuseKernelFlavorDevelPath, opensuseKernelRelease),
)
}

return paths
}

func getDownloadedHeaderDirs(headerDownloadDir string) []string {
Expand Down

0 comments on commit 7f8a9f1

Please sign in to comment.