Documentation
¶
Overview ¶
This module provides an API to access and programmatically process Debian `.deb` archives on disk.
Debian files, at a high level, are `ar(1)` archives, which contain a few sections, most notably the `control` member, which contains information about the Debian package itself, and the `data` member, which contains the actual contents of the files, as they should be written out on disk.
Here's a trivial example, which will print out the Package name for a `.deb` archive given on the command line:
package main
import (
"log"
"os"
"github.com/egibs/go-debian/deb"
)
func main() {
path := os.Args[1]
fd, err := os.Open(path)
if err != nil {
panic(err)
}
defer fd.Close()
debFile, err := deb.Load(fd, path)
if err != nil {
panic(err)
}
log.Printf("Package: %s\n", debFile.Control.Package)
}
Index ¶
Constants ¶
const ( SigTypeArchive = `archive` SigTypeMaint = `maint` SigTypeOrigin = `origin` )
Variables ¶
This section is empty.
Functions ¶
func SetXZMaxDict ¶ added in v0.19.0
func SetXZMaxDict(_ uint32)
SetXZMaxDict updates the maximum dictionary size parameter for XZ decompressing. If zero is supplied, the default max dictionary size will be used.
Types ¶
type Ar ¶
type Ar struct {
// contains filtered or unexported fields
}
This struct encapsulates a Debian .deb flavored `ar(1)` archive.
type ArEntry ¶
type ArEntry struct {
Name string
Timestamp int64
OwnerID int64
GroupID int64
FileMode string
Size int64
Data *io.SectionReader
}
Container type to access the different parts of a Debian `ar(1)` Archive.
The most interesting parts of this are the `Name` attribute, Data `io.Reader`, and the Tarfile helpers. This will allow the developer to programmatically inspect the information inside without forcing her to unpack the .deb to the filesystem.
func (*ArEntry) IsTarfile ¶
Check to see if the given ArEntry is, in fact, a Tarfile. This method will return `true` for files that have `.tar.*` or `.tar` suffix.
This will return `false` for the `debian-binary` file. If this method returns `true`, the `.Tarfile()` method will be around to give you a tar.Reader back.
type Control ¶
type Control struct {
control.Paragraph
Package string `required:"true"`
Source string
Version version.Version `required:"true"`
Architecture dependency.Arch `required:"true"`
Maintainer string
InstalledSize int `control:"Installed-Size"`
MultiArch string `control:"Multi-Arch"`
Depends dependency.Dependency
Recommends dependency.Dependency
Suggests dependency.Dependency
Breaks dependency.Dependency
Replaces dependency.Dependency
BuiltUsing dependency.Dependency `control:"Built-Using"`
Section string
Priority string
Homepage string
Description string
}
Binary Control format, as exists in the Control section of the `.deb` archive, as defined in Debian Policy, section 5.3, entitled "Binary package control files -- DEBIAN/control".
func (Control) SourceName ¶
type Deb ¶
type Deb struct {
Control Control
Path string
Data *tar.Reader
Closer io.Closer
ControlExt string
DataExt string
ArContent map[string]*ArEntry
}
Container struct to encapsulate a `.deb` file on disk. This contains information about what exactly we're looking at. When loaded. information regarding the Control file is read from the control section of the .deb, and Unmarshaled into the `Control` member of the Struct.
func Load ¶
Given a reader, and the file path to the file (for use in the Deb later) create a deb.Deb object, and populate the Control and Data members. It is the caller's responsibility to call Close() when done.
func (*Deb) CheckDebsig ¶
type DecompressorFunc ¶
type DecompressorFunc func(io.Reader) (io.ReadCloser, error)
func DecompressorFor ¶
func DecompressorFor(ext string) DecompressorFunc
DecompressorFn returns a decompressing reader for the specified reader and its corresponding file extension ext.