kernel

package
v0.0.0-...-a1bdd4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppliedPatchesFile = "cos-kernel-applied-patches.txt"
	PatchBaseFile      = "cos-kernel-patch-base.txt"
)

Variables

This section is empty.

Functions

func BuildKernelTarball

func BuildKernelTarball(conf KernelVariantConfig, extraMakeArgs []string) (string, error)

BuildKernelTarball compiles the kernel and modules in the current directory and packages them into a tarball suitable for use with cos-kernel-deploy.

This will also strip debug symbols from the modules.

func CompilerToolchainInstalled

func CompilerToolchainInstalled(toolchainDir string) bool

CompilerToolchainInstalled returns whether or not the toolchain has been installed in the target directory.

func FindPatchBaseCommit

func FindPatchBaseCommit(branch string) (string, error)

FindPatchBaseCommit finds the hash of the base commit for a branch created by PrepareBranch(..., branch).

func InstallCompilerToolchain

func InstallCompilerToolchain(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error

InstallCompilerToolchain installs the COS compiler toolchain in a target directory.

Once the toolchain has been installed, the toolchain tarball is removed to save space, and a toolchain-installed.txt file is created. If the installation fails for any reason, toolchain-installed.txt file will not be written, so it can be used as a reliable indicator that the installation succeeded.

func InstallCompilerToolchainAtomic

func InstallCompilerToolchainAtomic(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error

Installs the compiler toolchain atomically if it is not already installed. This function checks for a file which is only installed after an installation succeeds, meaning it will retry any partial installations.

func InstallKernelHeaders

func InstallKernelHeaders(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error

InstallKernelHeaders installs the COS kernel headers in a target directory.

Once the headers have been installed, the header tarball is removed to save space, and a kernel-headers-installed.txt file is created. If the installation fails for any reason, the kernel-headers-installed.txt file will not be written, so it can be used as a reliable indicator that the installation succeeded.

func InstallKernelHeadersAtomic

func InstallKernelHeadersAtomic(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error

Installs the kernel headers atomically if they are not already installed. This function checks for a file which is only installed after an installation succeeds, meaning it will retry any partial installations.

func KernelHeadersInstalled

func KernelHeadersInstalled(buildDir string) bool

KernelHeadersInstalled returns whether or not the kernel headers have been installed in the target directory.

func Kmake

func Kmake(conf KernelVariantConfig, makeArgs []string) error

Kmake will run the make command from the provided makeArgs using the default make arguments corresponding to the provided kernel variant config.

If an argument is passed in makeArgs, it will take precedence over the corresponding default arg.

func Prepare

func Prepare(ctx context.Context, downloader cos.ArtifactsDownloader, conf KernelVariantConfig) error

Prepare sets up the local kernel directory for compilation.

This will first download the compiler toolchain corresponding to the provided kernel variant config, apply any patches from the variant config which are not yet applied, and prepare the .config file using the base kernel config and fragments from the variant config.

func PrepareBranch

func PrepareBranch(ctx context.Context, downloader cos.ArtifactsDownloader, conf KernelVariantConfig, branch string) error

PrepareBranch switches to a new branch and sets up the local kernel directory for compilation.

See `Prepare` for details on how the branch will be prepared.

The new branch will be marked with a `cos-kernel-branch-start.txt` file, which contains the name of the branch. This can be used as a reference when creating patches from the new branch.

func ReadPatchBase

func ReadPatchBase() (string, error)

ReadPatchBase reads the patch base file created by PrepareBranch.

func UnpackCompilerToolchain

func UnpackCompilerToolchain(toolchainPath, dstDir string) error

UnpackCompilerToolchain unpacks a compiler toolchain to a target directory. This omits the rust toolchain components since they are unused by COS and use a significant amount of space.

func UnpackKernelHeaders

func UnpackKernelHeaders(headersPath, dstDir string) error

UnpackKernelHeaders unpacks kernel headers to a target directory.

Types

type FakeDownloader

type FakeDownloader struct {
}

func (*FakeDownloader) ArtifactExists

func (*FakeDownloader) ArtifactExists(context.Context, string) (bool, error)

func (*FakeDownloader) DownloadArtifact

func (*FakeDownloader) DownloadArtifact(context.Context, string, string) error

func (*FakeDownloader) DownloadGenericNvidiaDriver

func (*FakeDownloader) DownloadGenericNvidiaDriver(context.Context, string, string) (string, error)

func (*FakeDownloader) DownloadKernelHeaders

func (*FakeDownloader) DownloadKernelHeaders(ctx context.Context, destDir string) error

func (*FakeDownloader) DownloadKernelSrc

func (*FakeDownloader) DownloadKernelSrc(ctx context.Context, destDir string) error

func (*FakeDownloader) DownloadToolchain

func (*FakeDownloader) DownloadToolchain(ctx context.Context, destDir string) error

func (*FakeDownloader) DownloadToolchainEnv

func (*FakeDownloader) DownloadToolchainEnv(ctx context.Context, destDir string) error

func (*FakeDownloader) GetArtifact

func (*FakeDownloader) GetArtifact(context.Context, string) ([]byte, error)

func (*FakeDownloader) ListArtifacts

func (*FakeDownloader) ListArtifacts(ctx context.Context, prefix string) ([]string, error)

type KernelVariantConfig

type KernelVariantConfig struct {
	Build         string
	Board         string
	Arch          string
	Toolchain     string
	ToolchainArch string
	Configs       []string
	Patches       []string
}

A KernelVariantConfig is a configuration representing a COS kernel variant.

The Build must be given as a build number, e.g., 19804.0.0. If unspecified, the ToolchainArch is the same as the Arch.

func ReadConfig

func ReadConfig(path string) (KernelVariantConfig, error)

ReadConfig reads a KernelVariantConfig from a .json file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL