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
- func ArchToAPK(in string) string
- func GetRepositoryIndexes(repos []string, keys map[string][]byte, arch string, options ...IndexOption) (indexes []*namedRepositoryWithIndex, err error)
- func HashData(data []byte) ([]byte, error)
- func NewNamedRepositoryWithIndex(name string, repo *repository.RepositoryWithIndex) *namedRepositoryWithIndex
- func PackageToIndex(pkg *repository.Package) (out []string)
- func RSASignSHA1Digest(sha1Digest []byte, keyFile, passphrase string) ([]byte, error)
- func RSAVerifySHA1Digest(sha1Digest, signature []byte, publicKey []byte) error
- func ReadAndHashIndexFile(indexFile string) ([]byte, []byte, error)
- func SignIndex(logger *log.Logger, signingKey string, indexFile string) error
- type APKImplementation
- func (a *APKImplementation) FixateWorld(cache, updateCache, executeScripts bool, sourceDateEpoch *time.Time) error
- func (a *APKImplementation) GetInstalled() ([]*InstalledPackage, error)
- func (a *APKImplementation) GetRepositories() (repos []string, err error)
- func (a *APKImplementation) GetWorld() ([]string, error)
- func (a *APKImplementation) InitDB(versions ...string) error
- func (a *APKImplementation) InitKeyring(keyFiles, extraKeyFiles []string) (err error)
- func (a *APKImplementation) ListInitFiles() []tar.Header
- func (a *APKImplementation) ResolveWorld() (toInstall []*repository.RepositoryPackage, conflicts []string, err error)
- func (a *APKImplementation) SetClient(client *http.Client)
- func (a *APKImplementation) SetRepositories(repos []string) error
- func (a *APKImplementation) SetWorld(packages []string) error
- type DateTime
- type Executor
- type FileExistsError
- type IndexOption
- type InstalledPackage
- type Logger
- type NamedIndex
- type NoKeysFoundError
- type Option
- type PkgResolver
- func (p *PkgResolver) GetPackageWithDependencies(pkgName string, existing map[string]*repository.RepositoryPackage) (pkg *repository.RepositoryPackage, ...)
- func (p *PkgResolver) GetPackagesWithDependencies(packages []string) (toInstall []*repository.RepositoryPackage, conflicts []string, err error)
- func (p *PkgResolver) ResolvePackage(pkgName string) (pkgs []*repository.RepositoryPackage, err error)
- type ReleaseBranch
- type Releases
- type Repo
- type RepoKeys
Constants ¶
const ( DefaultKeyRingPath = "/etc/apk/keys" DefaultSystemKeyRingPath = "/usr/share/apk/keys/" )
Variables ¶
This section is empty.
Functions ¶
func GetRepositoryIndexes ¶ added in v0.8.0
func GetRepositoryIndexes(repos []string, keys map[string][]byte, arch string, options ...IndexOption) (indexes []*namedRepositoryWithIndex, err error)
GetRepositoryIndexes returns the indexes for the named repositories, keys and archs. The signatures for each index are verified unless ignoreSignatures is set to true. The key-value pairs in the map for `keys` are the name of the key and the contents of the key. The name is just indicative. If it finds a match, it will use it. Else, it will try all keys.
func NewNamedRepositoryWithIndex ¶ added in v0.8.0
func NewNamedRepositoryWithIndex(name string, repo *repository.RepositoryWithIndex) *namedRepositoryWithIndex
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 ¶
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 ¶
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.
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 ¶
DateTime wrapper for time.Time because the date format is "YYYY-MM-DD"
func (DateTime) MarshalJSON ¶
func (*DateTime) UnmarshalJSON ¶
type Executor ¶
Executor provider of interface to execute commands, if used. Will be used primarily to execute scripts.
type FileExistsError ¶ added in v0.8.0
func (FileExistsError) Error ¶ added in v0.8.0
func (f FileExistsError) Error() string
func (FileExistsError) Is ¶ added in v0.8.0
func (f FileExistsError) Is(target error) bool
type IndexOption ¶ added in v0.8.0
type IndexOption func(*indexOpts)
func WithHTTPClient ¶ added in v0.8.0
func WithHTTPClient(c *http.Client) IndexOption
func WithIgnoreSignatures ¶ added in v0.8.0
func WithIgnoreSignatures(ignoreSignatures bool) IndexOption
type InstalledPackage ¶
type InstalledPackage struct { repository.Package Files []*tar.Header }
type NamedIndex ¶ added in v0.8.0
type NamedIndex interface { Name() string Packages() []*repository.RepositoryPackage Source() string }
NamedIndex an index that contains all of its packages, as well as having an optional name and source. The name and source need not be unique.
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 ¶
WithArch sets the architecture to use. If not provided, will use the default runtime.GOARCH.
func WithExecutor ¶
WithExecutor executor to use. Not currently used.
func WithFS ¶
WithFS sets the filesystem to use. If not provided, will use the OS filesystem based at root /.
func WithIgnoreMknodErrors ¶
WithIgnoreMknodErrors sets whether to ignore errors when creating device nodes. Default is false.
func WithLogger ¶
WithLogger logger to use. If not provided, will discard all log messages.
func WithVersion ¶
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 resolves packages from a list of indexes. It is created with NewPkgResolver and passed a list of indexes. It then can be used to resolve the correct version of a package given version constraints, if any, as well as all the package and all of the required upstream dependencies. If provided multiple indexes, it will look for dependencies in all of the indexes. If you need to look only in a certain set, you should create a new PkgResolver with only those indexes. If the indexes change, you should generate a new pkgResolver.
func NewPkgResolver ¶
func NewPkgResolver(indexes []NamedIndex) *PkgResolver
NewPkgResolver creates a new pkgResolver from a list of indexes. The indexes are anything that implements NamedIndex.
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.
func (*PkgResolver) ResolvePackage ¶ added in v0.8.0
func (p *PkgResolver) ResolvePackage(pkgName string) (pkgs []*repository.RepositoryPackage, err error)
ResolvePackage given a single package name and optional version constraints, resolve to a list of packages that satisfy the constraint. The list will be sorted by version number, with the highest version first and decreasing from there. In general, the first one in the list is the best match. This function returns multiple in case you need to see all potential matches.
type ReleaseBranch ¶
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.