install

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package install builds and runs install plans for the packages hamstack manages.

Index

Constants

View Source
const (
	Hamlib  = "hamlib"
	Pat     = "pat"
	Mercury = "mercury"
	Data2G  = "data2g"
)

Names of what can be installed.

View Source
const Direwolf = "direwolf"

Direwolf is the package name of the VHF/UHF packet soundcard TNC.

View Source
const GPSD = "gpsd"

GPSD is gpsd's name for install.

Variables

This section is empty.

Functions

func Confirm

func Confirm(in io.Reader, out io.Writer, question string, def bool) bool

Confirm asks a yes/no question. An empty answer returns def.

func DirewolfSourceNotice

func DirewolfSourceNotice(e Env, version string) string

DirewolfSourceNotice is the disclaimer shown before a source build.

func Download

func Download(ctx context.Context, url, dest, wantSHA256 string) error

Download fetches url into dest. If wantSHA256 is non-empty the download is rejected unless its SHA-256 matches. The file is only moved into place once it is verified.

func ExtractAll

func ExtractAll(archive, dir string) (string, error)

ExtractAll unpacks a .tar.gz into dir (which must exist). Entries that would land outside dir, links, and special files are skipped. It returns the name of the single top-level directory if the archive has one.

func ExtractFile

func ExtractFile(archive, name, dest string) error

ExtractFile pulls the single regular file whose base name is name out of a .tar.gz and writes it to dest with mode 0755. Archive paths are never used to build the output path, and macOS "._" metadata entries are ignored.

func ExtractTree added in v0.2.0

func ExtractTree(archive, dir string) (string, error)

ExtractTree unpacks a .tar.gz into dir (which must exist), like ExtractAll, but it also keeps symbolic links, which a folder of shared libraries is full of. A link is kept only if its target is relative and stays inside dir, and nothing is ever written through a link, so the archive cannot reach outside dir. Special files are skipped. It returns the name of the single top-level folder if the archive has one.

func GPSDNotice

func GPSDNotice(e Env) string

GPSDNotice explains what installing gpsd does to the rest of the system. On Debian and Ubuntu the package also starts a system-wide gpsd and a udev rule that hands every GPS receiver you plug in to it, and that gpsd then holds the receiver, so hamstack's own gpsd cannot open it.

func HamlibSourceNotice

func HamlibSourceNotice(e Env, version string) string

HamlibSourceNotice is the disclaimer shown before a source build.

func InstallStaged

func InstallStaged(stage, prefix string) (int, error)

InstallStaged copies a staged install (a tree that holds files at their absolute install paths, as DESTDIR makes) under prefix. A file staged under prefix keeps its place; one staged under /usr/local or /usr (a fixed path the project ignored the prefix for) moves to the same place under prefix; anything else is skipped, so nothing can land outside prefix. Only regular files and symbolic links are copied (never a device or a pipe), without set-uid or set-gid bits. It returns how many files were copied.

func MercurySourceNotice

func MercurySourceNotice(e Env, version string) string

MercurySourceNotice is the disclaimer shown before Mercury is built.

func Run

func Run(steps []Step, o Options) error

Run shows the steps, asks for confirmation (unless Yes or DryRun), then runs them in order.

func SourceNotice

func SourceNotice(e Env, pkg catalog.Package, version, url string) string

SourceNotice is the disclaimer shown before a source build of a catalog program.

Types

type Env

type Env struct {
	Distro distro.Info
	Home   string // user's home; binaries go to Home/.local
	Root   bool   // running as root (no sudo needed)
	Sudo   bool   // sudo is available
	Arch   string // runtime.GOARCH
	Jobs   int    // parallel make jobs
}

Env is what the plans need to know about the host.

func HostEnv

func HostEnv() Env

HostEnv describes the running system.

func (Env) PkgSteps added in v0.2.0

func (e Env) PkgSteps(desc string, pkgs ...string) ([]Step, error)

PkgSteps returns the steps that install distribution packages (refreshing the package lists first where the package manager needs it).

func (Env) Priv

func (e Env) Priv(cmd ...string) ([]string, error)

Priv returns cmd prefixed with sudo when hamstack is not root.

type ErrAUR

type ErrAUR struct{ Pkgs []string }

