Documentation
¶
Overview ¶
Package packages builds native OS package formats from a built binary.
A .deb is an ar archive holding three members in a fixed order: debian-binary, control.tar.gz and data.tar.gz. Both the ar container and the tarballs inside it are in the Go standard library's reach, so this builds one directly rather than shelling out to dpkg-deb — which would restrict releases to Debian hosts and put a package manager in the build's dependency list.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDeb ¶
BuildDeb writes a Debian package for spec to outputPath and returns that path.
r := packages.BuildDeb(storage.Local, spec, "dist/core_0.12.3_amd64.deb")
if r.OK { path := r.Value.(string) }
func DebArchitecture ¶
DebArchitecture translates a GOARCH value into the Debian architecture name.
The two vocabularies agree on amd64 and arm64 and disagree on the rest, which is the sort of difference that silently produces a package apt refuses to install on the machine it was built for.
packages.DebArchitecture("386") // "i386"
func DebFileName ¶
DebFileName returns the conventional package file name.
packages.DebFileName("core", "v0.12.3", "amd64") // "core_0.12.3_amd64.deb"
func DebVersion ¶
DebVersion normalises a release tag into a Debian version.
Debian requires the version to start with a digit, so the "v" that every Go tag carries has to come off.
packages.DebVersion("v0.12.3") // "0.12.3"
Types ¶
type DebSpec ¶
type DebSpec struct {
// Name is the package name (e.g. "core").
Name string
// Version is the package version. A leading "v" is stripped, because
// Debian versions must begin with a digit.
Version string
// Architecture is a GOARCH value; it is translated to the Debian name.
Architecture string
// Maintainer is the "Name <email>" field. Required by policy.
Maintainer string
// Homepage is an optional project URL.
Homepage string
// Description is the one-line summary shown by apt search.
Description string
// LongDescription is the optional extended description.
LongDescription string
// Section defaults to "devel".
Section string
// Priority defaults to "optional".
Priority string
// Depends is an optional comma-separated dependency list. A static Go
// binary usually has none.
Depends string
// BinaryPath is the built binary to package.
BinaryPath string
// InstallPath is where the binary lands, defaulting to /usr/bin/<name>.
InstallPath string
}
DebSpec describes a Debian package to build.
spec := packages.DebSpec{Name: "core", Version: "0.12.3", Architecture: "amd64", BinaryPath: "dist/core"}