pkgfile

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pkgfile extracts files from Debian and RPM packages.

This is deliberately not a package manager: it reads the payload archive and nothing else. No control metadata is parsed, no dependencies are resolved, no scripts are considered. The only use case is harvesting files that live at a well-known path inside a package, such as the CA certificates in ca-certificates.deb.

Payloads compressed with xz are rejected rather than decompressed: a pure-Go xz decoder is not in the standard library, and the core img tool deliberately takes no dependency beyond go-containerregistry and the stdlib.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Path is the file's path inside the package, without a leading "/".
	Path string
	// Content is the file's bytes.
	Content []byte
}

Entry is one extracted regular file.

func ExtractDeb

func ExtractDeb(debPath string, match Matcher) ([]Entry, error)

ExtractDeb returns the files of a .deb package's data archive that match.

A .deb is an ar archive holding, in order, debian-binary, control.tar* and data.tar*. Only the data member is read.

func ExtractRPM

func ExtractRPM(rpmPath string, match Matcher) ([]Entry, error)

ExtractRPM returns the files of an .rpm package's payload that match.

The layout read here is: a 96-byte lead, the signature header (padded to an 8-byte boundary), the main header, and then the compressed cpio payload. Only the payload compressor is read out of the header; nothing else about the package is interpreted.

type ErrUnsupportedCompression

type ErrUnsupportedCompression struct {
	// Package is the path of the package file.
	Package string
	// Compression names the format, e.g. "xz".
	Compression string
}

ErrUnsupportedCompression reports a payload this package cannot decompress.

func (*ErrUnsupportedCompression) Error

func (e *ErrUnsupportedCompression) Error() string

type Matcher

type Matcher func(path string) bool

Matcher decides whether a path inside a package should be extracted.

func PrefixMatcher

func PrefixMatcher(prefixes ...string) Matcher

PrefixMatcher matches any path under one of the given directory prefixes, or equal to one of them.

Jump to

Keyboard shortcuts

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