cos

package
v0.0.0-...-0f4c505 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Package cos provides functionality to read and configure system configs that are specific to COS images.

Index

Constants

View Source
const (
	// GPUExtension is the name of GPU extension.
	GPUExtension = "gpu"
)

Variables

This section is empty.

Functions

func AddCCWrapperToPath

func AddCCWrapperToPath(toolchainDir, workDir, cc string) error

Creates a CC wrapper and adds it to the env PATH. Newer versions of LLVM have different -Wstrict-prototypes behavior that impacts the nvidia installer. The kernel always uses -Werror=strict-prototypes by default. This wrapper removes -Werror=strict-prototypes from the CC command line.

func CheckKernelModuleSigning

func CheckKernelModuleSigning(kernelCmdline string) bool

CheckKernelModuleSigning checks whether kernel module signing related options present.

func ConfigureModuleSymvers

func ConfigureModuleSymvers(kernelHeaderDir, kernelSrcDir string) error

ConfigureModuleSymvers copys Module.symvers file from kernel header dir to kernel source dir.

func ForceSymlinkLinker

func ForceSymlinkLinker(symlinkPath string) error

func InstallCrossToolchain

func InstallCrossToolchain(ctx context.Context, downloader ArtifactsDownloader, destDir string) error

InstallCrossToolchain installs COS toolchain and kernel headers to destination directory.

func InstallKernelSrcPkg

func InstallKernelSrcPkg(ctx context.Context, downloader ArtifactsDownloader, destDir string) error

InstallKernelSrcPkg installs COS kernel source package to destination directory.

func PackageInfoExists

func PackageInfoExists() bool

PackageInfoExists returns whether COS package information exists on the local OS.

func SetCompilationEnv

func SetCompilationEnv(ctx context.Context, downloader ArtifactsDownloader) error

SetCompilationEnv sets compilation environment variables (e.g. CC, CXX) for third-party kernel module compilation. TODO(mikewu): pass environment variables to the *exec.Cmd that runs the installer.

Types

type ArtifactsDownloader

type ArtifactsDownloader interface {
	DownloadKernelSrc(ctx context.Context, destDir string) error
	DownloadToolchainEnv(ctx context.Context, destDir string) error
	DownloadToolchain(ctx context.Context, destDir string) error
	DownloadKernelHeaders(ctx context.Context, destDir string) error
	DownloadArtifact(ctx context.Context, destDir, artifact string) error
	DownloadGenericNvidiaDriver(ctx context.Context, destDir, driverVersion string) (string, error)
	GetArtifact(ctx context.Context, artifact string) ([]byte, error)
	ArtifactExists(ctx context.Context, artifact string) (bool, error)
	ListArtifacts(ctx context.Context, prefix string) ([]string, error)
}

ArtifactsDownloader defines the interface to download COS artifacts.

type EnvReader

type EnvReader struct {
	// contains filtered or unexported fields
}

EnvReader is to read system configurations of COS. TODO(mikewu): rename EnvReader to a better name.

func NewEnvReader

func NewEnvReader(hostRootPath string) (reader *EnvReader, err error)

NewEnvReader returns an instance of EnvReader.

func (*EnvReader) Architecture

func (c *EnvReader) Architecture() string

Architecture - i.e. `uname -m`

func (*EnvReader) Board

func (c *EnvReader) Board() string

Board returns the COS board name. Retrieved from /etc/lsb-release.

func (*EnvReader) BuildNumber

func (c *EnvReader) BuildNumber() string

BuildNumber returns COS build number.

func (*EnvReader) KernelCommit

func (c *EnvReader) KernelCommit() string

KernelCommit returns commit hash of the COS kernel.

func (*EnvReader) KernelRelease

func (c *EnvReader) KernelRelease() string

KernelRelease return COS kernel release, i.e. `uname -r`

func (*EnvReader) Milestone

func (c *EnvReader) Milestone() string

Milestone returns COS milestone.

func (*EnvReader) OsRelease

func (c *EnvReader) OsRelease() map[string]string

OsRelease returns configs of /etc/os-release as a map.

func (*EnvReader) ReleaseTrack

func (c *EnvReader) ReleaseTrack() string

ReleaseTrack returns the COS release track.

func (*EnvReader) ToolchainPath

func (c *EnvReader) ToolchainPath() string

ToolchainPath returns the toolchain path of the COS version. It may return an empty string if the COS version doesn't support the feature.

type ExtensionsDownloader

type ExtensionsDownloader interface {
	ListExtensions() ([]string, error)
	ListExtensionArtifacts(extension string) ([]string, error)
	DownloadExtensionArtifact(ctx context.Context, destDir, extension, artifact string) error
	GetExtensionArtifact(ctx context.Context, extension, artifact string) ([]byte, error)
}

