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))
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.")
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.""")
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))
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))
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)
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.""" )