deb

package
v0.0.0-...-19c5dc3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2019 License: BSD-3-Clause, MIT Imports: 17 Imported by: 0

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/cinello/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

This section is empty.

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.Reader) (*Ar, error)

Load an Ar archive reader from an io.Reader

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.Reader
}

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 `control.tar.*` and `data.tar.*` files.

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, 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
}

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.Reader, 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.

type DecompressorFunc

type DecompressorFunc func(io.Reader) (io.Reader, 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