debian

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package debian implements Debian package and repository metadata.

Index

Constants

View Source
const (
	KindIndex          = "debian.index"
	KindReindexNoProps = "debian.reindex-no-props"
)
View Source
const (
	PropDistribution = "deb.distribution"
	PropComponent    = "deb.component"
	PropArchitecture = "deb.architecture"
	PropName         = "deb.name"
	PropVersion      = "deb.version"
)

Variables

This section is empty.

Functions

func ByHashMetadataPath

func ByHashMetadataPath(p string) (string, bool)

ByHashMetadataPath names a checksum-addressed Packages or Sources index.

func GzipIndex

func GzipIndex(body []byte) ([]byte, error)

GzipIndex compresses apt index text with a stable header for reproducible Release checksums and by-hash URLs.

func Packages

func Packages(entries []IndexedBinary) ([]byte, error)

Packages writes one binary-architecture index in stable package order. Architecture-independent packages belong in binary-all and in each architecture supported by the distribution.

func PackagesIndexPath

func PackagesIndexPath(p string) bool

PackagesIndexPath accepts only the apt binary-index layout this adapter understands. The same grammar guards remote metadata and virtual reads.

func Release

func Release(
	distribution string,
	components, architectures []string,
	generated []ReleaseEntry,
	at time.Time,
) ([]byte, error)

Release builds the checksummed metadata apt verifies before accepting a Packages index. Signing this body produces InRelease and Release.gpg.

func ReleaseMetadataPath

func ReleaseMetadataPath(p string) bool

ReleaseMetadataPath names one of the metadata files apt checks before it accepts indexes for a distribution.

func Serves

func Serves(t repo.PackageType) bool

func Sources

func Sources(entries []IndexedSource) ([]byte, error)

Sources emits the deb-src index with server-computed checksums. Client supplied Directory, Files and Checksums fields never reach the output.

func SourcesIndexPath

func SourcesIndexPath(p string) bool

SourcesIndexPath accepts apt source indexes for one distribution/component.

func ValidBinaryPath

func ValidBinaryPath(p string) bool

ValidBinaryPath reports whether a repository-relative path can safely appear as the Filename of a binary package in an apt index.

func ValidSourcePath

func ValidSourcePath(p string) bool

ValidSourcePath reports whether a repository-relative descriptor path can safely appear in a Sources index.

func ValidateReleaseMetadata

func ValidateReleaseMetadata(p string, body []byte) error

ValidateReleaseMetadata bounds upstream metadata before cache publication. Apt verifies the OpenPGP signature with its configured key; this checks the control structure and checksum paths so malformed bytes do not enter cache.

func WithSnapshotDelete

func WithSnapshotDelete(ctx context.Context) context.Context

WithSnapshotDelete permits deleting a complete snapshot folder.

func WithSnapshotWrite

func WithSnapshotWrite(ctx context.Context) context.Context

WithSnapshotWrite marks server-owned metadata publication. A client cannot supply this context value through the HTTP or package protocol surface.

Types

type Binary

type Binary struct {
	Name, Version, Architecture string
	Control                     []byte
}

Binary is the metadata in a validated .deb control archive. Control holds the original deb822 fields for the Packages index, including continuation lines, so package-specific fields are not silently discarded.

func ReadBinary

func ReadBinary(ctx context.Context, body io.ReaderAt, size int64) (Binary, error)

ReadBinary validates the ordered ar members, bounded control metadata and the data archive before any uploaded package can enter an apt index.

type Handler

type Handler struct{ generic.Handler }

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	w format.Write,
) (format.Write, error)

func (Handler) Classify

func (Handler) Classify(_ repo.Config, path string) format.Class

func (Handler) Deleted

func (Handler) Deleted(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	removed []types.Item,
) error

func (Handler) Deleting

func (Handler) Deleting(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) Deployed

func (Handler) Deployed(ctx context.Context, env format.Env, c repo.Config, it types.Item) error

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context,
	env format.Env,
	_ repo.Config,
	w format.Write,
) (any, error)

func (Handler) Owed

func (Handler) Owed(c repo.Config, cached bool, path string) []format.WorkRef

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

func (Handler) Work

func (Handler) Work(ctx context.Context, env format.Env, work types.WorkItem) error

