diff --git a/launch b/launch index d3fc72df917bce1db92366594579f9f662952d6e_bGF1bmNo..6551366079c04edcace588a44a1279bcf53ae7f2_bGF1bmNo 100755 --- a/launch +++ b/launch @@ -98,85 +98,6 @@ return res -def prefetch_component_sources(slug, rev_info, shares_dir, simulate=False): - repo_path = os.path.join(SOURCES_DIR, slug) - pull_branch = rev_info.get('pull_branch') - pull_revision = rev_info.get('pull_revision') - target_rev = rev_info['revision'] - pull_opts = [] - if pull_branch: - pull_opts.extend(('-b', pull_branch)) - if pull_revision: - pull_opts.extend(('-r', pull_revision)) - remote = rev_info['remote'] - - if os.path.isdir(repo_path): - sha = hg_rev_sha(repo_path, target_rev) - if sha is None: - cmd = ['hg', 'pull', '-R', repo_path, remote] - cmd.extend(pull_opts) - print("Pull for existing repository: %r" % cmd) - else: - print("Revision %r found in existing repository at %r as %r" % ( - target_rev, repo_path, sha)) - return repo_path, sha - else: - cmd = ['hg'] - if shares_dir is None: - cmd.extend(('clone', remote, '--noupdate')) - cmd.extend(pull_opts) - else: - cmd.extend(('share', '--noupdate', os.path.join(shares_dir, slug))) - cmd.append(repo_path) - print("Initializing repository: %r" % cmd) - - if not simulate: - subprocess.check_call(cmd) - return repo_path, None - - subprocess.check_call(cmd) - sha = hg_rev_sha(repo_path, target_rev) - return repo_path, hg_rev_sha(repo_path, target_rev, fail=not simulate) - - -def prepare_sources(context_dir, revisions, shares_dir, simulate=False): - for component, slug in PREFETCH_SOURCES.items(): - revision = revisions.get(component) - if revision is None: - # not specified in revisions, means not to be built - # (typically a dev image using the same version of the component - # as the base image - print("Prepare sources: skipping %r: " - "no revision specified" % component) - continue - src_path, sha = prefetch_component_sources( - slug, revision, shares_dir, - simulate=simulate) - tarball = os.path.join(context_dir, slug + '.tar') - if os.path.exists(tarball): - if sha is not None: # can be None without error in simulate mode - archive_md = inspect_archive(tarball) - tar_sha = archive_md['node'] - if tar_sha == sha: - print("Reusing existing tarball at %r. " - "Archival metadata: %r" % ( - tarball, archive_md)) - continue - else: - print("Remove stale tarball at %r " - "with archival metadada: %r " % ( - tarball, archive_md)) - if not simulate: - os.unlink(tarball) - cmd = ['hg', '-R', src_path, 'archive', - '-t', 'tar', - '-p', '.', - tarball, - '-r', revision['revision']] - print("Prepare sources for %s: %r" % (component, cmd)) - if not simulate: - subprocess.check_call(cmd) - def docker_build_args(py_version): python = 'python' if py_version == '2' else 'omnibus' return ('--build-arg', 'heptapod_python=' + python) @@ -187,59 +108,6 @@ return '%s-py%s' % (full_tag, py_version) -def build_image(full_tag, context_dir, py_version, - simulate=False, - no_cache=False, squash=False, - shares_dir=None, - msg="Docker build command"): - """Build the image from `context_dir` and tag it. - - `full_tag` is actually the full name of the image, with the tag part. - Examples: `octobus/heptapod:testing` - """ - raise NotImplementedError("As of Heptapod 0.17.0, local building does " - "not make sense any more") - - -def retag_partial_image(full_tag, - simulate=False, - pull=False, - py_version='3'): - msg = "Docker partial image retag command" - partial_image_tag = read_docker_file_from_field( - os.path.join(DOCKER_BASE_CONTEXT_DIR, 'Dockerfile'), - image_tag_rx=r'heptapod/partial:.*?') - if pull: - cmd = ['docker', 'pull', partial_image_tag] - print("%s: %r" % (msg, cmd)) - if not simulate: - subprocess.check_call(cmd) - - py_version_tag = py_version_image_tag(full_tag, py_version) - cmd = ('docker', 'tag', partial_image_tag, py_version_tag) - print("%s: %r" % (msg, cmd)) - if not simulate: - subprocess.check_call(cmd) - - if py_version == DEFAULT_PYTHON_VERSION: - cmd = ('docker', 'tag', py_version_tag, full_tag) - print("%s: %r" % (msg, cmd)) - if not simulate: - subprocess.check_call(cmd) - - -def push_image(full_tag, simulate=False): - """Push image to Docker Hub. - - `full_tag` is as in `build_image()`. - """ - cmd = ('docker', 'push', full_tag) - print("Docker push command: %r" % (cmd, )) - if not simulate: - subprocess.check_call(cmd) - print() - - def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, @@ -248,13 +116,6 @@ parser.add_argument('-s', '--simulate', action='store_true', help="Output configuration instead of " "executing commands") - parser.add_argument('--src-shares-dir', - help="Use `hg share` from the given directory " - "instead of `hg clone` to init the source " - "repositories that are maintained outside of the " - "build container. The slug is expected to be the " - "same as on foss.h.n, i.e., `heptapod-workhorse` etc." - ) vol_group = parser.add_argument_group("Docker volumes options") vol_group.add_argument('--volumes-dir', default=default_volumes_dir(), @@ -350,8 +211,6 @@ )) print_header("Commands") - shares_dir = parsed_args.src_shares_dir - if not do_run: return