apt

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package apt contains functions for managing a Debian APT repository

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist = fs.ErrNotExist
	ErrExist    = fs.ErrExist
)
View Source
var ErrAlreadyInPool = errors.New("already exists in pool but with different contents")

ErrAlreadyInPool is returned (possibly wrapped) by [AddToPool] when the file already exists in the pool but with different contents

Functions

This section is empty.

Types

type DirectoryStore

type DirectoryStore string

func (DirectoryStore) Create

func (dir DirectoryStore) Create(ctx context.Context, name string, content io.Reader, contentLen int64) (FileToken, error)

func (DirectoryStore) Delete

func (dir DirectoryStore) Delete(ctx context.Context, name string) error

func (DirectoryStore) Get

func (dir DirectoryStore) Link(ctx context.Context, oldName string, newName string) error

func (DirectoryStore) List

func (dir DirectoryStore) List(ctx context.Context, name string) ([]string, error)

func (DirectoryStore) Overwrite

func (dir DirectoryStore) Overwrite(ctx context.Context, name string, content io.Reader, contentLen int64) (FileToken, error)

func (DirectoryStore) Replace

func (dir DirectoryStore) Replace(ctx context.Context, name string, token FileToken, content io.Reader, contentLen int64) (FileToken, error)

func (DirectoryStore) URL

func (dir DirectoryStore) URL(ctx context.Context, name string) (string, error)

type Dist

type Dist struct {
	// contains filtered or unexported fields
}

AddPackage, AddSource, RemovePackage, RemoveSource are safe to call concurrently with each other.

func (*Dist) AddPackage

func (dist *Dist) AddPackage(ctx context.Context, component string, pkg IndexStanza) error

func (*Dist) AddSource

func (dist *Dist) AddSource(ctx context.Context, component string, newSrc IndexStanza) error

func (*Dist) Architectures

func (dist *Dist) Architectures() []string

func (*Dist) Codename

func (dist *Dist) Codename() string

func (*Dist) Components

func (dist *Dist) Components() []string

func (*Dist) ListPackages

func (dist *Dist) ListPackages(ctx context.Context, component string, arch string) ([]IndexStanza, error)

func (*Dist) ListSources

func (dist *Dist) ListSources(ctx context.Context, component string) ([]IndexStanza, error)

func (*Dist) ModifyIndexFile

func (dist *Dist) ModifyIndexFile(ctx context.Context, filename string, modifyFunc func([]byte) ([]byte, error)) error

func (*Dist) Publish

func (dist *Dist) Publish(ctx context.Context) error

Publish uploads all index files and publishes the distribution. If repo.Signed is true, an InRelease file is published and signed with repo.PrivateKey (an error is returned if it is nil). If repo.Signed is false, a Release file is published instead.

func (*Dist) RemovePackage

func (dist *Dist) RemovePackage(ctx context.Context, component string, arch string, name string) error

func (*Dist) RemoveSource

func (dist *Dist) RemoveSource(ctx context.Context, component string, name string) error

func (*Dist) Repo

func (dist *Dist) Repo() *Repo

func (*Dist) SerialNumber

func (dist *Dist) SerialNumber() uint64

type DistConfig

type DistConfig struct {
	Architectures []string
	Components    []string
	Origin        string
	Label         string
}

type FileHasher

type FileHasher struct {
	// contains filtered or unexported fields
}

func NewFileHasher

func NewFileHasher(path string) *FileHasher

func (*FileHasher) FileInfo

func (h *FileHasher) FileInfo() *FileInfo

func (*FileHasher) Write

func (h *FileHasher) Write(buf []byte) (int, error)

type FileInfo

type FileInfo struct {
	Path   string // e.g. "main/binary-arm64/Packages"
	Size   uint64
	MD5    [16]byte
	SHA1   [20]byte
	SHA256 [32]byte
	// contains filtered or unexported fields
}

func (*FileInfo) ByHashPath

func (f *FileInfo) ByHashPath() string

func (*FileInfo) Directory

func (f *FileInfo) Directory() string

func (*FileInfo) Filename

func (f *FileInfo) Filename() string

type FileToken

type FileToken any

type HTTPStore

