sign_android
index
/home/aki/wrk/git-mozharness-ro/scripts/sign_android.py

sign_android.py

 
Modules
       
os
sys

 
Classes
       
mozharness.base.transfer.TransferMixin(__builtin__.object)
SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)
mozharness.base.vcs.vcsbase.MercurialScript(mozharness.base.vcs.vcsbase.VCSScript)
SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)
mozharness.mozilla.l10n.locales.LocalesMixin(mozharness.base.parallel.ChunkingMixin)
SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)
mozharness.mozilla.release.ReleaseMixin
SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)
mozharness.mozilla.signing.MobileSigningMixin(mozharness.base.signing.AndroidSigningMixin, mozharness.mozilla.signing.SigningMixin)
SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)

 
class SignAndroid(mozharness.mozilla.l10n.locales.LocalesMixin, mozharness.mozilla.release.ReleaseMixin, mozharness.mozilla.signing.MobileSigningMixin, mozharness.base.transfer.TransferMixin, mozharness.base.vcs.vcsbase.MercurialScript)
    SignAndroid {{{1
 
 
Method resolution order:
SignAndroid
mozharness.mozilla.l10n.locales.LocalesMixin
mozharness.base.parallel.ChunkingMixin
mozharness.mozilla.release.ReleaseMixin
mozharness.mozilla.signing.MobileSigningMixin
mozharness.base.signing.AndroidSigningMixin
mozharness.mozilla.signing.SigningMixin
mozharness.base.signing.BaseSigningMixin
mozharness.base.transfer.TransferMixin
mozharness.base.vcs.vcsbase.MercurialScript
mozharness.base.vcs.vcsbase.VCSScript
mozharness.base.vcs.vcsbase.VCSMixin
mozharness.base.script.BaseScript
mozharness.base.script.ShellMixin
mozharness.base.script.OSMixin
mozharness.base.log.LogMixin
__builtin__.object

Methods defined here:
__init__(self, require_config_file=True)
add_failure(self, platform, locale, **kwargs)
create_snippets(self)
download_unsigned_bits(self)
preflight_sign(self)
pull(self)
query_buildid(self, platform, base_url, buildnum=None, version=None)
# Helper methods {{{2
query_failure(self, platform, locale)
sign(self)
upload_signed_bits(self)
upload_snippets(self)
verify_signatures(self)

Data and other attributes defined here:
config_options = [[['--locale'], {'action': 'extend', 'dest': 'locales', 'help': 'Specify the locale(s) to sign and update', 'type': 'string'}], [['--locales-file'], {'action': 'store', 'dest': 'locales_file', 'help': 'Specify a json file to determine which locales to sign and update', 'type': 'string'}], [['--tag-override'], {'action': 'store', 'dest': 'tag_override', 'help': 'Override the tags set for all repos', 'type': 'string'}], [['--platform'], {'action': 'extend', 'choices': ['android', 'android-xul'], 'dest': 'platforms', 'help': 'Specify the platform(s) to sign', 'type': 'choice'}], [['--user-repo-override'], {'action': 'store', 'dest': 'user_repo_override', 'help': 'Override the user repo path for all repos', 'type': 'string'}], [['--key-alias'], {'action': 'store', 'choices': ['production', 'nightly'], 'dest': 'key_alias', 'help': 'Specify the key alias', 'type': 'choice'}], [['--update-platform'], {'action': 'extend', 'choices': ['android', 'android-xul'], 'dest': 'update_platforms', 'help': 'Specify the platform(s) to create update snippets for', 'type': 'choice'}], [['--release-config-file'], {'action': 'store', 'dest': 'release_config_file', 'help': 'Specify the release config file to use', 'type': 'string'}], [['--version'], {'action': 'store', 'dest': 'version', 'help': 'Specify the current version', 'type': 'string'}], [['--old-version'], {'action': 'store', 'dest': 'old_version', 'help': 'Specify the version to update from', 'type': 'string'}], [['--buildnum'], {'action': 'store', 'default': 1, 'dest': 'buildnum', 'help': 'Specify the current release build num (e.g. build1, build2)', 'metavar': 'INT', 'type': 'int'}], [['--old-buildnum'], {'action': 'store', 'default': 1, 'dest': 'old_buildnum', 'help': 'Specify the release build num to update from (e.g. build1, build2)', 'metavar': 'INT', 'type': 'int'}], [['--keystore'], {'action': 'store', 'dest': 'keystore', 'help': 'Specify the location of the signing keystore', 'type': 'string'}], [['--with-partner-repacks'], {'action': 'store_true', 'default': False, 'dest': 'enable_partner_repacks', 'help': 'Download, sign, and verify partner repacks as well.'}]]

Methods inherited from mozharness.mozilla.l10n.locales.LocalesMixin:
list_locales(self)
Stub action method.
parse_locales_file(self, locales_file)
pull_locale_source(self)
# This requires self to inherit a VCSMixin.
query_abs_dirs(self)
query_locales(self)
run_compare_locales(self, locale, halt_on_failure=False)

Methods inherited from mozharness.base.parallel.ChunkingMixin:
query_chunked_list(self, possible_list, this_chunk, total_chunks, sort=False)
Split a list of items into a certain number of chunks and
return the subset of that will occur in this chunk.
 
Ported from build.l10n.getLocalesForChunk in build/tools.

Data descriptors inherited from mozharness.base.parallel.ChunkingMixin:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Methods inherited from mozharness.mozilla.release.ReleaseMixin:
query_release_config(self)

Data and other attributes inherited from mozharness.mozilla.release.ReleaseMixin:
release_config = {}

Methods inherited from mozharness.mozilla.signing.MobileSigningMixin:
verify_android_signature(self, apk, script=None, key_alias='nightly', tools_dir='tools/', env=None)
Runs mjessome's android signature verification script.
This currently doesn't check to see if the apk exists; you may want
to do that before calling the method.

Methods inherited from mozharness.base.signing.AndroidSigningMixin:
align_apk(self, unaligned_apk, aligned_apk, error_level='error')
Zipalign apk.
Returns None on success, not None on failure.
passphrase(self)
postflight_passphrase(self)
sign_apk(self, apk, keystore, storepass, keypass, key_alias, remove_signature=True, error_list=None, log_level='info', error_level='error')
Signs an apk with jarsigner.
unsign_apk(self, apk, **kwargs)
verify_passphrases(self)

Data and other attributes inherited from mozharness.base.signing.AndroidSigningMixin:
key_passphrase = None
store_passphrase = None

Methods inherited from mozharness.mozilla.signing.SigningMixin:
create_complete_snippet(self, binary_path, version, buildid, url, snippet_dir, snippet_file='complete.txt', size=None, sha512_hash=None, error_level='error')
Create a complete snippet, and writes to file.
Returns True for success, False for failure.

Methods inherited from mozharness.base.signing.BaseSigningMixin:
query_filesize(self, file_path)
query_sha512sum(self, file_path)
# TODO this should be parallelized with the to-be-written BaseHelper!

Methods inherited from mozharness.base.transfer.TransferMixin:
rsync_download_directory(self, ssh_key, ssh_user, remote_host, remote_path, local_path, rsync_options=None, error_level='error')
Create a remote directory and upload the contents of
a local directory to it via rsync+ssh.
 
Return None on success, not None on failure.
rsync_upload_directory(self, local_path, ssh_key, ssh_user, remote_host, remote_path, rsync_options=None, error_level='error', create_remote_directory=True)
Create a remote directory and upload the contents of
a local directory to it via rsync+ssh.
 
Return None on success, not None on failure.

Data and other attributes inherited from mozharness.base.vcs.vcsbase.MercurialScript:
default_vcs = 'hg'

Methods inherited from mozharness.base.vcs.vcsbase.VCSMixin:
vcs_checkout(self, vcs=None, **kwargs)
Check out a single repo.
vcs_checkout_repos(self, repo_list, parent_dir=None, tag_override=None, **kwargs)
Check out a list of repos.

Methods inherited from mozharness.base.script.BaseScript:
action_message(self, message)
add_summary(self, message, level='info')
clobber(self)
Delete the working directory
copy_to_upload_dir(self, target, dest=None, short_desc='unknown', long_desc='unknown', log_level='debug', error_level='error', rotate=False, max_backups=None)
Copy target file to upload_dir/dest.
 
Potentially update a manifest in the future if we go that route.
 
Currently only copies a single file; would be nice to allow for
recursive copying; that would probably done by creating a helper
_copy_file_to_upload_dir().
 
short_desc and long_desc are placeholders for if/when we add
upload_dir manifests.
dump_config(self, file_path=None)
Dump self.config to localconfig.json
new_log_obj(self, default_log_level='info')
# logging {{{2
run(self)
Default run method.
This is the "do everything" method, based on actions and all_actions.
 
First run dump_config() if it exists.
Second, go through the list of all_actions.
If they're in the list of self.actions, try to run
preflight_ACTION(), ACTION(), and postflight_ACTION().
 
Preflight is sanity checking before doing anything time consuming or
destructive.
 
Postflight is quick testing for success after an action.
 
Run summary() at the end.
summarize_success_count(self, success_count, total_count, message='%d of %d successful.')
summary(self)
Print out all the summary lines added via add_summary()
throughout the script.
 
I'd like to revisit how to do this in a prettier fashion.

Methods inherited from mozharness.base.script.ShellMixin:
get_output_from_command(self, command, cwd=None, halt_on_failure=False, env=None, silent=False, log_level='info', tmpfile_base_path='tmpfile', return_type='output', save_tmpfiles=False, throw_exception=False)
Similar to run_command, but where run_command is an
os.system(command) analog, get_output_from_command is a `command`
analog.
 
Less error checking by design, though if we figure out how to
do it without borking the output, great.
 
TODO: binary mode? silent is kinda like that.
TODO: since p.wait() can take a long time, optionally log something
every N seconds?
TODO: optionally only keep the first or last (N) line(s) of output?
TODO: optionally only return the tmp_stdout_filename?
query_env(self, partial_env=None, replace_dict=None, set_self_env=None)
Environment query/generation method.
 
The default, query_env(), will look for self.config['env']
and replace any special strings in there ( %(PATH)s ).
It will then store it as self.env for speeding things up later.
 
If you specify partial_env, partial_env will be used instead of
self.config['env'], and we don't save self.env as it's a one-off.
query_exe(self, exe_name, exe_dict='exes', default=None, return_type=None, error_level='fatal')
One way to work around PATH rewrites.
 
By default, return exe_name, and we'll fall through to searching
os.environ["PATH"].
However, if self.config[exe_dict][exe_name] exists, return that.
This lets us override exe paths via config file.
 
'return_type' can be None (don't do anything to the value),
'list' (return a list), or 'string' (return a string).
 
If we need runtime setting, we can build in self.exes support later.
run_command(self, command, cwd=None, error_list=None, parse_at_end=False, halt_on_failure=False, success_codes=None, env=None, return_type='status', throw_exception=False)
Run a command, with logging and error parsing.
 
TODO: parse_at_end, context_lines
TODO: retry_interval?
TODO: error_level_override?
TODO: Add a copy-pastable version of |command| if it's a list.
TODO: print env if set
 
error_list example:
[{'regex': re.compile('^Error: LOL J/K'), level=IGNORE},
 {'regex': re.compile('^Error:'), level=ERROR, contextLines='5:5'},
 {'substr': 'THE WORLD IS ENDING', level=FATAL, contextLines='20:'}
]
(context_lines isn't written yet)

Methods inherited from mozharness.base.script.OSMixin:
chdir(self, dir_name, ignore_if_noop=False)
chmod(self, path, mode)
copyfile(self, src, dest, log_level='info', error_level='error')
download_file(self, url, file_name=None, parent_dir=None, create_parent_dir=True, error_level='error', exit_code=-1)
Python wget.
TODO: should noop touch the filename? seems counter-noop.
TODO: the initial log line should say "Downloading url to file_name"
get_filename_from_url(self, url)
mkdir_p(self, path, error_level='error')
Returns None for success, not None for failure
move(self, src, dest, log_level='info', error_level='error', exit_code=-1)
read_from_file(self, file_path, verbose=True, open_mode='r', error_level='error')
Reads from file_path.
 
Returns contents if successful, None if not.
rmtree(self, path, log_level='info', error_level='error', exit_code=-1)
Returns None for success, not None for failure
which(self, program)
OS independent implementation of Unix's which command
Takes in a program name
Returns path to executable or None
write_to_file(self, file_path, contents, verbose=True, open_mode='w', create_parent_dir=False, error_level='error')
Write contents to file_path.
 
This doesn't currently create the parent_dir or translate into
abs_path; that needs to be done beforehand, since OSMixin doesn't
necessarily have access to query_abs_dirs().
 
Returns file_path if successful, None if not.

Methods inherited from mozharness.base.log.LogMixin:
critical(self, message)
debug(self, message)
dump_exception(self, message=None, level='error')
# Copying Bear's dumpException():
http://hg.mozilla.org/build/tools/annotate/1485f23c38e0/sut_tools/sut_lib.py#l23
error(self, message)
fatal(self, message, exit_code=-1)
info(self, message)
log(self, message, level='info', exit_code=-1)
warning(self, message)

 
Data
        BaseErrorList = [{'level': 'error', 'substr': 'command not found'}]
ERROR = 'error'
FATAL = 'fatal'
SUPPORTED_PLATFORMS = ['android', 'android-xul']