deb

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: BSD-3-Clause, MIT Imports: 18 Imported by: 16

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"

	"pault.ag/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

View Source
const (
	SigTypeArchive = `archive`
	SigTypeMaint   = `maint`
	SigTypeOrigin  = `origin`
)

Variables

This section is empty.

Functions

func LoadFile

func LoadFile(path string) (*Deb, Closer, error)

Types

type Ar

type Ar struct {
	// contains filtered or unexported fields
}

This struct encapsulates a Debian .deb flavored `ar(1)` archive.

func LoadAr

func LoadAr(in io.ReaderAt) (*Ar, error)

Load an Ar archive reader from an io.ReaderAt

func (*Ar) Next

func (d *Ar) Next() (*ArEntry, error)

Function to jump to the next file in the Debian `ar(1)` archive, and return the next member.

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

func (e *ArEntry) IsTarfile() bool

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.

func (*ArEntry) Tarfile

func (e *ArEntry) Tarfile() (*tar.Reader, io.Closer, error)

`.Tarfile()` will return a `tar.Reader` created from the ArEntry member to allow further inspection of the contents of the `.deb`.

type Closer

type Closer func() error

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          `required:"true"`
	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 `required:"true"`
}

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

func (c Control) SourceName() string

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

func Load(in io.ReaderAt, pathname string) (*Deb, error)

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 added in v0.11.0

func (deb *Deb) CheckDebsig(validKeys openpgp.EntityList, sigType string) (signer *openpgp.Entity, err error)

func (*Deb) Close added in v0.12.0

func (deb *Deb) Close() error

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.

Jump to

Keyboard shortcuts

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