Skip to content

Commit

Permalink
adjust archlinux support to require user to pass kernel type in the k…
Browse files Browse the repository at this point in the history
…ernelrelease

Signed-off-by: Logan Bond <lbond@secureworks.com>
  • Loading branch information
EXONER4TED authored and poiana committed Nov 2, 2022
1 parent 47b7457 commit eea9992
Showing 1 changed file with 83 additions and 49 deletions.
132 changes: 83 additions & 49 deletions pkg/driverbuilder/builder/archlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,59 +36,93 @@ func (c *archlinux) TemplateScript() string {
}

func (c *archlinux) URLs(cfg Config, kr kernelrelease.KernelRelease) ([]string, error) {

urls := []string{}
possibleCompressionSuffixes := []string{
"xz",
"zst",
}

if kr.Architecture == kernelrelease.ArchitectureAmd64 {
// Archlinux officially support 4 kernel versions: stable, lts, hardened and zen
// see: https://wiki.archlinux.org/title/Kernel#Officially_supported_kernels
var archKernelVersion string
var customVersion string
var baseurl string
switch {
case strings.Contains(kr.Extraversion, "-lts"):
archKernelVersion = "-lts"
customVersion = strings.ReplaceAll(kr.Extraversion, archKernelVersion, "")
baseurl = fmt.Sprintf("https://archive.archlinux.org/packages/l/linux%s-headers/linux%s-headers-%s-%s-%s.pkg.tar",
archKernelVersion,
archKernelVersion,
kr.Fullversion,
customVersion,
kr.Architecture.ToNonDeb())
case strings.Contains(kr.Extraversion, "-hardened"):
archKernelVersion = "-hardened"
customVersion = strings.ReplaceAll(kr.Extraversion, archKernelVersion, "")
baseurl = fmt.Sprintf("https://archive.archlinux.org/packages/l/linux%s-headers/linux%s-headers-%s.%s-%s.pkg.tar",
archKernelVersion,
archKernelVersion,
kr.Fullversion,
customVersion,
kr.Architecture.ToNonDeb())
case strings.Contains(kr.Extraversion, "-zen"):
archKernelVersion = "-zen"
customVersion = strings.ReplaceAll(kr.Extraversion, archKernelVersion, "")
baseurl = fmt.Sprintf("https://archive.archlinux.org/packages/l/linux%s-headers/linux%s-headers-%s.%s-%s.pkg.tar",
archKernelVersion,
archKernelVersion,
kr.Fullversion,
customVersion,
kr.Architecture.ToNonDeb())
default:
baseurl = fmt.Sprintf("https://archive.archlinux.org/packages/l/linux-headers/linux-headers-%s.%s-%s.pkg.tar",
kr.Fullversion,
kr.Extraversion,
kr.Architecture.ToNonDeb())
// check the architecture, which limits the mirror options
if kr.Architecture.ToNonDeb() == "x86_64" {
if strings.Contains(kr.FullExtraversion, "arch") { // arch stable kernel
baseURL := "https://archive.archlinux.org/packages/l/linux-headers"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-headers-%s%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
)
}
} else if strings.Contains(kr.FullExtraversion, "hardened") || strings.Contains(kr.FullExtraversion, ".a-1") { // arch hardened kernel ("a-1" is old naming standard)
baseURL := "https://archive.archlinux.org/packages/l/linux-hardened-headers"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-hardened-headers-%s%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
)
}
} else if strings.Contains(kr.FullExtraversion, "zen") { // arch zen kernel
baseURL := "https://archive.archlinux.org/packages/l/linux-zen-headers"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-zen-headers-%s%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
)
}
} else { // arch LTS kernel
baseURL := "https://archive.archlinux.org/packages/l/linux-lts-headers"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-lts-headers-%s%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
)
}
}
} else if kr.Architecture.ToNonDeb() == "aarch64" {
baseURL := "http://tardis.tiny-vps.com/aarm/packages/l/linux-aarch64-headers/"
for _, compressionAlgo := range possibleCompressionSuffixes {
urls = append(
urls,
fmt.Sprintf(
"%s/linux-aarch64-headers-%s%s-%s.pkg.tar.%s",
baseURL,
kr.Fullversion,
kr.FullExtraversion,
kr.Architecture.ToNonDeb(),
compressionAlgo,
),
)
}
urls = append(urls, fmt.Sprintf("%s%s", baseurl, ".xz"))
urls = append(urls, fmt.Sprintf("%s%s", baseurl, ".zst"))
} else {
urls = append(urls, fmt.Sprintf(
"http://tardis.tiny-vps.com/aarm/packages/l/linux-%s-headers/linux-%s-headers-%s-%s-%s.pkg.tar.xz",
kr.Architecture.ToNonDeb(),
kr.Architecture.ToNonDeb(),
kr.Fullversion,
cfg.KernelVersion,
kr.Architecture.ToNonDeb()))
}

return urls, nil
}

Expand Down

0 comments on commit eea9992

Please sign in to comment.