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 HashData(data []byte) ([]byte, error)
- 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 InstalledPackage
- type Logger
- 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)
- 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 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 InstalledPackage ¶
type InstalledPackage struct { repository.Package Files []*tar.Header }
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 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 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.