Package dak :: Package daklib :: Module utils
[show private | hide private]
[frames | no frames]

Module dak.daklib.utils

Function Summary
  arch_compare_sw(a, b)
  build_file_list(changes, is_a_dsc, field, hashname)
  cc_fix_changes(changes)
  changes_compare(a, b)
  check_hash(where, files, hashname, hashfunc)
check_hash checks the given hash in the files dict against the actual files on disk.
  check_hash_fields(what, manifest)
check_hash_fields ensures that there are no checksum fields in the given dict that we do not know about.
  check_signature(sig_filename, reject, data_filename, keyrings, autofetch)
Check the signature of a file and return the fingerprint if the signature is valid or 'None' if it's not.
  check_size(where, files)
check_size checks the file sizes in the passed files dict against the files on disk.
  clean_symlink(src, dest, root)
  copy(src, dest, overwrite, perms)
  create_hash(where, files, hashname, hashfunc)
create_hash extends the passed files dict with the given hash by iterating over all files on disk and passing them to the hashing function given.
  Dict(**dict)
  ensure_hashes(changes, dsc, files, dsc_files)
  extract_component_from_section(section)
  find_next_free(dest, too_many)
  fix_maintainer(maintainer)
Parses a Maintainer or Changed-By field and returns: (1) an RFC822 compatible version, (2) an RFC2047 compatible version, (3) the name (4) the email The name is forced to UTF-8 for both (1) and (3).
  force_to_utf8(s)
Forces a string to UTF-8.
  fubar(msg, exit_code)
  get_conf()
  gpg_get_key_addresses(fingerprint)
retreive email addresses from gpg key uids for a given fingerprint
  gpg_keyring_args(keyrings)
  gpgv_get_status_output(cmd, status_read, status_write)
  hash_key(hashname)
  html_escape(s)
  is_email_alias(email)
  join_with_commas_and(list)
  move(src, dest, overwrite, perms)
  open_file(filename, mode)
  our_raw_input(prompt)
  parse_args(Options)
  parse_changes(filename, signing_rules)
Parses a changes file and returns a dictionary where each field is a key.
  parse_checksums(where, files, manifest, hashname)
  parse_deb822(contents, signing_rules)
  poolify(source, component)
  pp_deps(deps)
  prefix_multi_line_string(str, prefix, include_blank_lines)
  print_exc()
  process_gpgv_output(status)
  real_arch(arch)
  regex_safe(s)
  result_join(original, sep)
  retrieve_key(filename, keyserver, keyring)
Retrieve the key that signed 'filename' from 'keyserver' and add it to 'keyring'.
  rfc2047_encode(s)
Encodes a (header) string per RFC2047 if necessary.
  send_mail(message, filename)
  size_type(c)
  split_args(s, dwim)
  temp_filename(directory, prefix, suffix)
Return a secure and unique filename by pre-creating it.
  TemplateSubst(map, filename)
  try_with_debug(function)
  validate_changes_file_arg(filename, require_changes)
'filename' is either a .changes or .dak file.
  warn(msg)
  where_am_i()
  which_alias_file()
  which_apt_conf_file()
  which_conf_file()
  whoami()
  wrap(paragraph, max_length, prefix)