Work rebuilds apt metadata from the committed item tree. It never builds a remote repository's index from a partial cache: remote metadata is fetched from the upstream with the source/cache policy instead.

func (Handler) WorkKinds

func (Handler) WorkKinds() []string

type IndexedBinary

type IndexedBinary struct {
	Binary    Binary
	Path      string
	Size      int64
	Checksums types.Checksums
}

IndexedBinary binds a validated control record to the exact stored item and its server-computed digests. The upload cannot supply these values.

type IndexedSource

type IndexedSource struct {
	Source    Source
	Path      string
	Size      int64
	Checksums types.Checksums
	Archives  []SourceArchive
}

IndexedSource binds a parsed .dsc to the stored bytes for it and each named archive. Source records are emitted only after all declared bytes match.

type PackageIndexRef

type PackageIndexRef struct {
	Path   string
	SHA256 string
	Size   int64
}

PackageIndexRef binds a Packages representation to the SHA256 and size declared by its member Release file.

func ReleaseIndexRefs

func ReleaseIndexRefs(distribution string, body []byte) ([]PackageIndexRef, error)

ReleaseIndexRefs returns every checksum-bound metadata path in a Release. Snapshot creation uses these declarations to materialize an immutable view.

func ReleasePackageIndexes

func ReleasePackageIndexes(distribution string, body []byte) ([]PackageIndexRef, error)

ReleasePackageIndexes selects the plain Packages index for each advertised component and architecture, falling back to gzip when plain is absent. The caller must compare the fetched bytes with each declared digest.

func (PackageIndexRef) BasePath

func (r PackageIndexRef) BasePath() string

BasePath is the uncompressed Packages or Sources path for a Release member.

type PackageRecord

type PackageRecord struct {
	Name, Version, Architecture string
	Filename, SHA256            string
	Size                        int64
	Raw                         []byte
}

PackageRecord is a validated stanza in an upstream Packages index. Raw retains package fields for virtual index composition, while Filename and SHA256 bind the advertised download to one repository-relative artifact.

func DecodePackagesIndex

func DecodePackagesIndex(body []byte) ([]PackageRecord, error)

DecodePackagesIndex accepts the plain and mandatory gzip index encodings. The bound applies after decompression, so a small compressed bomb cannot enter the remote cache or a virtual index.

func ParsePackagesIndex

func ParsePackagesIndex(body []byte) ([]PackageRecord, error)

ParsePackagesIndex checks the complete apt Packages representation before it can be cached or combined into a virtual index. A malformed stanza must not make apt resolve a package that the registry cannot safely address.

type ReleaseEntry

type ReleaseEntry struct {
	Path string
	Body []byte
}

ReleaseEntry is a path under dists/<distribution> and its generated body.

type SignedRelease

type SignedRelease struct {
	InRelease  []byte
	ReleaseGPG []byte
}

SignedRelease is the two signatures apt can verify beside Release.

func SignRelease

func SignRelease(body []byte, armoredPrivate, passphrase string) (SignedRelease, error)

SignRelease binds an apt Release file to the repository's configured GPG private key. Callers publish all three files in one derivation cycle.

type Source

type Source struct {
	Name, Version, Format string
	Control               []byte
	Parts                 []SourcePart
}

Source is the parsed source control file and its declared archive parts.

func ReadSource

func ReadSource(ctx context.Context, r io.Reader, size int64) (Source, error)

ReadSource parses an unsigned or OpenPGP clear-signed .dsc without accepting a second stanza or unbounded input. The repository verifies archive digests separately before any Sources entry is published.

type SourceArchive

type SourceArchive struct {
	Name      string
	Size      int64
	Checksums types.Checksums
}

type SourceIndexRecord

type SourceIndexRecord struct {
	Files []string
}

SourceIndexRecord lists the artifact paths advertised by one validated Sources stanza. It lets the HTTP layer enforce read permissions before exposing a source index to an apt client.

func DecodeSourcesIndex

func DecodeSourcesIndex(body []byte) ([]SourceIndexRecord, error)

DecodeSourcesIndex bounds and validates plain or gzip apt source indexes.

type SourcePart

type SourcePart struct {
	Name, MD5, SHA256 string
	Size              int64
}

SourcePart is one archive named by a .dsc file. Its declarations are not trusted until the repository has compared them to stored server checksums.

Jump to

Keyboard shortcuts

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