ExtensionsDownloader is the struct downloading COS extensions from GCS bucket.

type GCSDownloader

type GCSDownloader struct {
	// contains filtered or unexported fields
}

GCSDownloader is the struct downloading COS artifacts from GCS bucket.

func NewGCSDownloader

func NewGCSDownloader(gcsClient *storage.Client, e *EnvReader, bucket, prefix, nvidiaBucket, nvidiaPrefix string) *GCSDownloader

NewGCSDownloader creates a GCSDownloader instance.

func (*GCSDownloader) ArtifactExists

func (d *GCSDownloader) ArtifactExists(ctx context.Context, artifactPath string) (bool, error)

ArtifactExists check whether the artifactpath exists.

func (*GCSDownloader) DownloadArtifact

func (d *GCSDownloader) DownloadArtifact(ctx context.Context, destDir, artifactPath string) error

DownloadArtifact downloads an artifact from the GCS prefix configured in GCSDownloader.

func (*GCSDownloader) DownloadArtifactFromURL

func (d *GCSDownloader) DownloadArtifactFromURL(ctx context.Context, url string, destinationPath string) error

DownloadArtifactFromURL will download the artifact from url and save it to the destinationPath.

func (*GCSDownloader) DownloadExtensionArtifact

func (d *GCSDownloader) DownloadExtensionArtifact(ctx context.Context, destDir, extension, artifact string) error

DownloadExtensionArtifact downloads an artifact of the given extension.

func (*GCSDownloader) DownloadGenericNvidiaDriver

func (d *GCSDownloader) DownloadGenericNvidiaDriver(ctx context.Context, destDir, driverVersion string) (string, error)

DownloadNvidiaArtifact downloads a NVIDIA drivers from the NVIDIA GCS bucket and prefix configured in GCSDownloader.

func (*GCSDownloader) DownloadKernelHeaders

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

DownloadKernelHeaders downloads COS kernel headers to destination directory.

func (*GCSDownloader) DownloadKernelSrc

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

DownloadKernelSrc downloads COS kernel sources to destination directory.

func (*GCSDownloader) DownloadToolchain

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

DownloadToolchain downloads toolchain package to destination directory.

func (*GCSDownloader) DownloadToolchainEnv

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

DownloadToolchainEnv downloads toolchain compilation environment variables to destination directory.

func (*GCSDownloader) GetArtifact

func (d *GCSDownloader) GetArtifact(ctx context.Context, artifactPath string) ([]byte, error)

GetArtifact gets an artifact from GCS buckets and returns its content.

func (*GCSDownloader) GetExtensionArtifact

func (d *GCSDownloader) GetExtensionArtifact(ctx context.Context, extension, artifact string) ([]byte, error)

GetExtensionArtifact reads the content of an artifact of the given extension.

func (*GCSDownloader) GetGCSClient

func (d *GCSDownloader) GetGCSClient(ctx context.Context) (*storage.Client, error)

func (*GCSDownloader) ListArtifacts

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

ListArtifacts: this function lists the artifacts with `gcsDownloadPrefix/prefix` prefix.

func (*GCSDownloader) ListExtensionArtifacts

func (d *GCSDownloader) ListExtensionArtifacts(extension string) ([]string, error)

ListExtensionArtifacts lists all artifacts of a given extension.

func (*GCSDownloader) ListExtensions

func (d *GCSDownloader) ListExtensions() ([]string, error)

ListExtensions lists all supported extensions.

func (*GCSDownloader) ListGPUExtensionArtifacts

func (d *GCSDownloader) ListGPUExtensionArtifacts() ([]string, error)

ListGPUExtensionArtifacts lists all artifacts of GPU extension.

type Package

type Package struct {
	Category      string `json:"category"`
	Name          string `json:"name"`
	Version       string `json:"version"`
	EbuildVersion string `json:"ebuild_version"`
}

Package represents a COS package. For example, this schema is used in the cos-package-info.json file.

type PackageInfo

type PackageInfo struct {
	InstalledPackages []Package `json:"installedPackages"`
	BuildTimePackages []Package `json:"buildTimePackages"`
}

PackageInfo contains information about the packages of a COS instance. For example, this schema is used in the cos-package-info.json file.

func GetPackageInfo

func GetPackageInfo() (PackageInfo, error)

GetPackageInfo loads the package information from the local OS and returns it.

func GetPackageInfoFromFile

func GetPackageInfoFromFile(filename string) (PackageInfo, error)

GetPackageInfoFromFile loads the package information from the specified file on the local OS and returns it.

Jump to

Keyboard shortcuts

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