Variable Summary
NoneType alias_cache = None                                                                  
Configuration Cnf = <Configuration object at 0x7f5a6b212570>
str default_apt_config = '/etc/dak/apt.conf'
str default_config = '/etc/dak/dak.conf'
dict html_escaping = {'>': '&gt;', '"': '&quot;', '<': '&lt;'...
dict key_uid_email_cache = {}
list known_hashes = [('sha1', <built-in function sha1sum>, (1...
SRE_Pattern re_arch_from_filename = /binary-[^/]+/
SRE_Pattern re_comments = #.*
SRE_Pattern re_extract_src_version = (\S+)\s*\((.*)\)
SRE_Pattern re_gpg_uid = ^uid.*<([^>]*)>
SRE_Pattern re_html_escaping = [>"<&]
SRE_Pattern re_isadeb = (.+?)_(.+?)_(.+)\.u?deb$
SRE_Pattern re_issource = (.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.g...
SRE_Pattern re_multi_line_field = ^\s(.*)
SRE_Pattern re_no_epoch = ^\d+:
SRE_Pattern re_no_revision = -[^-]+$
SRE_Pattern re_parse_maintainer = ^\s*(\S.*\S)\s*<([^>]+)>
SRE_Pattern re_single_line_field = ^(\S*)\s*:\s*(.*)
SRE_Pattern re_srchasver = ^(\S+)\s+\((\S+)\)$
SRE_Pattern re_taint_free = ^[-\+~/\.\w]+$
SRE_Pattern re_verwithext = ^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$

Imported modules:
apt_pkg, codecs, commands, dak.daklib.database, email, os, pwd, re, select, shutil, socket, stat, sys, tempfile, time, traceback
Imported exceptions:
CantOpenError, CantOverwriteError, DakError, FileExistsError, InvalidDscError, NoFilesFieldError, NoFreeFilenameError, NoSourceFieldError, ParseChangesError, ParseMaintError, SendmailFailedError, TransitionsError, UnknownFormatError
Function Details

check_hash(where, files, hashname, hashfunc)

check_hash checks the given hash in the files dict against the actual files on disk. The hash values need to be present consistently in all file entries. It does not modify its input in any way.

check_hash_fields(what, manifest)

check_hash_fields ensures that there are no checksum fields in the given dict that we do not know about.

check_signature(sig_filename, reject, data_filename='', keyrings=None, autofetch=None)

Check the signature of a file and return the fingerprint if the signature is valid or 'None' if it's not. The first argument is the filename whose signature should be checked. The second argument is a reject function and is called when an error is found. The reject() function must allow for two arguments: the first is the error message, the second is an optional prefix string. It's possible for reject() to be called more than once during an invocation of check_signature(). The third argument is optional and is the name of the files the detached signature applies to. The fourth argument is optional and is a *list* of keyrings to use. 'autofetch' can either be None, True or False. If None, the default behaviour specified in the config will be used.

check_size(where, files)

check_size checks the file sizes in the passed files dict against the files on disk.

create_hash(where, files, hashname, hashfunc)

create_hash extends the passed files dict with the given hash by iterating over all files on disk and passing them to the hashing function given.

fix_maintainer(maintainer)

Parses a Maintainer or Changed-By field and returns:
  (1) an RFC822 compatible version,
  (2) an RFC2047 compatible version,
  (3) the name
  (4) the email

The name is forced to UTF-8 for both (1) and (3).  If the name field
contains '.' or ',' (as allowed by Debian policy), (1) and (2) are
switched to 'email (name)' format.

force_to_utf8(s)

Forces a string to UTF-8. If the string isn't already UTF-8, it's assumed to be ISO-8859-1.

gpg_get_key_addresses(fingerprint)

retreive email addresses from gpg key uids for a given fingerprint

parse_changes(filename, signing_rules=0)

Parses a changes 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:

 o If signing_rules == -1, no signature is required.
 o If signing_rules == 0 (the default), a signature is required.
 o If signing_rules == 1, it turns on the same strict format checking
   as dpkg-source.

The rules for (signing_rules == 1)-mode are:

  o The PGP header consists of "-----BEGIN PGP SIGNED MESSAGE-----"
    followed by any PGP header data and must end with a blank line.

  o The data section must end with a blank line and must be followed by
    "-----BEGIN PGP SIGNATURE-----".

retrieve_key(filename, keyserver=None, keyring=None)

Retrieve the key that signed 'filename' from 'keyserver' and add it to 'keyring'. Returns nothing on success, or an error message on error.

rfc2047_encode(s)

Encodes a (header) string per RFC2047 if necessary. If the string is neither ASCII nor UTF-8, it's assumed to be ISO-8859-1.

temp_filename(directory=None, prefix='dak', suffix='')

Return a secure and unique filename by pre-creating it. If 'directory' is non-null, it will be the directory the file is pre-created in. If 'prefix' is non-null, the filename will be prefixed with it, default is dak. If 'suffix' is non-null, the filename will end with it.

Returns a pair (fd, name).

validate_changes_file_arg(filename, require_changes=1)

'filename' is either a .changes or .dak file.  If 'filename' is a
.dak file, it's changed to be the corresponding .changes file.  The
function then checks if the .changes file a) exists and b) is
readable and returns the .changes filename if so.  If there's a
problem, the next action depends on the option 'require_changes'
argument:

 o If 'require_changes' == -1, errors are ignored and the .changes
                               filename is returned.
 o If 'require_changes' == 0, a warning is given and 'None' is returned.
 o If 'require_changes' == 1, a fatal error is raised.

Variable Details

alias_cache

Type:
NoneType
Value:
None                                                                  

Cnf

Type:
Configuration
Value:
<Configuration object at 0x7f5a6b212570>                               

default_apt_config

Type:
str
Value:
'/etc/dak/apt.conf'                                                    

default_config

Type:
str
Value:
'/etc/dak/dak.conf'                                                    

html_escaping

Type:
dict
Value:
{'>': '&gt;', '"': '&quot;', '<': '&lt;', '&': '&amp;'}                

key_uid_email_cache

Type:
dict
Value:
{}                                                                     

known_hashes

Type:
list
Value:
[('sha1', <built-in function sha1sum>, (1, 8)),
 ('sha256', <built-in function sha256sum>, (1, 8))]                    

re_arch_from_filename

Type:
SRE_Pattern
Value:
/binary-[^/]+/                                                         

re_comments

Type:
SRE_Pattern
Value:
#.*                                                                    

re_extract_src_version

Type:
SRE_Pattern
Value:
(\S+)\s*\((.*)\)                                                       

re_gpg_uid

Type:
SRE_Pattern
Value:
^uid.*<([^>]*)>                                                        

re_html_escaping

Type:
SRE_Pattern
Value:
[>"<&]                                                                 

re_isadeb

Type:
SRE_Pattern
Value:
(.+?)_(.+?)_(.+)\.u?deb$                                               

re_issource

Type:
SRE_Pattern
Value:
(.+)_(.+?)\.(orig\.tar\.gz|diff\.gz|tar\.gz|dsc)$                      

re_multi_line_field

Type:
SRE_Pattern
Value:
^\s(.*)                                                                

re_no_epoch

Type:
SRE_Pattern
Value:
^\d+:                                                                  

re_no_revision

Type:
SRE_Pattern
Value:
-[^-]+$                                                                

re_parse_maintainer

Type:
SRE_Pattern
Value:
^\s*(\S.*\S)\s*<([^>]+)>                                               

re_single_line_field

Type:
SRE_Pattern
Value:
^(\S*)\s*:\s*(.*)                                                      

re_srchasver

Type:
SRE_Pattern
Value:
^(\S+)\s+\((\S+)\)$                                                    

re_taint_free

Type:
SRE_Pattern
Value:
^[-\+~/\.\w]+$                                                         

re_verwithext

Type:
SRE_Pattern
Value:
^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$                                    

Generated by Epydoc 2.1 on Sat Jan 24 18:08:17 2009 http://epydoc.sf.net