deb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidARMagic     = errors.New("invalid AR archive magic")
	ErrInvalidHeaderSize  = errors.New("invalid header size")
	ErrInvalidModTime     = errors.New("invalid modification time")
	ErrInvalidOwnerID     = errors.New("invalid owner ID")
	ErrInvalidGroupID     = errors.New("invalid group ID")
	ErrInvalidMode        = errors.New("invalid mode")
	ErrInvalidSize        = errors.New("invalid size")
	ErrARMemberTooLarge   = errors.New("AR member size exceeds maximum allowed")
	ErrInvalidARHeaderEnd = errors.New("invalid AR header ending marker")
)

Sentinel errors for AR archive parsing.

View Source
var (
	ErrInvalidControlFormat = errors.New("invalid control file format")
	ErrMissingRequiredField = errors.New("required field not found in control file")
)

Sentinel errors for control file parsing.

View Source
var (
	ErrEmptyDependency      = errors.New("empty dependency string")
	ErrInvalidVersionFormat = errors.New("invalid version constraint")
	ErrInvalidVersionOp     = errors.New("invalid version operator")
)

Sentinel errors for dependency parsing.

View Source
var (
	ErrControlArchiveNotFound   = errors.New("control archive not found in deb file (tried .gz, .xz, .zst)")
	ErrUnsupportedArchiveFormat = errors.New("unsupported control archive format")
	ErrFileNotFoundInTar        = errors.New("file not found in tar archive")
	ErrControlArchiveTooLarge   = errors.New("control archive exceeds max decompressed size")
	ErrDebFileTooLarge          = errors.New("deb file exceeds max size")
	ErrControlFileTooLarge      = errors.New("control file exceeds max size")
)

Sentinel errors for deb file parsing.

Functions

This section is empty.

Types

type ARArchive

type ARArchive struct {
	Members []*ARMember
}

ARArchive represents a Debian .deb file (which is an AR archive).

func ReadARArchive

func ReadARArchive(r io.Reader, maxMemberSize int64) (*ARArchive, error)

ReadARArchive reads and parses an AR archive. maxMemberSize bounds the declared size of any single member (guarding against a corrupt or malicious header causing an unbounded or negative allocation); pass <= 0 to fall back to maxARMemberSize. Callers that already hold the full input in memory should pass its length so a member can never be declared larger than the remaining stream.

func (*ARArchive) GetMember

func (a *ARArchive) GetMember(name string) *ARMember

GetMember retrieves a member by name.

func (*ARArchive) GetMemberData

func (a *ARArchive) GetMemberData(name string) []byte

GetMemberData retrieves member data by name.

func (*ARArchive) GetMemberReader

func (a *ARArchive) GetMemberReader(name string) io.Reader

GetMemberReader returns an io.Reader for a member.

func (*ARArchive) ListMembers

func (a *ARArchive) ListMembers() []string

ListMembers returns a list of member names.

type ARHeader

type ARHeader struct {
	Name    string
	ModTime time.Time
	OwnerID int
	GroupID int
	Mode    int
	Size    int64
}

ARHeader represents the header of an AR archive member.

type ARMember

type ARMember struct {
	Header ARHeader
	Data   []byte
}

ARMember represents a member file in an AR archive.

type ControlFile

type ControlFile struct {
	Fields map[string]string
}

ControlFile represents a Debian control file (RFC 822 format).

func ParseControlFile

func ParseControlFile(r io.Reader) (*ControlFile, error)

ParseControlFile parses a Debian control file in RFC 822 format Control files use field: value format with continuation lines starting with space.

func (*ControlFile) Get

func (cf *ControlFile) Get(field string) string

Get retrieves a field value.

func (*ControlFile) GetRequired

func (cf *ControlFile) GetRequired(field string) (string, error)

GetRequired retrieves a required field value.

func (*ControlFile) ParsePackage

func (cf *ControlFile) ParsePackage() (*Package, error)

ParsePackage extracts package metadata from a control file.

type DebFile

type DebFile struct {
	Package      *Package
	ControlFile  *ControlFile
	ControlTarGz []byte
}

DebFile represents a parsed .deb file.

func ParseDebFile

func ParseDebFile(r io.Reader) (*DebFile, error)

ParseDebFile parses a .deb file from a sequential reader. The input is buffered (bounded by maxDebFileSize); callers that already hold the data in a file should use ParseDebFileAt to avoid the copy.

func ParseDebFileAt added in v0.2.0

func ParseDebFileAt(r io.ReaderAt, size int64) (*DebFile, error)

ParseDebFileAt parses a .deb file by walking the AR headers with ReadAt and reading only the control archive, so memory use is independent of the package size.

func (*DebFile) GetMetadata

func (df *DebFile) GetMetadata() map[string]any

GetMetadata returns package metadata as a map.

type Dependency

type Dependency struct {
	Package   string
	Version   string
	Operator  string // "", "<<", "<=", "=", ">=", ">>"
	Arch      string // optional architecture qualifier
	Optional  bool   // true for Recommends/Suggests
	Conflicts bool   // true for Conflicts/Breaks
}

Dependency represents a single package dependency.

func (*Dependency) IsSatisfied

func (d *Dependency) IsSatisfied(version string) bool

IsSatisfied checks if a dependency is satisfied by a given package version.

func (*Dependency) String

func (d *Dependency) String() string

String returns the string representation of a dependency.

type DependencyGroup

type DependencyGroup struct {
	Dependencies []*Dependency
}

DependencyGroup represents a group of alternative dependencies (OR).

func (*DependencyGroup) String

func (dg *DependencyGroup) String() string

String returns the string representation of a dependency group.

type DependencyList

type DependencyList struct {
	Groups []*DependencyGroup
}

DependencyList represents a list of dependency groups (AND).

func ParseDependencies

func ParseDependencies(depStr string) (*DependencyList, error)

ParseDependencies parses a Debian dependency string Format: pkg1 (>= 1.0) | pkg2, pkg3 (= 2.0) Commas separate AND groups, pipes separate OR alternatives.

func (*DependencyList) GetPackages

func (dl *DependencyList) GetPackages() []string

GetPackages returns a list of all package names in the dependency list.

func (*DependencyList) String

func (dl *DependencyList) String() string

String returns the string representation of a dependency list.

type Package

type Package struct {
	Package       string
	Version       string
	Architecture  string
	Maintainer    string
	Description   string
	Depends       string
	PreDepends    string
	Recommends    string
	Suggests      string
	Conflicts     string
	Breaks        string
	Replaces      string
	Provides      string
	Section       string
	Priority      string
	Homepage      string
	Size          int64
	InstalledSize int64
	MD5sum        string
	SHA1          string
	SHA256        string
	Filename      string
	Source        string
	SourceVersion string
	Essential     bool
	MultiArch     string
	BuiltUsing    string
	Custom        map[string]string
}

Package represents a Debian package metadata.

Jump to

Keyboard shortcuts

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