apt

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UncompressPackages

func UncompressPackages(downloads []FileByte) (io.Reader, error)

func UncompressSources

func UncompressSources(downloads []FileByte) (io.Reader, error)

UncompressSources selects an uncompressed or gzipped Sources index from a slice of FileByte.

Types

type Client

type Client struct {
	*http.Client
}

func New

func New(client *http.Client) *Client

func (*Client) InRelease

func (c *Client) InRelease(ctx context.Context, uri *url.URL, suite string) (InRelease, error)

InRelease gets an InRelease file from a Debian Repository and parses it.

func (*Client) Packages

func (c *Client) Packages(
	ctx context.Context, uri *url.URL, suite string, component Component,
) (PackagesBytes, error)

func (*Client) Sources

func (c *Client) Sources(
	ctx context.Context, uri *url.URL, suite string, component Component,
) (SourcesBytes, error)

Sources downloads and parses Sources index files from a remote HTTP mirror.

func (*Client) StreamFile

func (c *Client) StreamFile(ctx context.Context, uri *url.URL, suite string, file FileHash) (io.ReadCloser, error)

func (*Client) StreamPackage

func (c *Client) StreamPackage(ctx context.Context, uri *url.URL, file FileHash) (io.ReadCloser, error)

func (*Client) StreamSource

func (c *Client) StreamSource(ctx context.Context, uri *url.URL, file FileHash) (io.ReadCloser, error)

type Component

type Component struct {
	Name         string
	Architecture string
	Files        FileHashes
}

Component is a component/architecture pair in an InRelease file.

type Components

type Components []Component

Components is a Component slice.

func (Components) Diff

type ComponentsDiff

type ComponentsDiff struct {
	Added   Components
	Removed Components
	Changed Components
}

type Config

type Config struct {
	URI      *url.URL
	Suites   wheel.Set[string]
	SignedBy string
}

type Configs

type Configs map[string]Config

func MapConfigs

func MapConfigs(configs []config.Source) (Configs, error)

MapConfigs turns config.Source into a Configs. Since a source can have multiple URIs and those can collide between different sources, we need to know which URI has which suites.

type FileByte

type FileByte struct {
	Hashes FileHash
	Bytes  []byte
}

FileByte is a file from a Debian Repository along with its hashes.

type FileBytes

type FileBytes []FileByte

func (FileBytes) Diff

func (p FileBytes) Diff(n FileBytes) FileBytesDiff

type FileBytesDiff

type FileBytesDiff struct {
	Added   FileBytes
	Removed FileBytes
	Changed FileBytes
}

type FileHash

type FileHash struct {
	MD5Sum string
	SHA1   string
	SHA256 string
	SHA512 string

	Size uint

	// Filename may begin with `${component}/` from [InRelease], `pool/${suite}/`
	// from [Packages] or `pool/${suite}/` from [Source].
	Filename string
}

FileHash is a single file entry in an InRelease file. It's also used as a lowest common denominator for Packages file entries.

type FileHashes

type FileHashes map[string]FileHash

FileHashes contains all the file entries of an InRelease file.

func (FileHashes) Diff

type FileHashesDiff

type FileHashesDiff struct {
	Added   FileHashes
	Removed FileHashes
	Changed FileHashes
}

type InRelease

type InRelease struct {
	Hash          string
	Architectures []string
	Codename      string
	Components    []string
	Date          string
	Description   string
	Label         string
	Origin        string
	Suite         string
	Version       string
	AcquireByHash string

	MD5Sum []InReleaseSum
	SHA1   []InReleaseSum
	SHA256 []InReleaseSum
	SHA512 []InReleaseSum

	Raw      []byte
	Warnings []error
}

InRelease is a parsed InRelease file from a Debian Repository.

See https://wiki.debian.org/DebianRepository/Format#A.22Release.22_files.

func ParseInRelease

func ParseInRelease(r io.Reader) (InRelease, error)

ParseInRelease parses an InRelease file from a Debian Repository.

func (InRelease) ByComponents

func (i InRelease) ByComponents(files FileHashes) Components

ByComponents slices an InRelease file into component/architecture pairs.

func (InRelease) Diff

func (p InRelease) Diff(n InRelease) (FileHashesDiff, error)

func (InRelease) FileHashes

func (i InRelease) FileHashes() (FileHashes, error)

FileHashes obtains the file entries from an InRelease file as a FileHashes.

type InReleaseSum

type InReleaseSum struct {
	Hash string
	Size uint
	Path string
}

InReleaseSum is a single checksum entry in an InRelease file.

type Package

type Package struct {
	Package       string
	Version       string
	Architecture  string
	Section       string
	Priority      string
	InstalledSize uint
	Maintainer    string
	Description   string
	Homepage      *url.URL
	Conflicts     string
	Depends       string
	Recommends    string
	Provides      string
	Replaces      string
	MD5sum        string
	SHA1          string
	SHA256        string
	SHA512        string
	Size          uint
	Filename      string

	Warnings []error
}

Package is a single package entry in a Packages file.

func (Package) FileHash

func (p Package) FileHash() FileHash

FileHash turns a Package info a FileHash.

type Packages

type Packages []Package

Packages is an entire Packages file.

func ParsePackages

func ParsePackages(r io.Reader) (Packages, error)

func (Packages) Diff

func (p Packages) Diff(n Packages) PackagesDiff

type PackagesBytes

type PackagesBytes struct {
	Packages  Packages
	FileBytes FileBytes
}

type PackagesDiff

type PackagesDiff struct {
	Added   Packages
	Removed Packages
	Changed Packages
}

type Source

type Source struct {
	Package          string
	Format           string
	Binary           string
	Architecture     string
	Version          string
	Maintainer       string
	StandardsVersion string
	BuildDepends     string
	Homepage         *url.URL
	VcsBrowser       *url.URL
	VcsGit           *url.URL
	Directory        string
	PackageList      []string
	Files            []SourceSum
	ChecksumsSha1    []SourceSum
	ChecksumsSha256  []SourceSum
	ChecksumsSha512  []SourceSum

	Warnings []error
}

Source is a single entry in a Sources file.

func (Source) FileHashes

func (s Source) FileHashes() (FileHashes, error)

FileHash turns a Source info a FileHashes.

type SourceSum

type SourceSum struct {
	Hash string
	Size uint
	Name string
}

SourceSum is a single checksum entry in a Source definition.

type Sources

type Sources []Source

Sources is an entire Sources file.

func ParseSources

func ParseSources(r io.Reader) (Sources, error)

func (Sources) Diff

func (p Sources) Diff(n Sources) (SourcesDiff, error)

type SourcesBytes

type SourcesBytes struct {
	Sources   Sources
	FileBytes FileBytes
}

type SourcesDiff

type SourcesDiff struct {
	Added   Sources
	Removed Sources
	Changed Sources
}

Jump to

Keyboard shortcuts

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