Documentation
¶
Overview ¶
Package install builds and runs install plans for the packages hamstack manages.
Index ¶
- Constants
- func Confirm(in io.Reader, out io.Writer, question string, def bool) bool
- func DirewolfSourceNotice(e Env, version string) string
- func Download(ctx context.Context, url, dest, wantSHA256 string) error
- func ExtractAll(archive, dir string) (string, error)
- func ExtractFile(archive, name, dest string) error
- func GPSDNotice(e Env) string
- func HamlibSourceNotice(e Env, version string) string
- func InstallStaged(stage, prefix string) (int, error)
- func MercurySourceNotice(e Env, version string) string
- func Run(steps []Step, o Options) error
- func SourceNotice(e Env, pkg catalog.Package, version, url string) string
- type Env
- type ErrAUR
- type Options
- type Step
- func AX25ToolsPlan(e Env) ([]Step, error)
- func AppPlan(ctx context.Context, e Env, pkg catalog.Package, latest string, ...) (steps []Step, notice string, err error)
- func DirewolfPlan(ctx context.Context, e Env, fromSource bool) (steps []Step, notice string, err error)
- func GPSDPlan(e Env) ([]Step, error)
- func GroupStep(e Env, group, username, why string) (Step, error)
- func HamlibPlan(e Env) ([]Step, error)
- func HamlibSourcePlan(ctx context.Context, e Env) ([]Step, string, error)
- func MercuryPlan(ctx context.Context, e Env, latest string) ([]Step, error)
- func PatPlan(ctx context.Context, e Env) ([]Step, error)
- func RootFileStep(e Env, desc, path, content string) (Step, error)
Constants ¶
const ( Hamlib = "hamlib" Pat = "pat" Mercury = "mercury" )
Names of what can be installed.
const Direwolf = "direwolf"
Direwolf is the package name of the VHF/UHF packet soundcard TNC.
const GPSD = "gpsd"
GPSD is gpsd's name for install.
Variables ¶
This section is empty.
Functions ¶
func DirewolfSourceNotice ¶
DirewolfSourceNotice is the disclaimer shown before a source build.
func Download ¶
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 ¶
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 ¶
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 GPSDNotice ¶
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 ¶
HamlibSourceNotice is the disclaimer shown before a source build.
func InstallStaged ¶
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 ¶
MercurySourceNotice is the disclaimer shown before Mercury is built.
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.
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.
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 ¶
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 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 ¶
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 ¶
GroupStep adds username to a group (for example uucp or dialout, which own USB serial ports).
func HamlibPlan ¶
HamlibPlan installs hamlib, which provides rigctld.
func HamlibSourcePlan ¶
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 ¶
MercuryPlan installs build dependencies, then builds the latest tagged Mercury into ~/.local.
func PatPlan ¶
PatPlan downloads the upstream Pat release, verifies its checksum and installs it to ~/.local/bin.
func RootFileStep ¶
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.