type HTTPStore struct {
	BaseURL   string // must contain trailing slash
	UserAgent string
}

Read-only HTTP store

func (*HTTPStore) Create

func (store *HTTPStore) Create(ctx context.Context, name string, content io.Reader, contentLen int64) (FileToken, error)

func (*HTTPStore) Delete

func (store *HTTPStore) Delete(ctx context.Context, name string) error

func (*HTTPStore) Get

func (store *HTTPStore) Get(ctx context.Context, name string) (io.ReadCloser, FileToken, error)
func (store *HTTPStore) Link(ctx context.Context, oldName string, newName string) error

func (*HTTPStore) List

func (store *HTTPStore) List(ctx context.Context, name string) ([]string, error)

func (*HTTPStore) Overwrite

func (store *HTTPStore) Overwrite(ctx context.Context, name string, content io.Reader, contentLen int64) (FileToken, error)

func (*HTTPStore) Replace

func (store *HTTPStore) Replace(ctx context.Context, name string, token FileToken, content io.Reader, contentLen int64) (FileToken, error)

func (*HTTPStore) URL

func (store *HTTPStore) URL(ctx context.Context, name string) (string, error)

type IndexStanza

type IndexStanza struct {
	Package string

	controlfile.Stanza
}

func ParseIndexStanza

func ParseIndexStanza(data []byte) (IndexStanza, []byte)

type ReleaseFile

type ReleaseFile struct {
	Origin           string
	Label            string
	Codename         string
	Date             time.Time
	ValidUntil       time.Time
	SerialNumber     uint64
	Architectures    []string
	Components       []string
	AcquireByHash    bool
	NoSupportArchAll string
	IndexFiles       map[string]*FileInfo
}

func ParseReleaseFile

func ParseReleaseFile(data []byte) (*ReleaseFile, error)

func (*ReleaseFile) GetIndexFile

func (r *ReleaseFile) GetIndexFile(name string) (*FileInfo, decompressor)

func (*ReleaseFile) GetIndexFiles

func (r *ReleaseFile) GetIndexFiles(name string) []*FileInfo

func (*ReleaseFile) Marshal

func (r *ReleaseFile) Marshal() ([]byte, error)

type Repo

type Repo struct {
	Store            Store
	PublicKeys       []pgpsign.PublicKey // nil to disable verification of InRelease files when Signed is true
	EnforceValidAt   time.Time           // if not zero, require (In)Release file to be valid at this time
	Signed           bool                // download/publish InRelease files instead of Release files
	PrivateKey       *pgpsign.PrivateKey // required to sign InRelease files when Signed is true
	Validity         time.Duration       // zero for no expiration
	LegacySignatures bool
	LegacyIndexFiles bool
}

Methods are safe to call concurrently

func (*Repo) AddToPool

func (repo *Repo) AddToPool(ctx context.Context, component string, sourceName string, filename string, file io.Reader, fileLen int64) (*FileInfo, error)

func (*Repo) GetDist

func (repo *Repo) GetDist(ctx context.Context, codename string) (*Dist, error)

GetDist retrieves the given distribution from the repository. If repo.Signed is true, the InRelease file is downloaded and verified with repo.PublicKeys (if non-nil). If repo.Signed is false, the Release file is downloaded instead.

func (*Repo) GetPackage

func (repo *Repo) GetPackage(ctx context.Context, pkg IndexStanza) (io.ReadCloser, error)

Download the given package from the pool. Package integrity is not verified until the ReadCloser is closed; be sure to check the return value of Close before executing any code contained in the package.

func (*Repo) ListDists

func (repo *Repo) ListDists(ctx context.Context) ([]string, error)

func (*Repo) NewDist

func (repo *Repo) NewDist(codename string, config *DistConfig) (*Dist, error)

func (*Repo) SignDist

func (repo *Repo) SignDist(ctx context.Context, codename string) error

SignDist downloads a dist's Release file, signs it with repo.PrivateKey, and uploads InRelease and Release.gpg (if enabled) files. Returns an error if repo.PrivateKey is nil.

Directories

Path Synopsis
package s3 implements an apt.Store in Amazon S3
package s3 implements an apt.Store in Amazon S3

Jump to

Keyboard shortcuts

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