hermit

package module
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

README

Hermit

Hermit - uniform tooling for Linux and Mac CI

Hermit installs tools for software projects in self-contained, isolated sets, so your team, your contributors, and your CI have the same consistent tooling.

See https://cashapp.github.io/hermit for full documentation.

hermit intro screen cast


Copyright 2021 Square, 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// UserStateDir should be passed to Open()/Init() in most cases.
	UserStateDir = func() string {

		explicit := os.Getenv("HERMIT_STATE_DIR")
		if explicit != "" {
			return explicit
		}

		cache, err := os.UserCacheDir()
		if err != nil {
			panic(err)
		}
		return filepath.Join(cache, "hermit")
	}()
)

Reset environment variables.

Functions

func EnvDirFromProxyLink(executable string) (string, error)

EnvDirFromProxyLink finds a Hermit environment given a proxy symlink.

func Init

func Init(l *ui.UI, env string, distURL string, stateDir string, config Config) error

Init a new Env.

Types

type CleanMask

type CleanMask int

CleanMask is a bitmask specifying which parts of a hermit system to clean.

const (
	CleanBin       CleanMask = 1 << iota            // bin
	CleanPackages                                   // packages
	CleanCache                                      // cache
	CleanAll       CleanMask = ^0                   // all
	CleanTransient           = CleanAll &^ CleanBin // transient
)

Bitmask for what to clean.

func (CleanMask) String

func (i CleanMask) String() string

type Config

type Config struct {
	Envars    envars.Envars `hcl:"env,optional" help:"Extra environment variables."`
	Sources   []string      `hcl:"sources,optional" help:"Package manifest sources."`
	ManageGit bool          `hcl:"manage-git,optional" default:"true" help:"Whether Hermit should automatically 'git add' new packages."`
}

Config for a Hermit environment.

type Env

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

Env is a Hermit environment.

func OpenEnv

func OpenEnv(envDir string, state *state.State, ephemeral envars.Envars) (*Env, error)

OpenEnv opens a Hermit environment.

The environment may not exist, in which case this will succeed but subsequent operations will fail.

func (*Env) AddSource

func (e *Env) AddSource(l *ui.UI, s sources.Source) error

AddSource adds a new source bundle and refreshes the packages from it

func (*Env) BinDir

func (e *Env) BinDir() string

BinDir returns the directory for the binaries of this environment

func (*Env) Clean

func (e *Env) Clean(l *ui.UI, level CleanMask) error

Clean parts of the hermit system.

func (*Env) DelEnv

func (e *Env) DelEnv(key string) error

DelEnv deletes a custom environment variable.

func (*Env) EnsureChannelIsUpToDate

func (e *Env) EnsureChannelIsUpToDate(l *ui.UI, pkg *manifest.Package) error

EnsureChannelIsUpToDate updates the package if it has an update interval, the required time since the last update check has passed, and the etag in the source has changed from the last check.

This should only be called for packages that have already been installed

func (*Env) EnvDir

func (e *Env) EnvDir() string

EnvDir returns the directory where this environment is rooted

func (*Env) EnvOps

func (e *Env) EnvOps(l *ui.UI) (envars.Ops, error)

EnvOps returns the envar mutation operations for this environment.

PATH, HERMIT_BIN and HERMIT_ENV will always be explicitly set, plus all environment variables defined in the packages installed in the environment, and finally any environment variables explicitly configured in the environment.

func (*Env) Envars

func (e *Env) Envars(l *ui.UI, inherit bool) ([]string, error)

Envars returns the fully expanded envars for this environment.

PATH, HERMIT_BIN and HERMIT_ENV will always be explicitly set, plus all environment variables defined in the packages installed in the environment, and finally any environment variables explicitly configured in the environment.

If "inherit" is true, variables from the shell environment will be inherited. Otherwise only variables defined in Hermit itself will be available.

func (*Env) Exec

func (e *Env) Exec(l *ui.UI, pkg *manifest.Package, binary string, args []string, deps map[string]*manifest.Package) error

Exec the specified binary from the given package, replacing this process.

"args" should be os.Args (or equivalent), including the binary name. "deps" contains all packages that need to be in the system for the execution. The missing dependencies are downloaded and unpacked.

func (*Env) GC

func (e *Env) GC(l *ui.UI, age time.Duration) error

GC can be used to clean up unused packages, and clear the download cache.

func (*Env) Install

func (e *Env) Install(l *ui.UI, pkg *manifest.Package) (*shell.Changes, error)

Install package. If a package with same name exists, uninstall it first.

func (*Env) LinkedBinaries

