Пример #1
0
def _build_node(name: str, repo: str, commit: str):
    # This is responsible for creating a build/ directory and building in it

    cmd = "git clone {repo} --no-checkout build".format(**locals()).split()
    check_call(cmd)

    with cd("build"):
        cmd = "git checkout {commit}".format(**locals()).split()
        check_call(cmd)

        with cd("boss-ui"):  # TODO!!
            mybin = os.path.expanduser("~/bin")
            env = dict(os.environ, PATH=os.environ['PATH'] + ":" + mybin)
            check_call(["npm", "install"], env=env)
            check_call(["npm", "run", "build"], env=env)

            check_call(["rm", "-rf", "node_modules"])

            if os.path.isfile("post_build.sh"):
                subprocess.check_call(["./post_build.sh"])
Пример #2
0
def run_step(description: str, payload: str) -> str:
    decoded = b64decode(payload)
    msg = pickle.loads(decoded)
    method = getattr(functions, msg['method'])
    user = getpass.getuser()
    home = os.path.expanduser(f"~{user}")
    keys = ", ".join(msg['params'].keys())
    log(f" --- {description}: [ {msg['method']} ] as {user} ({keys})")
    with cd(home):
        result = method(**msg['params'])
        encoded = b64encode(pickle.dumps(result, 0)).decode()
        return encoded
Пример #3
0
def _get_zip_archive(url: str, digest: str):
    os.mkdir("build")
    with cd("build"):
        filename = fetch_archive(digest, url)

        check_call([
            "unzip",
            "-q",
            filename,
        ])

        os.unlink(filename)
Пример #4
0
def _build(name: str, repo: str, commit: str):
    # This is responsible for creating a build/ directory and building in it

    exe = find_program("git", "/usr/bin")

    def git(cmd):
        log(f"{exe} {cmd}")
        return check_call([exe] + cmd.split())

    git_home = os.path.expanduser("~/git")
    ensure_dir(git_home, 0o700)

    dst = repo.split("/")[-1]

    with cd(git_home):
        local_repo = os.path.abspath(dst)

        if not os.path.exists(dst):
            git(f"init -q --bare {dst}")
        with cd(dst):
            git("config --local uploadpack.allowreachablesha1inwant true")
            rc, existing_repo = subprocess.getstatusoutput(f"{exe} remote get-url origin")
            if rc != 0:
                git(f"remote add origin {repo}")
            elif existing_repo.strip() != repo:
                git(f"remote set-url origin {repo}")

            with timeit("remote fetch"):
                git("fetch")

    cmd = f"init -q build"
    git(cmd)

    with cd("build"):
        git(f"remote add origin {local_repo}")
        with timeit("local fetch"):
            git(f"fetch -q origin {commit} --depth 1")
        git(f"reset -q --hard {commit}")
        with timeit("build"):
            subprocess.check_call(f"./services/{name}/build.sh", stdout=sys.stderr)
Пример #5
0
def install_deb(url: str, digest: str, pkg_name: str, version: str) -> None:
    rc, output = subprocess.getstatusoutput(
        f"dpkg-query --show -f '${{Version}}' {pkg_name}")
    if rc == 0:
        have = output.strip()
        if have == version:
            return
        else:
            raise NotImplementedError(
                f"We don't support changing the version at the moment. Have={have} Want={version}"
            )

    with tempfile.TemporaryDirectory() as tmpdir:
        with cd(tmpdir):
            filename = build_utils.fetch_archive(digest, url)
            check(["apt-get", "install", "./" + filename],
                  env={"DEBIAN_FRONTEND": "noninteractive"})