impl

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Copyright 2023 Chainguard, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

nolint:all

Index

Constants

View Source
const (
	DefaultKeyRingPath       = "/etc/apk/keys"
	DefaultSystemKeyRingPath = "/usr/share/apk/keys/"
)

Variables

This section is empty.

Functions

func ArchToAPK

func ArchToAPK(in string) string

func HashData

func HashData(data []byte) ([]byte, error)

func PackageToIndex

func PackageToIndex(pkg *repository.Package) (out []string)

PackageToIndex takes a Package and returns it as the string representation of lines in an index file.

func RSASignSHA1Digest

func RSASignSHA1Digest(sha1Digest []byte, keyFile, passphrase string) ([]byte, error)

RSASignSHA1Digest signs the provided SHA1 message digest. The key file must be in the PEM format and can either be encrypted or not.

func RSAVerifySHA1Digest

func RSAVerifySHA1Digest(sha1Digest, signature []byte, publicKey []byte) error

RSAVerifySHA1Digest is exported for use in tests and verifies a signature over the provided SHA1 hash of a message. The key file must be in the PEM format.

func ReadAndHashIndexFile

func ReadAndHashIndexFile(indexFile string) ([]byte, []byte, error)

func SignIndex

func SignIndex(logger *log.Logger, signingKey string, indexFile string) error

TODO: solidify this API and move into pkg/

Types

type APKImplementation

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

func NewAPKImplementation

func NewAPKImplementation(options ...Option) (*APKImplementation, error)

func (*APKImplementation) FixateWorld

func (a *APKImplementation) FixateWorld(cache, updateCache, executeScripts bool, sourceDateEpoch *time.Time) error

FixateWorld force apk's resolver to re-resolve the requested dependencies in /etc/apk/world.

func (*APKImplementation) GetInstalled

func (a *APKImplementation) GetInstalled() ([]*InstalledPackage, error)

getInstalledPackages get list of installed packages

func (*APKImplementation) GetRepositories

func (a *APKImplementation) GetRepositories() (repos []string, err error)

func (*APKImplementation) GetWorld

func (a *APKImplementation) GetWorld() ([]string, error)

getWorldPackages get list of packages that should be installed, according to /etc/apk/world

func (*APKImplementation) InitDB

func (a *APKImplementation) InitDB(versions ...string) error

Initialize the APK database for a given build context. Assumes base directories are in place and checks them. Returns the list of files and directories and files installed and permissions, unless those files will be included in the installed database, in which case they can be retrieved via GetInstalled().

func (*APKImplementation) InitKeyring

func (a *APKImplementation) InitKeyring(keyFiles, extraKeyFiles []string) (err error)

Installs the specified keys into the APK keyring inside the build context.

func (*APKImplementation) ListInitFiles

func (a *APKImplementation) ListInitFiles() []tar.Header

ListInitFiles list the files that are installed during the InitDB phase.

func (*APKImplementation) ResolveWorld

func (a *APKImplementation) ResolveWorld() (toInstall []*repository.RepositoryPackage, conflicts []string, err error)

ResolveWorld determine the target state for the requested dependencies in /etc/apk/world. Do not install anything.

func (*APKImplementation) SetClient

func (a *APKImplementation) SetClient(client *http.Client)

SetClient set the http client to use for downloading packages. In general, you can leave this unset, and it will use the default http.Client. It is useful for fine-grained control, for proxying, or for setting alternate paths.

func (*APKImplementation) SetRepositories

func (a *APKImplementation) SetRepositories(repos []string) error

SetRepositories sets the contents of /etc/apk/repositories file. The base directory of /etc/apk must already exist, i.e. this only works on an initialized APK database.

func (*APKImplementation) SetWorld

func (a *APKImplementation) SetWorld(packages []string) error

SetWorld sets the list of world packages intended to be installed. The base directory of /etc/apk must already exist, i.e. this only works on an initialized APK database.

type DateTime

type DateTime struct {
	time.Time
}

