Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyPatch(path string, writer io.Writer) error
- func ApplyPatches(paths []string, writer io.Writer) ([]string, []string, error)
- func BuildKernelTarball(conf KernelVariantConfig, extraMakeArgs []string) (string, error)
- func CompilerToolchainInstalled(toolchainDir string) bool
- func CopyFileToGcpInstance(ctx context.Context, localPath string, remotePath string, gcloudArgs []string) error
- func DeployKernelToGcpInstance(ctx context.Context, path string, gcloudArgs []string) error
- func DeployKernelToLocalInstance(path string) error
- func FilesModifiedByPatch(path string) ([]string, error)
- func FindPatchBaseCommit(branch string) (string, error)
- func InstallCompilerToolchain(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error
- func InstallCompilerToolchainAtomic(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error
- func InstallKernelHeaders(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error
- func InstallKernelHeadersAtomic(ctx context.Context, downloader cos.ArtifactsDownloader, dstDir string) error
- func KernelHeadersInstalled(buildDir string) bool
- func Kmake(conf KernelVariantConfig, makeArgs []string) error
- func Menuconfig(conf KernelVariantConfig, makeArgs []string) error
- func PatchAppliesCleanly(path string, writer io.Writer) (bool, error)
- func Prepare(ctx context.Context, downloader cos.ArtifactsDownloader, ...) error
- func PrepareBranch(ctx context.Context, downloader cos.ArtifactsDownloader, ...) error
- func ReadPatchBase() (string, error)
- func UnapplyPatch(path string, writer io.Writer) error
- func UnapplyPatches(paths []string, writer io.Writer) error
- func UnlockGCPInstance(ctx context.Context, gcloudArgs []string) error
- func UnlockLocalInstance() error
- func UnpackCompilerToolchain(toolchainPath, dstDir string) error
- func UnpackKernelHeaders(headersPath, dstDir string) error
- type FakeDownloader
- func (*FakeDownloader) ArtifactExists(context.Context, string) (bool, error)
- func (*FakeDownloader) DownloadArtifact(context.Context, string, string) error
- func (*FakeDownloader) DownloadGenericNvidiaDriver(context.Context, string, string) (string, error)
- func (*FakeDownloader) DownloadKernelHeaders(ctx context.Context, destDir string) error
- func (*FakeDownloader) DownloadKernelSrc(ctx context.Context, destDir string) error
- func (*FakeDownloader) DownloadToolchain(ctx context.Context, destDir string) error
- func (*FakeDownloader) DownloadToolchainEnv(ctx context.Context, destDir string) error
- func (*FakeDownloader) GetArtifact(context.Context, string) ([]byte, error)
- func (*FakeDownloader) ListArtifacts(ctx context.Context, prefix string) ([]string, error)
- type KernelVariantConfig
Constants ¶
const ( AppliedPatchesFile = "cos-kernel-applied-patches.txt" PatchBaseFile = "cos-kernel-patch-base.txt" )
Variables ¶
var GcloudExecutable = "gcloud"
GcloudExecutable is the path to the gcloud binary used for commands.
Functions ¶
func ApplyPatch ¶
ApplyPatch applies a patch in the current directory.
This returns an error if the patch can't be read or does not apply cleanly. Logs the output of the patch command to the provided writer.
func ApplyPatches ¶
ApplyPatches applies a list of patches in the current directory.
For each patch, this first checks if the patch would apply cleanly. If not, then the patch is not applied, and the function exits.
The first return value is the list of patches which applied cleanly, and the second return value is the full list of paths modified by the applied patches. Both of these values are populated correctly even if this function returns an error. This is so that callers can commit or roll back changes to the affected files.
Returns an error immediately if any patch cannot be applied.
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 ¶
CompilerToolchainInstalled returns whether or not the toolchain has been installed in the target directory.
func CopyFileToGcpInstance ¶
func CopyFileToGcpInstance(ctx context.Context, localPath string, remotePath string, gcloudArgs []string) error
CopyFileToGcpInstance copies a file from a local path to a remote path on a GCP instance.
The copy is done via `gcloud compute ssh`.
The gcloudArgs args are passed directly to `gcloud compute ssh` in order to specify the instance the file should be copied to.
func DeployKernelToGcpInstance ¶
DeployKernelToGcpInstance replaces the kernel on a GCP instance with a kernel from a remote path on that instance.
The gcloudArgs args are passed directly to `gcloud compute ssh` in order to specify the instance where the kernel will be deployed.
func DeployKernelToLocalInstance ¶
DeployKernelToLocalInstance replaces the kernel on a local instance with the kernel at the provided path.
func FilesModifiedByPatch ¶
FilesModifiedByPatch returns the list of files that a patch would modify.
This returns an error if the patch can't be read or does not apply cleanly.
func FindPatchBaseCommit ¶
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 ¶
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 Menuconfig ¶
func Menuconfig(conf KernelVariantConfig, makeArgs []string) error
func PatchAppliesCleanly ¶
PatchAppliesCleanly checks whether or not a patch applies cleanly to the current directory.
This returns an error if the patch file can't be read. Any nonzero exit code of the patch command is interpreted as the patch not applying cleanly, but is not considered an error. Logs the output of the patch command to the provided writer.
func Prepare ¶
func Prepare(ctx context.Context, downloader cos.ArtifactsDownloader, cleanFailedPatches bool, 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, cleanFailedPatches bool, 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 ¶
ReadPatchBase reads the patch base file created by PrepareBranch.
func UnapplyPatch ¶
UnapplyPatch unapplies a patch in the current directory by applying it in reverse.
This returns an error if the patch can't be read or does not unapply cleanly. Logs the output of the patch command to the provided writer.
func UnapplyPatches ¶
UnapplyPatches unapplies a list of patches in the current directory.
Returns an error immediately if any patch fails to be unapplied.
func UnlockGCPInstance ¶
UnlockGCPInstance unlocks a GCP COS instance by running the cos-set-dev-mode script on it and rebooting.
The gcloudArgs args are passed directly to `gcloud compute ssh` in order to specify the instance that should be unlocked.
func UnlockLocalInstance ¶
func UnlockLocalInstance() error
UnlockGCPInstance unlocks the local COS instance by running the cos-set-dev-mode script on it and rebooting.
func UnpackCompilerToolchain ¶
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 ¶
UnpackKernelHeaders unpacks kernel headers to a target directory.
Types ¶
type FakeDownloader ¶
type FakeDownloader struct {
}
func (*FakeDownloader) ArtifactExists ¶
func (*FakeDownloader) DownloadArtifact ¶
func (*FakeDownloader) DownloadGenericNvidiaDriver ¶
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) ListArtifacts ¶
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.