func (e *Env) LinkedBinaries(pkg *manifest.Package) (binaries []string, err error)

LinkedBinaries lists just the binaries installed in the environment.

func (*Env) ListInstalled

func (e *Env) ListInstalled(l *ui.UI) ([]*manifest.Package, error)

ListInstalled packages from this environment.

func (*Env) ListInstalledReferences

func (e *Env) ListInstalledReferences() ([]manifest.Reference, error)

ListInstalledReferences from this environment.

func (*Env) Resolve

func (e *Env) Resolve(l *ui.UI, selector manifest.Selector, syncOnMissing bool) (*manifest.Package, error)

Resolve package reference.

If "syncOnMissing" is true, sources will be synced if the selector cannot be initially resolved, then resolve attempted again.

func (e *Env) ResolveLink(l *ui.UI, executable string) (pkg *manifest.Package, binary string, err error)

ResolveLink returns the package for a hermit bin dir link.

Link chains are in the form

<binary> -> <pkg>-<version>.pkg -> hermit

func (*Env) ResolveVirtual

func (e *Env) ResolveVirtual(l *ui.UI, name string) ([]*manifest.Package, error)

ResolveVirtual references to concrete packages.

func (*Env) ResolveWithDeps

func (e *Env) ResolveWithDeps(l *ui.UI, installed manifest.Packages, selector manifest.Selector, out map[string]*manifest.Package) (err error)

ResolveWithDeps collect packages and their dependencies based on the given manifest.Selector into a map

func (*Env) Root

func (e *Env) Root() string

Root directory of the environment.

func (*Env) Search

func (e *Env) Search(l *ui.UI, pattern string) (manifest.Packages, error)

Search for packages using the given regular expression.

func (*Env) SetEnv

func (e *Env) SetEnv(key, value string) error

SetEnv sets an extra environment variable.

func (*Env) Sources

func (e *Env) Sources(l *ui.UI) ([]string, error)

Sources enabled in this environment.

func (*Env) Sync

func (e *Env) Sync(l *ui.UI, force bool) error

Sync sources.

func (*Env) Test

func (e *Env) Test(l *ui.UI, pkg *manifest.Package) error

Test the sanity of a package using the configured test shell fragment.

func (*Env) Trigger

func (e *Env) Trigger(l *ui.UI, event manifest.Event) (messages []string, err error)

Trigger an event.

func (*Env) Uninstall

func (e *Env) Uninstall(l *ui.UI, pkg *manifest.Package) (*shell.Changes, error)

Uninstall uninstalls a single package.

func (*Env) Unpack

func (e *Env) Unpack(l *ui.Task, p *manifest.Package) error

Unpack but do not install package.

func (*Env) UpdateUsage

func (e *Env) UpdateUsage(pkg *manifest.Package) error

UpdateUsage updates the package usage time stamps in the underlying database. if the package was not previously present, it is inserted to the DB.

func (*Env) Upgrade

func (e *Env) Upgrade(l *ui.UI, pkg *manifest.Package) (*shell.Changes, error)

Upgrade package.

func (*Env) ValidateManifests

func (e *Env) ValidateManifests(l *ui.UI) (manifest.ManifestErrors, error)

ValidateManifests from all sources.

type InstalledPackagePredictor added in v0.2.3

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

InstalledPackagePredictor is a shell completion predictor for installed package names

func NewInstalledPackagePredictor added in v0.2.3

func NewInstalledPackagePredictor(e *Env, l *ui.UI) *InstalledPackagePredictor

NewInstalledPackagePredictor returns a new InstalledPackagePredictor

func (*InstalledPackagePredictor) Predict added in v0.2.3

func (p *InstalledPackagePredictor) Predict(args complete.Args) []string

type PackagePredictor added in v0.2.3

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

PackagePredictor is a shell completion predictor for all package names

func NewPackagePredictor added in v0.2.3

func NewPackagePredictor(s *state.State, e *Env, l *ui.UI) *PackagePredictor

NewPackagePredictor returns a new PackagePredictor

func (*PackagePredictor) Predict added in v0.2.3

func (p *PackagePredictor) Predict(args complete.Args) []string

Directories

Path Synopsis
Package archive extracts archives with a progress bar.
Package archive extracts archives with a progress bar.
cmd
gendocs
nolint
nolint
internal
dao
Package ui provides the terminal UI formatter for Hermit.
Package ui provides the terminal UI formatter for Hermit.
Package xpath is an XPath parser supporting the minimal subset of XPath used by Hermit.
Package xpath is an XPath parser supporting the minimal subset of XPath used by Hermit.

Jump to

Keyboard shortcuts

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