daklib.upload

module to handle uploads not yet installed to the archive

This module provides classes to handle uploads not yet installed to the archive. Central is the Changes class which represents a changes file. It provides methods to access the included binary and source packages.

Functions

parse_file_list(control, ...[, ...])

Parse Files and Checksums-* fields

Classes

Binary(directory, hashed_file)

Representation of a binary package

Changes(directory, filename, keyrings[, ...])

Representation of a .changes file

HashedFile(filename, size, md5sum, sha1sum, ...)

file with checksums

Source(directory, hashed_files, keyrings[, ...])

Representation of a source package

Exceptions

FileDoesNotExist(filename)

InvalidBinaryException

InvalidChangesException

InvalidFilenameException(filename)

InvalidHashException(filename, hash_name, ...)

InvalidSourceException

UploadException

class daklib.upload.Binary(directory: str, hashed_file: HashedFile)[source]

Representation of a binary package

property component: str

component name

control: TagSection

dict to access fields in DEBIAN/control

classmethod from_file(directory, filename) Binary[source]
hashed_file: HashedFile

file object for the .deb

property name: str
property source: tuple[str, str]

get tuple with source package name and version

property type: str

package type (‘deb’ or ‘udeb’)

class daklib.upload.Changes(directory: str, filename: str, keyrings, require_signature: bool = True)[source]

Representation of a .changes file

_key() tuple[str, daklib.aptversion.AptVersion, bool, str][source]

tuple used to compare two changes files

We sort by source name and version first. If these are identical, we sort changes that include source before those without source (so that sourceful uploads get processed first), and finally fall back to the filename (this should really never happen).

property architectures: list[str]

list of architectures included in the upload

property binaries: list[daklib.upload.Binary]

included binary packages

property binary_names: list[str]

names of included binary packages

property buildinfo_files: list[daklib.upload.HashedFile]

included buildinfo files

property byhand_files: list[daklib.upload.HashedFile]

included byhand files

property bytes: int

total size of files included in this upload in bytes

changes: TagSection

dict to access fields of the .changes file

property closed_bugs: list[str]

bugs closed by this upload

property contents_sha1: str
directory: str

directory the .changes is located in

property distributions: list[str]

list of target distributions for the upload

filename: str

name of the .changes file

property files: dict[str, daklib.upload.HashedFile]

dict mapping filenames to HashedFile objects

property path: str

path to the .changes file

property primary_fingerprint: str

fingerprint of the key used for signing the .changes file

property signature_timestamp: datetime.datetime
property source: Optional[Source]

included source or None

property source_name: str

source package name

property sourceful: bool

True if the upload includes source

property valid_signature: bool

True if the .changes has a valid signature

property weak_signature: bool

True if the .changes was signed using a weak algorithm

exception daklib.upload.FileDoesNotExist(filename: str)[source]
class daklib.upload.HashedFile(filename: str, size: int, md5sum: str, sha1sum: str, sha256sum: str, section: Optional[str] = None, priority: Optional[str] = None, input_filename: Optional[str] = None)[source]

file with checksums

check(directory: str) None[source]

Validate hashes

Check if size and hashes match the expected value.

Parameters:

directory – directory the file is located in

Raises:

InvalidHashException – if there is a hash mismatch

check_fh(fh) None[source]
filename: str

name of the file

classmethod from_file(directory: str, filename: str, section: Optional[str] = None, priority: Optional[str] = None) HashedFile[source]

create with values for an existing file

Create a HashedFile object that refers to an already existing file.

Parameters:
  • directory – directory the file is located in

  • filename – filename

  • section – optional section as given in .changes files

  • priority – optional priority as given in .changes files

Returns:

HashedFile object for the given file

input_filename: str

name of the file on disk

Used for temporary files that should not be installed using their on-disk name.

md5sum: str

MD5 hash in hexdigits

priority: Optional[str]

priority or None

section: Optional[str]

section or None

sha1sum: str

SHA1 hash in hexdigits

sha256sum: str

SHA256 hash in hexdigits

size: int

size in bytes

exception daklib.upload.InvalidBinaryException[source]
exception daklib.upload.InvalidChangesException[source]
exception daklib.upload.InvalidFilenameException(filename: str)[source]
exception daklib.upload.InvalidHashException(filename: str, hash_name: str, expected, actual)[source]
exception daklib.upload.InvalidSourceException[source]
class daklib.upload.Source(directory: str, hashed_files: list[daklib.upload.HashedFile], keyrings, require_signature=True)[source]

Representation of a source package

property component: str

guessed component name

Might be wrong. Don’t rely on this.

dsc: Mapping[str, str]

dict to access fields in the .dsc file

property filename: str

filename of .dsc file

property files: dict[str, daklib.upload.HashedFile]

dict mapping filenames to HashedFile objects for additional source files

This list does not include the .dsc itself.

classmethod from_file(directory, filename, keyrings, require_signature=True) Source[source]
hashed_files: list[daklib.upload.HashedFile]

list of source files (including the .dsc itself)

package_list: PackageList

Information about packages built by the source.

property primary_fingerprint: str

fingerprint of the key used to sign the .dsc

property valid_signature: bool

True if the .dsc has a valid signature

property weak_signature: bool

True if the .dsc was signed using a weak algorithm

exception daklib.upload.UploadException[source]
daklib.upload.parse_file_list(control: Mapping[str, str], has_priority_and_section: bool, safe_file_regexp: Pattern = re.compile('^[a-zA-Z0-9][a-zA-Z0-9_.~+-]*$'), fields=('Files', 'Checksums-Sha1', 'Checksums-Sha256')) dict[str, daklib.upload.HashedFile][source]

Parse Files and Checksums-* fields

Parameters:
  • control – control file to take fields from

  • has_priority_and_section – Files field include section and priority (as in .changes)

Returns:

dict mapping filenames to HashedFile objects

Raises:

InvalidChangesException – missing fields or other grave errors