Пример #1
0
    def exec_amend(self):
        try:
            subprocess.run(self.amend_cmd.split(),
                           check=True,
                           stdout=get_std(),
                           stderr=get_std())
        except subprocess.CalledProcessError:
            # fmt: off
            raise click.ClickException("""Cannot amend image {} to manifest.
Passing.""".format(self.qemu_registry_target))
Пример #2
0
 def exec_push_manifest(self):
     try:
         subprocess.run(
             self.push_manifest_cmd.split(),
             check=True,
             stdout=get_std(),
             stderr=get_std(),
         )
     except subprocess.CalledProcessError:
         raise click.ClickException("Cannot push manifest list to registry.")
Пример #3
0
    def login_registry():
        try:
            subprocess.run(["docker", "login"],
                           check=True,
                           stdout=get_std(),
                           stderr=get_std())
        except subprocess.CalledProcessError:
            # fmt: off
            raise click.ClickException("""Docker registry is not accessible.
Please login with `docker login` command.""")
Пример #4
0
    def exec_build(self):
        try:
            subprocess.run(self.build_cmd.split(),
                           check=True,
                           stdout=get_std(),
                           stderr=get_std())
        except subprocess.CalledProcessError:
            # fmt: off
            raise click.ClickException(
                """Cannot build image for architecture {}.
Passing.""".format(self.arch))
Пример #5
0
    def pull_qemu_image(self):
        try:
            subprocess.run(
                ["docker", "pull", self.qemu_image],
                check=True,
                stdout=get_std(),
                stderr=get_std(),
            )
        except subprocess.CalledProcessError:
            # fmt: off
            raise click.ClickException("""Cannot pull QEMU base image {}.
Passing.""".format(self.qemu_image))
Пример #6
0
 def check_manifest_cmd():
     try:
         subprocess.run(["docker", "manifest"],
                        check=True,
                        stdout=get_std(),
                        stderr=get_std())
     except subprocess.CalledProcessError:
         docker_config = "{}/{}".format(os.path.expanduser("~"),
                                        ".docker/config.json")
         with click.open_file(docker_config, "r+") as file:
             config = json.load(file)
             config.update({"experimental": "enabled"})
             file.seek(0)
             json.dump(config, file)
Пример #7
0
    def register_binfmt_misc():
        try:
            subprocess.run(
                [
                    "sudo",
                    "docker",
                    "run",
                    "--rm",
                    "--privileged",
                    "multiarch/qemu-user-static:register",
                ],
                check=True,
                stdout=get_std(),
                stderr=get_std(),
            )
        except subprocess.CalledProcessError:
            # fmt: off
            raise click.ClickException("""Could not register binfmt_misc.
Please register it with \
`sudo docker run --rm --privileged multiarch/qemu-user-static:register` command."""
                                       )