コード例 #1
0
    def run(self, args: argparse.Namespace) -> None:
        repo = mzbuild.Repository.from_arguments(ROOT, args)
        template = """#!/usr/bin/env bash

# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
#
# mzcompose — runs Docker Compose with Materialize customizations.

exec "$(dirname "$0")/{}/bin/mzcompose" "$@"
"""
        for path in repo.compositions.values():
            mzcompose_path = path / "mzcompose"
            with open(mzcompose_path, "w") as f:
                f.write(template.format(os.path.relpath(repo.root, path)))
            mzbuild.chmod_x(mzcompose_path)
コード例 #2
0
def gen_shortcuts(repo: mzbuild.Repository) -> int:
    template = """#!/usr/bin/env bash

# Copyright Materialize, Inc. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
#
# mzcompose — runs Docker Compose with Materialize customizations.

exec "$(dirname "$0")/{}/bin/mzcompose" "$@"
"""
    for path in repo.compose_dirs:
        mzcompose_path = path / "mzcompose"
        with open(mzcompose_path, "w") as f:
            f.write(template.format(os.path.relpath(repo.root, path)))
        mzbuild.chmod_x(mzcompose_path)
    return 0
コード例 #3
0
def acquire_materialized(repo: mzbuild.Repository, out: Path) -> None:
    """Acquire a Linux materialized binary from the materialized Docker image.

    This avoids an expensive rebuild if a Docker image is available from Docker
    Hub.
    """
    deps = repo.resolve_dependencies([repo.images["materialized"]])
    deps.acquire()
    out.parent.mkdir(parents=True, exist_ok=True)
    with open(out, "wb") as f:
        spawn.runv(
            [
                "docker",
                "run",
                "--rm",
                "--entrypoint",
                "cat",
                deps["materialized"].spec(),
                "/usr/local/bin/materialized",
            ],
            stdout=f,
        )
    mzbuild.chmod_x(out)