daklib.utils¶
Utility functions
@contact: Debian FTP Master <ftpmaster@debian.org> @copyright: 2000, 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org> @license: GNU General Public License version 2 or later
Module Attributes
Cache for email addresses from gpg key uids |
Functions
|
Perform a substition of template |
|
|
|
run editor and return the result as a string |
|
|
|
Verify that the files listed in the Files field of the .dsc are those expected given the announced Format. |
|
|
|
Relativize an absolute symlink from 'src' -> 'dest' relative to 'root'. |
|
extract DEBIAN/control from a binary package |
|
split "section" into "section", "component" parts |
|
|
|
|
|
print error message and exit program |
|
Takes a directory and lists all .changes files in it (as well as chdir'ing to the directory; this is due to broken behaviour on the part of p-u/p-a when you're not in the right place) |
|
|
|
retrieve login from LDAP linked to a given fingerprint |
retrieve login and user names from LDAP |
|
get login name |
|
|
retreive email addresses from gpg key uids for a given fingerprint |
|
|
|
|
|
binary package is a debug package |
|
|
|
mail addresses to contact for an upload |
|
|
|
Move a file to the correct dir in morgue |
open connection to the configured LDAP server |
|
|
Handle -a, -c and -s arguments; returns them as SQL constraints |
|
|
|
source packages referenced via Built-Using |
|
Parses a changes or source control (.dsc) file and returns a dictionary where each field is a key. |
|
|
|
Parses the wnpp bug list available at https://qa.debian.org/data/bts/wnpp_rm Well, actually it parsed a local copy, but let's document the source somewhere ;) |
|
convert source name into directory path used in pool structure |
|
|
|
prepend prefix to each line in lines |
|
Copy buildinfo files into Dir::BuildinfoArchive |
|
|
|
sendmail wrapper, takes a message string |
|
|
|
Split command line arguments which can be separated by either commas or whitespace. |
|
Return suite_suffix for the given suite |
|
Return a secure and unique directory by pre-creating it. |
|
print warning message |
|
get user name |
Classes
|
Key object for use in sorting lists of architectures. |
- class daklib.utils.ArchKey(arch, *args)[source]¶
Key object for use in sorting lists of architectures.
Sorts normally except that ‘source’ dominates all others.
- arch¶
- issource¶
- daklib.utils.TemplateSubst(subst_map: Mapping[str, str], filename: str) str [source]¶
Perform a substition of template
- daklib.utils.build_file_list(changes: Mapping[str, str], is_a_dsc: bool = False, field='files', hashname='md5sum') dict[str, dict[str, str]] [source]¶
- daklib.utils.call_editor(text: str = '', suffix: str = '.txt') str [source]¶
run editor and return the result as a string
- Parameters:
text – initial text
suffix – extension for temporary file
- Returns:
string with the edited text
- daklib.utils.check_dsc_files(dsc_filename: str, dsc: Mapping[str, str], dsc_files: Mapping[str, Mapping[str, str]]) list[str] [source]¶
Verify that the files listed in the Files field of the .dsc are those expected given the announced Format.
- Parameters:
dsc_filename – path of .dsc file
dsc – the content of the .dsc parsed by
parse_changes()
dsc_files – the file list returned by
build_file_list()
- Returns:
all errors detected
- daklib.utils.check_reverse_depends(removals: Iterable[str], suite: str, arches: Optional[Iterable[Architecture]] = None, session=None, cruft: bool = False, quiet: bool = False, include_arch_all: bool = True) bool [source]¶
- daklib.utils.clean_symlink(src: str, dest: str, root: str) str [source]¶
Relativize an absolute symlink from ‘src’ -> ‘dest’ relative to ‘root’. Returns fixed ‘src’
- daklib.utils.deb_extract_control(path: str) bytes [source]¶
extract DEBIAN/control from a binary package
- daklib.utils.extract_component_from_section(section: str) tuple[str, str] [source]¶
split “section” into “section”, “component” parts
If “component” is not given, “main” is used instead.
- Returns:
tuple (section, component)
- daklib.utils.find_possibly_compressed_file(filename: str) str [source]¶
- Parameters:
filename – path to a control file (Sources, Packages, etc) to look for
- Returns:
path to the (possibly compressed) control file, or null if the file doesn’t exist
- daklib.utils.fubar(msg: str, exit_code: int = 1) NoReturn [source]¶
print error message and exit program
- daklib.utils.get_changes_files(from_dir: str) list[str] [source]¶
Takes a directory and lists all .changes files in it (as well as chdir’ing to the directory; this is due to broken behaviour on the part of p-u/p-a when you’re not in the right place)
Returns a list of filenames
- daklib.utils.get_logins_from_ldap(fingerprint: str = '*') dict[str, str] [source]¶
retrieve login from LDAP linked to a given fingerprint
- daklib.utils.gpg_get_key_addresses(fingerprint: str) list[str] [source]¶
retreive email addresses from gpg key uids for a given fingerprint
- daklib.utils.is_in_debug_section(control: Mapping[str, str]) bool [source]¶
binary package is a debug package
- Parameters:
control – control file of binary package
- Returns:
True if the binary package is a debug package
- daklib.utils.key_uid_email_cache: dict[str, list[str]] = {}¶
Cache for email addresses from gpg key uids
- daklib.utils.mail_addresses_for_upload(maintainer: str, changed_by: str, fingerprint: str) list[str] [source]¶
mail addresses to contact for an upload
- Parameters:
maintainer – Maintainer field of the .changes file
changed_by – Changed-By field of the .changes file
fingerprint – fingerprint of the key used to sign the upload
- Returns:
list of RFC 2047-encoded mail addresses to contact regarding this upload
- daklib.utils.move_to_morgue(morguesubdir: str, filenames: Iterable[str], fs_transaction: FilesystemTransaction, logger: Logger)[source]¶
Move a file to the correct dir in morgue
- Parameters:
morguesubdir – subdirectory of morgue where this file needs to go
filenames – names of files
fs_transaction – FilesystemTransaction instance
logger – logger instance
- daklib.utils.parse_args(Options) tuple[str, str, str, bool] [source]¶
Handle -a, -c and -s arguments; returns them as SQL constraints
- daklib.utils.parse_built_using(control: Mapping[str, str]) list[tuple[str, str]] [source]¶
source packages referenced via Built-Using
- Parameters:
control – control file to take Built-Using field from
- Returns:
list of (source_name, source_version) pairs
- daklib.utils.parse_changes(filename: str, signing_rules: Literal[-1, 0, 1] = 0, dsc_file: bool = False, keyrings=None) dict[str, str] [source]¶
Parses a changes or source control (.dsc) file and returns a dictionary where each field is a key. The mandatory first argument is the filename of the .changes file.
signing_rules is an optional argument:
If signing_rules == -1, no signature is required.
If signing_rules == 0 (the default), a signature is required.
If signing_rules == 1, it turns on the same strict format checking as dpkg-source.
The rules for (signing_rules == 1)-mode are:
The PGP header consists of “—–BEGIN PGP SIGNED MESSAGE—–” followed by any PGP header data and must end with a blank line.
The data section must end with a blank line and must be followed by “—–BEGIN PGP SIGNATURE—–“.
- Parameters:
dsc_file – filename is a Debian source control (.dsc) file
- daklib.utils.parse_deb822(armored_contents: bytes, signing_rules: Literal[-1, 0, 1] = 0, keyrings=None) dict[str, str] [source]¶
- daklib.utils.parse_wnpp_bug_file(file: str = '/srv/ftp-master.debian.org/scripts/masterfiles/wnpp_rm') dict[str, list[str]] [source]¶
Parses the wnpp bug list available at https://qa.debian.org/data/bts/wnpp_rm Well, actually it parsed a local copy, but let’s document the source somewhere ;)
returns a dict associating source package name with a list of open wnpp bugs (Yes, there might be more than one)
- daklib.utils.poolify(source: str) str [source]¶
convert source name into directory path used in pool structure
- daklib.utils.prefix_multi_line_string(lines: str, prefix: str, include_blank_lines: bool = False) str [source]¶
prepend prefix to each line in lines
- daklib.utils.process_buildinfos(directory: str, buildinfo_files: Iterable[HashedFile], fs_transaction: FilesystemTransaction, logger: Logger) None [source]¶
Copy buildinfo files into Dir::BuildinfoArchive
- Parameters:
directory – directory where .changes is stored
buildinfo_files – names of buildinfo files
fs_transaction – FilesystemTransaction instance
logger – logger instance
- daklib.utils.send_mail(message: str, whitelists: Optional[list[str]] = None) None [source]¶
sendmail wrapper, takes a message string
- Parameters:
whitelists – path to whitelists.
None
or an empty list whitelists everything, otherwise an address is whitelisted if it is included in any of the lists. In addition a global whitelist can be specified in Dinstall::MailWhiteList.
- daklib.utils.split_args(s: str, dwim: bool = True) list[str] [source]¶
Split command line arguments which can be separated by either commas or whitespace. If dwim is set, it will complain about string ending in comma since this usually means someone did ‘dak ls -a i386, m68k foo’ or something and the inevitable confusion resulting from ‘m68k’ being treated as an argument is undesirable.
- daklib.utils.temp_dirname(parent: Optional[str] = None, prefix: str = 'dak', suffix: str = '', mode: Optional[int] = None, group: Optional[str] = None) str [source]¶
Return a secure and unique directory by pre-creating it.
- Parameters:
parent – If non-null it will be the directory the directory is pre-created in.
prefix – The filename will be prefixed with this string
suffix – The filename will end with this string
mode – If set the file will get chmodded to those permissions
group – If set the file will get chgrped to the specified group.
- Returns:
Returns a pair (fd, name)