Documentation ¶
Overview ¶
Package cos provides functionality to read and configure system configs that are specific to COS images.
Index ¶
- Constants
- func AddCCWrapperToPath(toolchainDir, workDir, cc string) error
- func CheckKernelModuleSigning(kernelCmdline string) bool
- func ConfigureModuleSymvers(kernelHeaderDir, kernelSrcDir string) error
- func ForceSymlinkLinker(symlinkPath string) error
- func InstallCrossToolchain(ctx context.Context, downloader ArtifactsDownloader, destDir string) error
- func InstallKernelSrcPkg(ctx context.Context, downloader ArtifactsDownloader, destDir string) error
- func PackageInfoExists() bool
- func SetCompilationEnv(ctx context.Context, downloader ArtifactsDownloader) error
- type ArtifactsDownloader
- type EnvReader
- func (c *EnvReader) Board() string
- func (c *EnvReader) BuildNumber() string
- func (c *EnvReader) KernelCommit() string
- func (c *EnvReader) KernelRelease() string
- func (c *EnvReader) Milestone() string
- func (c *EnvReader) OsRelease() map[string]string
- func (c *EnvReader) ReleaseTrack() string
- func (c *EnvReader) ToolchainPath() string
- type ExtensionsDownloader
- type GCSDownloader
- func (d *GCSDownloader) ArtifactExists(ctx context.Context, artifactPath string) (bool, error)
- func (d *GCSDownloader) DownloadArtifact(ctx context.Context, destDir, artifactPath string) error
- func (d *GCSDownloader) DownloadArtifactFromURL(ctx context.Context, url string, destinationPath string) error
- func (d *GCSDownloader) DownloadExtensionArtifact(ctx context.Context, destDir, extension, artifact string) error
- func (d *GCSDownloader) DownloadKernelHeaders(ctx context.Context, destDir string) error
- func (d *GCSDownloader) DownloadKernelSrc(ctx context.Context, destDir string) error
- func (d *GCSDownloader) DownloadToolchain(ctx context.Context, destDir string) error
- func (d *GCSDownloader) DownloadToolchainEnv(ctx context.Context, destDir string) error
- func (d *GCSDownloader) GetArtifact(ctx context.Context, artifactPath string) ([]byte, error)
- func (d *GCSDownloader) GetExtensionArtifact(ctx context.Context, extension, artifact string) ([]byte, error)
- func (d *GCSDownloader) GetGCSClient(ctx context.Context) (*storage.Client, error)
- func (d *GCSDownloader) ListArtifacts(ctx context.Context, prefix string) ([]string, error)
- func (d *GCSDownloader) ListExtensionArtifacts(extension string) ([]string, error)
- func (d *GCSDownloader) ListExtensions() ([]string, error)
- func (d *GCSDownloader) ListGPUExtensionArtifacts() ([]string, error)
- type Package
- type PackageInfo
Constants ¶
const (
// GPUExtension is the name of GPU extension.
GPUExtension = "gpu"
)
Variables ¶
This section is empty.
Functions ¶
func AddCCWrapperToPath ¶
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 ¶
CheckKernelModuleSigning checks whether kernel module signing related options present.
func ConfigureModuleSymvers ¶
ConfigureModuleSymvers copys Module.symvers file from kernel header dir to kernel source dir.
func ForceSymlinkLinker ¶
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(dctx context.Context, estDir string) error DownloadArtifact(ctx context.Context, destDir, artifact 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 ¶
NewEnvReader returns an instance of EnvReader.
func (*EnvReader) BuildNumber ¶
BuildNumber returns COS build number.
func (*EnvReader) KernelCommit ¶
KernelCommit returns commit hash of the COS kernel.
func (*EnvReader) KernelRelease ¶
KernelRelease return COS kernel release, i.e. `uname -r`
func (*EnvReader) ReleaseTrack ¶
ReleaseTrack returns the COS release track.
func (*EnvReader) ToolchainPath ¶
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 string) *GCSDownloader
NewGCSDownloader creates a GCSDownloader instance.
func (*GCSDownloader) ArtifactExists ¶
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) 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 ¶
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 (*GCSDownloader) ListArtifacts ¶
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.