Documentation ¶
Overview ¶
Package debpkg implements creation of (gpg signed) debian packages
Overview ¶
The most basic debian package is created as follows (without error checking):
deb := debpkg.New() deb.SetName("foobar") deb.SetVersion("1.2.3") deb.SetArchitecture("amd64") deb.SetMaintainer("Foo Bar") deb.SetMaintainerEmail("foo@bar.com") deb.SetHomepage("http://foobar.com") deb.SetShortDescription("Minimal foo bar package") deb.SetDescription("Foo bar package doesn't do anything") deb.AddFile("/tmp/foobar") deb.Write("foobar.deb") deb.Close()
Index ¶
- Constants
- Variables
- func ExpandVar(msg string) (string, error)
- func GetArchitecture() string
- func GetVar(v string) string
- func GetVarWithPrefix(v string) string
- func SetVar(key, val string)
- type DebPkg
- func (deb *DebPkg) AddControlExtra(name, filename string) error
- func (deb *DebPkg) AddControlExtraString(name, s string) error
- func (deb *DebPkg) AddDirectory(dir string) error
- func (deb *DebPkg) AddEmptyDirectory(dir string) error
- func (deb *DebPkg) AddFile(filename string, dest ...string) error
- func (deb *DebPkg) AddFileString(contents, dest string) error
- func (deb *DebPkg) Close() error
- func (deb *DebPkg) Config(filename string) error
- func (deb *DebPkg) GetFilename() string
- func (deb *DebPkg) MarkConfigFile(dest string) error
- func (deb *DebPkg) SetArchitecture(arch string)
- func (deb *DebPkg) SetBuiltUsing(info string)
- func (deb *DebPkg) SetConflicts(conflicts string)
- func (deb *DebPkg) SetDepends(depends string)
- func (deb *DebPkg) SetDescription(descr string)
- func (deb *DebPkg) SetHomepage(url string)
- func (deb *DebPkg) SetMaintainer(maintainer string)
- func (deb *DebPkg) SetMaintainerEmail(email string)
- func (deb *DebPkg) SetName(name string)
- func (deb *DebPkg) SetPriority(priority Priority)
- func (deb *DebPkg) SetProvides(provides string)
- func (deb *DebPkg) SetRecommends(recommends string)
- func (deb *DebPkg) SetReplaces(replaces string)
- func (deb *DebPkg) SetSection(section string)
- func (deb *DebPkg) SetShortDescription(descr string)
- func (deb *DebPkg) SetSuggests(suggests string)
- func (deb *DebPkg) SetVcsBrowser(url string)
- func (deb *DebPkg) SetVcsType(vcs VcsType)
- func (deb *DebPkg) SetVcsURL(url string)
- func (deb *DebPkg) SetVersion(version string)
- func (deb *DebPkg) SetVersionMajor(major uint)
- func (deb *DebPkg) SetVersionMinor(minor uint)
- func (deb *DebPkg) SetVersionPatch(patch uint)
- func (deb *DebPkg) Write(filename string) error
- func (deb *DebPkg) WriteSigned(filename string, entity *openpgp.Entity) error
- type Priority
- type VcsType
Examples ¶
Constants ¶
const ( DefaultInstallPrefix = "/usr" // Default install Prefix DefaultBinDir = "bin" // Default binary directory DefaultSbinDir = "sbin" // Default sbin directory DefaultSysConfDir = "etc" // Default configuration directory DefaultDataRootDir = "share" // Default data root directory )
Default installation variables
Variables ¶
var ErrClosed = errors.New("debpkg: Closed")
ErrClosed when the file I/O is requested and it is already closed
var ErrIO = errors.New("debpkg: I/O failed")
ErrIO is returned when any file I/O failed
Functions ¶
func GetArchitecture ¶
func GetArchitecture() string
GetArchitecture gets the current build.Default.GOARCH in debian-form
func GetVarWithPrefix ¶
GetVarWithPrefix gets a variable and appends INSTALLPREFIX when the value doesn't start with "/"
Types ¶
type DebPkg ¶
type DebPkg struct {
// contains filtered or unexported fields
}
DebPkg holds data for a single debian package
func New ¶
New creates new debian package, optionally provide an tempdir to write
intermediate files, otherwise os.TempDir is used. A provided tempdir must exist in order for it to work.
func (*DebPkg) AddControlExtra ¶
AddControlExtra allows the advanced user to add custom script to the control.tar.gz Typical usage is
for preinst, postinst, postrm, prerm: https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
And: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#maintscripts the files have possible DOS line-endings replaced by UNIX line-endings
func (*DebPkg) AddControlExtraString ¶
AddControlExtraString is the same as AddControlExtra except it uses a string input. the files have possible DOS line-endings replaced by UNIX line-endings
func (*DebPkg) AddDirectory ¶
AddDirectory adds a directory recursive to the package
func (*DebPkg) AddEmptyDirectory ¶
AddEmptyDirectory adds a empty directory to the package
func (*DebPkg) AddFileString ¶
AddFileString adds a file to the package with the provided content
func (*DebPkg) Close ¶
Close closes the File (and removes the intermediate files), rendering it unusable for I/O. It returns an error, if any.
func (*DebPkg) GetFilename ¶
GetFilename calculates the filename based on name, version and architecture SetName("foo") SetVersion("1.33.7") SetArchitecture("amd64") Generates filename "foo-1.33.7_amd64.deb"
func (*DebPkg) MarkConfigFile ¶
MarkConfigFile marks configuration files in the debian package
func (*DebPkg) SetArchitecture ¶
SetArchitecture sets the architecture of the package where it can be installed.
E.g "i386, amd64, arm, any, all". See `dpkg-architecture -L` for all supported.
Architecture: any
The generated binary package is an architecture dependent one usually in a compiled language.
Architecture: all
The generated binary package is an architecture independent one usually consisting of text, images, or scripts in an interpreted language.
See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Architecture And: http://man7.org/linux/man-pages/man1/dpkg-architecture.1.html
func (*DebPkg) SetBuiltUsing ¶
SetBuiltUsing incorporate parts of other packages when built but do not have to depend on those packages. A package using the source code from the gcc-4.6-source binary package built from the gcc-4.6 source package would have this field in its control file:
Built-Using: gcc-4.6 (= 4.6.0-11)
A package including binaries from grub2 and loadlin would have this field in its control file:
Built-Using: grub2 (= 1.99-9), loadlin (= 1.6e-1)
See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-built-using
func (*DebPkg) SetConflicts ¶
SetConflicts sets one or more conflicting packages. E.g: "nano" See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
func (*DebPkg) SetDepends ¶
SetDepends sets the package dependencies. E.g: "lsb-release" See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
func (*DebPkg) SetDescription ¶
SetDescription sets the extended description over several lines. E.g: "This tool will calculation the most efficient way to world domination" NOTE: The debian control file has a special formatting of the long description
this function replaces newlines with a newline and a space.
func (*DebPkg) SetHomepage ¶
SetHomepage sets the homepage URL of the package. E.g: "https://github.com/foo/bar"
func (*DebPkg) SetMaintainer ¶
SetMaintainer (mandatory), sets the package maintainers name and surname. E.g: "Foo Bar" See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Maintainer
func (*DebPkg) SetMaintainerEmail ¶
SetMaintainerEmail sets the package maintainers email address. E.g: "foo@bar.com" See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Maintainer
func (*DebPkg) SetName ¶
SetName sets the name of the binary package (mandatory) See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Package
func (*DebPkg) SetPriority ¶
SetPriority (recommended). Default set to debpkg.PriorityUnset See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Priority And: https://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities
func (*DebPkg) SetProvides ¶
SetProvides sets the type which the package provides. E.g: "editor" See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-virtual
func (*DebPkg) SetRecommends ¶
SetRecommends sets the package recommendations. E.g: "aptitude" See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
func (*DebPkg) SetReplaces ¶
SetReplaces sets the names of packages which will be replaced. E.g: "pico" See: https://www.debian.org/doc/debian-policy/ch-relationships.html
func (*DebPkg) SetSection ¶
SetSection (recommended). E.g: editors See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Section And: https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections
func (*DebPkg) SetShortDescription ¶
SetShortDescription sets the single line synopsis. E.g: "My awesome foo bar baz tool"
func (*DebPkg) SetSuggests ¶
SetSuggests sets the package suggestions. E.g: "aptitude" See: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps
func (*DebPkg) SetVcsBrowser ¶
SetVcsBrowser sets the version control system (Vcs) browsable source-tree URL for the source package. See: https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html#s6.2.5.2
func (*DebPkg) SetVcsType ¶
SetVcsType sets the version control system (Vcs) type for the source package. See: https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html#s6.2.5.2
func (*DebPkg) SetVcsURL ¶
SetVcsURL sets the version control system (Vcs) URL for the source package. See: https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.html#s6.2.5.2
func (*DebPkg) SetVersion ¶
SetVersion sets the full version string (mandatory), or use SetVersion* functions for "major.minor.patch" The upstream_version may contain only alphanumerics ( A-Za-z0-9 ) and the characters . + - : ~
(full stop, plus, hyphen, colon, tilde) and should start with a digit.
NOTE: When the full string is set the other SetVersion* function calls are ignored See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
func (*DebPkg) SetVersionMajor ¶
SetVersionMajor sets the version major number See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
func (*DebPkg) SetVersionMinor ¶
SetVersionMinor sets the version minor number See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
func (*DebPkg) SetVersionPatch ¶
SetVersionPatch sets the version patch level See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
func (*DebPkg) Write ¶
Write the debian package to the filename
Example ¶
ExampleDebPkgWrite demonstrates generating a simple package
tempfile := os.TempDir() + "/foobar.deb" deb := New() defer deb.Close() deb.SetName("foobar") deb.SetVersion("1.2.3") deb.SetArchitecture("amd64") deb.SetMaintainer("Foo Bar") deb.SetMaintainerEmail("foo@bar.com") deb.SetHomepage("http://foobar.com") deb.SetShortDescription("Minimal foo bar package") deb.SetDescription("Foo bar package doesn't do anything") deb.AddFile("debpkg.go") fmt.Println(deb.Write(tempfile)) // Do something with tempfile other than removing it...
Output:
type Priority ¶
type Priority string
Priority for Debian package
const ( PriorityUnset Priority = "" // Priority field is skipped PriorityRequired Priority = "required" // Packages which are necessary for the proper functioning of the system PriorityImportant Priority = "important" // Important programs, including those which one would expect to find on any Unix-like system PriorityStandard Priority = "standard" // These packages provide a reasonably small but not too limited character-mode system PriorityOptional Priority = "optional" // This is all the software that you might reasonably want to install if you didn't know what it was and don't have specialized requirements )
Package Priority
type VcsType ¶
type VcsType string
VcsType for Debian package supported version control system (Vcs) types
const ( VcsTypeUnset VcsType = "" // VcsType field is skipped VcsTypeArch VcsType = "Arch" // Arch VcsTypeBazaar VcsType = "Bzr" // Bazaar VcsTypeDarcs VcsType = "Darcs" // Darcs VcsTypeGit VcsType = "Git" // Git VcsTypeMercurial VcsType = "Hg" // Mercurial VcsTypeMonotone VcsType = "Mtn" // Monotone VcsTypeSubversion VcsType = "Svn" // Subversion )
Package VcsType