ErrAUR is returned for packages that exist only in the Arch User Repository. hamstack does not run AUR helpers or build AUR packages on its own: they are community-maintained and run arbitrary build scripts.

func (ErrAUR) Error

func (e ErrAUR) Error() string

type Options

type Options struct {
	Notice string // shown before the plan, for disclaimers
	DryRun bool
	Yes    bool      // do not ask for confirmation
	In     io.Reader // confirmation input; os.Stdin if nil
	Out    io.Writer // os.Stdout if nil
}

Options controls Run.

type Step

type Step struct {
	Desc string
	Cmd  []string     // command to run (with sudo already prefixed if needed)
	Do   func() error // alternative to Cmd
	Dir  string       // working directory for Cmd; "" for the current one
	Env  []string     // extra environment for Cmd
	// Cleanup, if set, runs once every step is done or one has failed, provided this step was started:
	// a download step removes its temporary build folder here, so a failed build leaves nothing behind.
	Cleanup func()
}

Step is one action in an install plan: either a command to run, or a Go function.

func AX25ToolsPlan

func AX25ToolsPlan(e Env) ([]Step, error)

AX25ToolsPlan installs the classic AX.25 tools: kissattach and friends (ax25-tools) and axcall and axlisten (ax25-apps).

func AppPlan

func AppPlan(ctx context.Context, e Env, pkg catalog.Package, latest string, fromSource bool) (steps []Step, notice string, err error)

AppPlan installs a catalog program that has no plan of its own (the fl suite, WSJT-X, JS8Call, Xastir...): the distribution's package when there is one, otherwise a build from the upstream source into ~/.local. fromSource forces the build, for the newest release when the distribution's package lags upstream. latest is the newest upstream version ("" when it could not be looked up, which a source build cannot do without). The notice is the disclaimer for a source build, or "" for a package.

func Data2GPlan added in v0.2.0

func Data2GPlan(ctx context.Context, e Env) ([]Step, error)

Data2GPlan downloads the upstream Data2G release, verifies its checksum and installs it. The release is a self-contained folder (the programs, their own Qt and Hamlib libraries, and a launcher script), so it goes to ~/.local/share/data2g whole, and the launcher is linked into ~/.local/bin as "data2g". The launcher finds its libraries from where it really is, so the link is enough. "data2g host" and "data2g web" run the other front ends; with no argument it opens the GUI.

func DirewolfPlan

func DirewolfPlan(ctx context.Context, e Env, fromSource bool) (steps []Step, notice string, err error)

DirewolfPlan installs Direwolf. Debian and Fedora have a package, which is used unless fromSource is set (it can lag upstream: Debian 13 ships 1.7 against 1.8.1). Arch has no package, so it is built from source into ~/.local. The notice is the disclaimer for a source build, or "" for a package.

func GPSDPlan

func GPSDPlan(e Env) ([]Step, error)

GPSDPlan installs gpsd from the distribution's package manager. gpsd is not built from source: the distribution packages are recent enough, and it is a daemon that needs its udev rules and users.

func GroupStep

func GroupStep(e Env, group, username, why string) (Step, error)

GroupStep adds username to a group (for example uucp or dialout, which own USB serial ports).

func HamlibPlan

func HamlibPlan(e Env) ([]Step, error)

HamlibPlan installs hamlib, which provides rigctld.

func HamlibSourcePlan

func HamlibSourcePlan(ctx context.Context, e Env) ([]Step, string, error)

HamlibSourcePlan builds the latest hamlib release from source into ~/.local. ctx is only used for looking up the release while building the plan.

func MercuryPlan

func MercuryPlan(ctx context.Context, e Env, latest string) ([]Step, error)

MercuryPlan installs build dependencies, then builds the latest tagged Mercury into ~/.local.

func PatPlan

func PatPlan(ctx context.Context, e Env) ([]Step, error)

PatPlan downloads the upstream Pat release, verifies its checksum and installs it to ~/.local/bin.

func RootFileStep

func RootFileStep(e Env, desc, path, content string) (Step, error)

RootFileStep writes content to path as root, keeping a copy of any existing file as path.hamstack-bak. The content is shown in the plan exactly as it will be written.

func (Step) Display

func (s Step) Display() string

Display is the one-line form shown to the user.

Jump to

Keyboard shortcuts

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