hermit

package module
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

README

Hermit

Hermit - uniform tooling for Linux and Mac

CI Slack chat Go Report Card

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 (

	// ScriptSHAs contains the default known valid SHA256 sums for bin/activate-hermit and bin/hermit.
	ScriptSHAs = tidySha256Db(sha256Db)

	// InstallerTemplateSource is a string containing the installer template
	//go:embed "files/install.sh.tmpl"
	InstallerTemplateSource string

	// 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 := system.UserCacheDir()
		if err != nil {
			panic(fmt.Sprintf("could not find user cache dir: %s", 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 FindEnvDir added in v0.26.0

func FindEnvDir(binary string) (envDir string, err error)

FindEnvDir finds the highest priority active Hermit environment

func Init

func Init(l *ui.UI, env string, distURL string, stateDir string, config Config, installScriptSHA string) 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."`
	InheritParent bool          `` /* 152-byte string literal not displayed */
	AddIJPlugin   bool          `hcl:"idea,optional" default:"false" help:"Whether Hermit should automatically add the IntelliJ IDEA plugin."`
}

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,
	packageSource cache.PackageSourceSelector,
	ephemeral envars.Envars,
	httpClient *http.Client,
	scriptSums []string,
) (*Env, error)

OpenEnv opens a Hermit environment.

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

"scriptSums" contains all known SHA256 checksums for "bin/hermit" and "bin/activate-hermit" scripts.

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) 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.

This function is much faster than ListInstalled, if all you need is the Reference.

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.Reference, 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) 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 for all installed packages.

func (*Env) TriggerForPackage added in v0.2.27

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

TriggerForPackage triggers an event for a single package.

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) Update added in v0.16.0

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

Update sources and auto-update channels.

Will be updated at most every SyncFrequency unless "force" is true.

A Sources set can only be synchronised once. Following calls will not have any effect.

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, *manifest.Package, error)

Upgrade package.

If an upgrade does not occur, returns all nils.

func (*Env) ValidateManifest added in v0.2.21

func (e *Env) ValidateManifest(l *ui.UI, name string, options *ValidationOptions) ([]string, error)

ValidateManifest with given name.

Returns the resolution errors for core systems as warnings. If a version fails to resolve for all systems, returns an error.

func (*Env) ValidateManifests

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

ValidateManifests from all sources.

func (*Env) Verify added in v0.12.0

func (e *Env) Verify() error

Verify contains valid Hermit scripts.

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

type ValidationOptions added in v0.2.25

type ValidationOptions struct {
	// CheckSources if true, check that the package sources are reachable
	CheckSources bool
}

ValidationOptions for manifest validation

Directories

Path Synopsis
Package archive extracts archives with a progress bar.
Package archive extracts archives with a progress bar.
cmd
gendocs
nolint
nolint
Package github implements a client for GitHub that includes the minimum set of functions required by Hermit.
Package github implements a client for GitHub that includes the minimum set of functions required by Hermit.
internal
dao
Package ui provides the terminal UI formatter for Hermit.
Package ui provides the terminal UI formatter for Hermit.

Jump to

Keyboard shortcuts

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