daklib.archive¶
module to manipulate the archive
This module provides classes to manipulate the archive.
Functions
Get component for a source package |
Classes
manipulate the archive in a transaction |
|
|
handle an upload |
Exceptions
- class daklib.archive.ArchiveTransaction[source]¶
manipulate the archive in a transaction
- _add_built_using(db_binary, filename, control, suite, extra_archives=None) None [source]¶
Add Built-Using sources to
db_binary.extra_sources
- _copy_file(db_file: PoolFile, archive: Archive, component: Component, allow_tainted: bool = False) None [source]¶
Copy a file to the given archive and component
- Parameters:
db_file – file to copy
archive – target archive
component – target component
allow_tainted – allow to copy from tainted archives (such as NEW)
- _ensure_extra_source_exists(filename: str, source: DBSource, archive: Archive, extra_archives: Optional[Iterable[Archive]] = None)[source]¶
ensure source exists in the given archive
This is intended to be used to check that Built-Using sources exist.
- Parameters:
filename – filename to use in error messages
source – source to look for
archive – archive to look in
extra_archives – list of archives to copy the source package from if it is not yet present in archive
- _install_file(directory, hashed_file, archive, component, source_name) PoolFile [source]¶
Install a file
Will not give an error when the file is already present.
- Returns:
database object for the new file
- copy_binary(db_binary: DBBinary, suite: Suite, component: Component, allow_tainted: bool = False, extra_archives: Optional[Iterable[Archive]] = None) None [source]¶
Copy a binary package to the given suite and component
- Parameters:
db_binary – binary to copy
suite – target suite
component – target component
allow_tainted – allow to copy from tainted archives (such as NEW)
extra_archives – extra archives to copy Built-Using sources from
- copy_source(db_source: DBSource, suite: Suite, component: Component, allow_tainted: bool = False) None [source]¶
Copy a source package to the given suite and component
- Parameters:
db_source – source to copy
suite – target suite
component – target component
allow_tainted – allow to copy from tainted archives (such as NEW)
- get_file(hashed_file: HashedFile, source_name: str, check_hashes: bool = True) PoolFile [source]¶
Look for file hashed_file in database
- Parameters:
hashed_file – file to look for in the database
source_name – source package name
check_hashes – check size and hashes match
- Returns:
database entry for the file
- Raises:
KeyError – file was not found in the database
HashMismatchException – hash mismatch
- install_binary(directory: str, binary: Binary, suite: Suite, component: Component, allow_tainted: bool = False, fingerprint: Optional[Fingerprint] = None, source_suites=None, extra_source_archives: Optional[Iterable[Archive]] = None) DBBinary [source]¶
Install a binary package
- Parameters:
directory – directory the binary package is located in
binary – binary package to install
suite – target suite
component – target component
allow_tainted – allow to copy additional files from tainted archives
fingerprint – optional fingerprint
source_suites – suites to copy the source from if they are not in suite or
True
to allow copying from any suite. Can be a SQLAlchemy subquery forSuite
orTrue
.extra_source_archives – extra archives to copy Built-Using sources from
- Returns:
database object for the new package
- install_source(directory: str, source: Source, suite: Suite, component: Component, changed_by: Maintainer, allow_tainted: bool = False, fingerprint: Optional[Fingerprint] = None) DBSource [source]¶
Install a source package
- Parameters:
directory – directory the source package is located in
source – source package to install
suite – target suite
component – target component
changed_by – person who prepared this version of the package
allow_tainted – allow to copy additional files from tainted archives
fingerprint – optional fingerprint
- Returns:
database object for the new source
- install_source_to_archive(directory, source, archive, component, changed_by, allow_tainted=False, fingerprint=None) DBSource [source]¶
Install source package to archive
- remove_binary(binary: DBBinary, suite: Suite) None [source]¶
Remove a binary from a given suite and component
- Parameters:
binary – binary to remove
suite – suite to remove the package from
- remove_file(db_file: PoolFile, archive: Archive, component: Component) None [source]¶
Remove a file from a given archive and component
- Parameters:
db_file – file to remove
archive – archive to remove the file from
component – component to remove the file from
- class daklib.archive.ArchiveUpload(directory: str, changes, keyrings)[source]¶
handle an upload
This class can be used in a with-statement:
with ArchiveUpload(...) as upload: ...
Doing so will automatically run any required cleanup and also rollback the transaction if it was not committed.
- _binary_component(suite: Suite, binary: Binary, only_overrides: bool = True) Optional[Component] [source]¶
get component for a binary
By default this will only look at overrides to get the right component; if only_overrides is
False
this method will also look at the Section field.- Parameters:
only_overrides – only use overrides to get the right component
- _binary_override(suite: Suite, binary: Union[Binary, PackageListEntry]) Optional[Override] [source]¶
Get override entry for a binary
- Parameters:
suite – suite to get override for
binary – binary to get override for
- Returns:
override for the given binary or
None
- _check_new(suite, overridesuite) bool [source]¶
Check if upload is NEW
An upload is NEW if it has binary or source packages that do not have an override in overridesuite OR if it references files ONLY in a tainted archive (eg. when it references files in NEW).
Debug packages (*-dbgsym in Section: debug) are not considered as NEW if suite has a separate debug suite.
- Returns:
True
if the upload is NEW,False
otherwise
- _install_byhand(policy_queue_upload: PolicyQueueUpload, hashed_file: HashedFile) PolicyQueueByhandFile [source]¶
install byhand file
- _install_policy(policy_queue, target_suite, db_changes, db_source, db_binaries) PolicyQueueUpload [source]¶
install upload to policy queue
- _install_to_suite(target_suite: Suite, suite: Suite, source_component_func: Callable[[Source], Component], binary_component_func: Callable[[Binary], Component], source_suites=None, extra_source_archives: Optional[Iterable[Archive]] = None, policy_upload: bool = False) tuple[Optional[daklib.dbconn.DBSource], list[daklib.dbconn.DBBinary]] [source]¶
Install upload to the given suite
- Parameters:
target_suite – target suite (before redirection to policy queue or NEW)
suite – suite to install the package into. This is the real suite, ie. after any redirection to NEW or a policy queue
source_component_func – function to get the
daklib.dbconn.Component
for adaklib.upload.Source
objectbinary_component_func – function to get the
daklib.dbconn.Component
for adaklib.upload.Binary
objectsource_suites – see
daklib.archive.ArchiveTransaction.install_binary()
extra_source_archives – see
daklib.archive.ArchiveTransaction.install_binary()
policy_upload – Boolean indicating upload to policy queue (including NEW)
- Returns:
tuple with two elements. The first is a
daklib.dbconn.DBSource
object for the install source orNone
if no source was included. The second is a list ofdaklib.dbconn.DBBinary
objects for the installed binary packages.
- _mapped_suites() list[daklib.dbconn.Suite] [source]¶
Get target suites after mappings
- Returns:
list giving the mapped target suites of this upload
- _policy_queue(suite) Optional[PolicyQueue] [source]¶
- _source_component(suite: Suite, source: Binary, only_overrides: bool = True) Optional[Component] [source]¶
get component for a source
By default this will only look at overrides to get the right component; if only_overrides is
False
this method will also look at the Section field.- Parameters:
only_overrides – only use overrides to get the right component
- _source_override(suite: Suite, source: Source) Optional[Override] [source]¶
Get override entry for a source
- Parameters:
suite – suite to get override for
source – source to get override for
- Returns:
override for the given source or
None
- check(force: bool = False) bool [source]¶
run checks against the upload
- Parameters:
force – ignore failing forcable checks
- Returns:
True
if all checks passed,False
otherwise
- fingerprint: Fingerprint¶
fingerprint of the key used to sign the upload
- install() None [source]¶
install upload
Install upload to a suite or policy queue. This method does not handle uploads to NEW.
You need to have called the
check()
method before calling this method.
- install_to_new() None [source]¶
install upload to NEW
Install upload to NEW. This method does not handle regular uploads to suites or policy queues.
You need to have called the
check()
method before calling this method.
- prepare()[source]¶
prepare upload for further processing
This copies the files involved to a temporary directory. If you use this method directly, you have to remove the directory given by the
directory
attribute later on your own.Instead of using the method directly, you can also use a with-statement:
with ArchiveUpload(...) as upload: ...
This will automatically handle any required cleanup.
- session¶
database session
- transaction: ArchiveTransaction¶
transaction used to handle the upload
- unpacked_source() Optional[str] [source]¶
Path to unpacked source
Get path to the unpacked source. This method does unpack the source into a temporary directory under
directory
if it has not been done so already.- Returns:
string giving the path to the unpacked source directory or
None
if no source was included in the upload.
- daklib.archive.source_component_from_package_list(package_list: PackageList, suite: Suite) Optional[Component] [source]¶
Get component for a source package
This function will look at the Package-List field to determine the component the source package belongs to. This is the first component the source package provides binaries for (first with respect to the ordering of components).
It the source package has no Package-List field, None is returned.
- Parameters:
package_list – package list of the source to get the override for
suite – suite to consider for binaries produced
- Returns:
component for the given source or
None