DateTime wrapper for time.Time because the date format is "YYYY-MM-DD"

func (DateTime) MarshalJSON

func (c DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) UnmarshalJSON

func (c *DateTime) UnmarshalJSON(b []byte) error

type Executor

type Executor interface {
	Execute(name string, arg ...string) error
}

Executor provider of interface to execute commands, if used. Will be used primarily to execute scripts.

type InstalledPackage

type InstalledPackage struct {
	repository.Package
	Files []*tar.Header
}

type Logger

type Logger interface {
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Debugf(string, ...interface{})
}

type NoKeysFoundError

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

func (*NoKeysFoundError) Error

func (e *NoKeysFoundError) Error() string

type Option

type Option func(*opts) error

func WithArch

func WithArch(arch string) Option

WithArch sets the architecture to use. If not provided, will use the default runtime.GOARCH.

func WithExecutor

func WithExecutor(executor Executor) Option

WithExecutor executor to use. Not currently used.

func WithFS

func WithFS(fs apkfs.FullFS) Option

WithFS sets the filesystem to use. If not provided, will use the OS filesystem based at root /.

func WithIgnoreMknodErrors

func WithIgnoreMknodErrors(ignore bool) Option

WithIgnoreMknodErrors sets whether to ignore errors when creating device nodes. Default is false.

func WithLogger

func WithLogger(logger Logger) Option

WithLogger logger to use. If not provided, will discard all log messages.

func WithVersion

func WithVersion(version string) Option

WithVersion sets the version to use for downloading keys and other purposes. If not provided, finds the latest stable.

type PkgResolver

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

PkgResolver is a helper struct for resolving packages from a list of indexes. If the indexes change, you should generate a new pkgResolver.

func NewPkgResolver

func NewPkgResolver(indexes []*namedRepositoryWithIndex) *PkgResolver

NewPkgResolver creates a new pkgResolver from a list of indexes.

func (*PkgResolver) GetPackageWithDependencies

func (p *PkgResolver) GetPackageWithDependencies(pkgName string, existing map[string]*repository.RepositoryPackage) (pkg *repository.RepositoryPackage, dependencies []*repository.RepositoryPackage, conflicts []string, err error)

GetPackageWithDependencies get all of the dependencies for a single package as well as looking up the package itself and resolving its version, based on the indexes. Requires the existing set because the logic for resolving dependencies between competing options may depend on whether or not one already is installed. Must not modify the existing map directly.

func (*PkgResolver) GetPackagesWithDependencies

func (p *PkgResolver) GetPackagesWithDependencies(packages []string) (toInstall []*repository.RepositoryPackage, conflicts []string, err error)

GetPackagesWithDependencies get all of the dependencies for the given packages based on the indexes. Does not filter for installed already or not.

type ReleaseBranch

type ReleaseBranch struct {
	Arches        []string              `json:"arches"`
	GitBranch     string                `json:"git_branch"`
	Keys          map[string][]RepoKeys `json:"keys"`
	ReleaseBranch string                `json:"rel_branch"`
	Repos         []Repo                `json:"repos"`
}

func (ReleaseBranch) KeysFor

func (r ReleaseBranch) KeysFor(arch string, date time.Time) []string

KeysFor returns the keys for the given architecture and date. The date is used to check for deprecation.

type Releases

type Releases struct {
	Architectures   []string        `json:"architectures"`
	LatestStable    string          `json:"latest_stable"`
	ReleaseBranches []ReleaseBranch `json:"release_branches"`
}

func (Releases) GetReleaseBranch

func (r Releases) GetReleaseBranch(version string) *ReleaseBranch

GetReleaseBranch returns the release branch for the given version. If not found, nil is returned.

type Repo

type Repo struct {
	Name string   `json:"name"`
	EOL  DateTime `json:"eol_date"`
}

type RepoKeys

type RepoKeys struct {
	URL        string   `json:"url"`
	Deprecated DateTime `json:"deprecated_since"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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