apt

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package apt provides utilities for Debian repository indices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFileInfo

func ExtractFileInfo(p string, r io.Reader) ([]*FileInfo, Paragraph, error)

ExtractFileInfo parses debian repository index files such as Release, Packages, or Sources and return a list of *FileInfo listed in the file.

If the index is Release, InRelease, or Index, this function also returns non-nil Paragraph data of the index.

p is the relative path of the file.

func IsMeta

func IsMeta(p string) bool

IsMeta returns true if p points a debian repository index file containing checksums for other files.

func IsSupported

func IsSupported(p string) bool

IsSupported returns true if the meta data is compressed that can be decompressed by ExtractFileInfo.

func SupportByHash added in v1.3.0

func SupportByHash(d Paragraph) bool

SupportByHash returns true if paragraph from Release indicates support for indices acquisition via hash values (by-hash). See https://wiki.debian.org/DebianRepository/Format#indices_acquisition_via_hashsums_.28by-hash.29

Types

type FileInfo

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

FileInfo is a set of meta data of a file.

func CopyWithFileInfo added in v1.4.0

func CopyWithFileInfo(dst io.Writer, src io.Reader, p string) (*FileInfo, error)

CopyWithFileInfo copies from src to dst until either EOF is reached on src or an error occurs, and returns FileInfo calculated while copying.

func MakeFileInfoNoChecksum

func MakeFileInfoNoChecksum(path string, size uint64) *FileInfo

MakeFileInfoNoChecksum constructs a FileInfo without calculating checksums.

func (*FileInfo) AddPrefix

func (fi *FileInfo) AddPrefix(prefix string) *FileInfo

AddPrefix creates a new FileInfo by prepending prefix to the path.

func (*FileInfo) CalcChecksums

func (fi *FileInfo) CalcChecksums(data []byte)

CalcChecksums calculates checksums and stores them in fi.

func (*FileInfo) HasChecksum

func (fi *FileInfo) HasChecksum() bool

HasChecksum returns true if fi has checksums.

func (*FileInfo) MD5SumPath added in v1.3.0

func (fi *FileInfo) MD5SumPath() string

MD5SumPath returns the filepath for "by-hash" with md5 checksum. If fi has no checksum, an empty string will be returned.

func (*FileInfo) MarshalJSON

func (fi *FileInfo) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*FileInfo) Path

func (fi *FileInfo) Path() string

Path returns the indentifying path string of the file.

func (*FileInfo) SHA1Path added in v1.3.0

func (fi *FileInfo) SHA1Path() string

SHA1Path returns the filepath for "by-hash" with sha1 checksum. If fi has no checksum, an empty string will be returned.

func (*FileInfo) SHA256Path added in v1.3.0

func (fi *FileInfo) SHA256Path() string

SHA256Path returns the filepath for "by-hash" with sha256 checksum. If fi has no checksum, an empty string will be returned.

func (*FileInfo) Same

func (fi *FileInfo) Same(t *FileInfo) bool

Same returns true if t has the same checksum values.

func (*FileInfo) Size

func (fi *FileInfo) Size() uint64

Size returns the number of bytes of the file body.

func (*FileInfo) UnmarshalJSON

func (fi *FileInfo) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Paragraph

type Paragraph map[string][]string

Paragraph is a mapping between field names and values.

Values are a list of strings. For simple fields, the list has only one element. Newlines are stripped from (multiline) strings. Folded fields are treated just the same as multiline fields.

type Parser

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

Parser reads debian control file and return Paragraph one by one.

PGP preambles and signatures are ignored if any.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser creates a parser from a io.Reader.

func (*Parser) Read

func (p *Parser) Read() (Paragraph, error)

Read reads a paragraph.

It returns io.EOF if no more paragraph can be read.

Jump to

Keyboard shortcuts

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