def release(): """ Bump version and run clean,freeze,...,upload """ require_existing_project() version = SETTINGS['version'] next_version = _get_next_version(version) release_version = prompt_for_value('Release version', default=next_version) activate_profile('release') SETTINGS['version'] = release_version log_level = _LOG.level if log_level == logging.NOTSET: _LOG.setLevel(logging.WARNING) try: clean() freeze() installer() sign_installer() repo() finally: _LOG.setLevel(log_level) upload() base_json = 'src/build/settings/base.json' update_json(path(base_json), {'version': release_version}) _LOG.info('Also, %s was updated with the new version.', base_json)
def release(version=None): """ Bump version and run clean,freeze,...,upload """ require_existing_project() if version is None: curr_version = SETTINGS['version'] next_version = _get_next_version(curr_version) release_version = prompt_for_value('Release version', default=next_version) elif version == 'current': release_version = SETTINGS['version'] else: release_version = version activate_profile('release') SETTINGS['version'] = release_version log_level = _LOG.level if log_level == logging.NOTSET: _LOG.setLevel(logging.WARNING) try: clean() freeze() if is_windows() and _has_windows_codesigning_certificate(): sign() installer() if (is_windows() and _has_windows_codesigning_certificate()) or \ is_arch_linux() or is_fedora(): sign_installer() repo() finally: _LOG.setLevel(log_level) upload() base_json = 'src/build/settings/base.json' update_json(path(base_json), {'version': release_version}) _LOG.info('Also, %s was updated with the new version.', base_json)
def init_licensing(): """ Generate public/private keys for licensing """ require_existing_project() try: import rsa except ImportError: _LOG.error('Please install Python library `rsa`. Eg. via:\n' ' pip install rsa') return nbits = _prompt_for_nbits() print('') pubkey, privkey = rsa.newkeys(nbits) pubkey_args = {'n': pubkey.n, 'e': pubkey.e} privkey_args = { attr: getattr(privkey, attr) for attr in ('n', 'e', 'd', 'p', 'q') } update_json(path(SECRET_JSON), { 'licensing_privkey': privkey_args, 'licensing_pubkey': pubkey_args }) try: with open(path(BASE_JSON)) as f: user_base_settings = json.load(f) except FileNotFoundError: user_base_settings = {} public_settings = user_base_settings.get('public_settings', []) if 'licensing_pubkey' not in public_settings: public_settings.append('licensing_pubkey') update_json(path(BASE_JSON), {'public_settings': public_settings}) updated_base_json = True else: updated_base_json = False message = 'Saved a public/private key pair for licensing to:\n %s.\n' \ % SECRET_JSON if updated_base_json: message += 'Also added "licensing_pubkey" to "public_settings" in' \ '\n %s.\n' \ '(This lets your app read the public key when it runs.)\n' \ % BASE_JSON message += '\nFor details on how to implement licensing for your ' \ 'application, see:\n '\ ' https://build-system.fman.io/manual#licensing.' _LOG.info(message)
def gengpgkey(): """ Generate a GPG key for Linux code signing """ require_existing_project() if exists(_DEST_DIR): raise FbsError('The %s folder already exists. Aborting.' % _DEST_DIR) try: email = prompt_for_value('Email address') name = prompt_for_value('Real name', default=SETTINGS['author']) passphrase = prompt_for_value('Key password', password=True) except KeyboardInterrupt: print('') return print('') _LOG.info('Generating the GPG key. This can take a little...') _init_docker() args = ['run', '-t'] if exists('/dev/urandom'): # Give the key generator more entropy on Posix: args.extend(['-v', '/dev/urandom:/dev/random']) args.extend([_DOCKER_IMAGE, '/root/genkey.sh', name, email, passphrase]) result = _run_docker(args, check=True, stdout=PIPE, universal_newlines=True) key = _snip( result.stdout, "revocation certificate stored as '/root/.gnupg/openpgp-revocs.d/", ".rev'", include_bounds=False) pubkey = _snip(result.stdout, '-----BEGIN PGP PUBLIC KEY BLOCK-----\n', '-----END PGP PUBLIC KEY BLOCK-----\n') privkey = _snip(result.stdout, '-----BEGIN PGP PRIVATE KEY BLOCK-----\n', '-----END PGP PRIVATE KEY BLOCK-----\n') makedirs(path(_DEST_DIR), exist_ok=True) pubkey_dest = _DEST_DIR + '/' + _PUBKEY_NAME Path(path(pubkey_dest)).write_text(pubkey) Path(path(_DEST_DIR + '/' + _PRIVKEY_NAME)).write_text(privkey) update_json(path(BASE_JSON), {'gpg_key': key, 'gpg_name': name}) update_json(path(SECRET_JSON), {'gpg_pass': passphrase}) _LOG.info( 'Done. Created %s and ...%s. Also updated %s and ...secret.json with ' 'the values you provided.', pubkey_dest, _PRIVKEY_NAME, BASE_JSON)
def release(version=None): """ Bump version and run clean,freeze,...,upload """ require_existing_project() if version is None: curr_version = SETTINGS['version'] next_version = _get_next_version(curr_version) release_version = prompt_for_value('Release version', default=next_version) elif version == 'current': release_version = SETTINGS['version'] else: release_version = version if not is_valid_version(release_version): if not is_valid_version(version): raise FbsError( 'The release version of your app is invalid. It should be ' 'three\nnumbers separated by dots, such as "1.2.3". ' 'You have: "%s".' % release_version) activate_profile('release') SETTINGS['version'] = release_version log_level = _LOG.level if log_level == logging.NOTSET: _LOG.setLevel(logging.WARNING) try: clean() freeze() if is_windows() and _has_windows_codesigning_certificate(): sign() installer() if (is_windows() and _has_windows_codesigning_certificate()) or \ is_arch_linux() or is_fedora(): sign_installer() if _repo_is_supported(): repo() finally: _LOG.setLevel(log_level) upload() base_json = 'src/build/settings/base.json' update_json(path(base_json), {'version': release_version}) _LOG.info('Also, %s was updated with the new version.', base_json)
def _login(username, password): update_json(path(SECRET_JSON), { 'fbs_user': username, 'fbs_pass': password }) _LOG.info('Saved your username and password to %s.', SECRET_JSON)