def list_(cli): ch.dependencies_check() imgdir = ch.storage.unpack_base if (cli.image_ref is None): # list all images if (not os.path.isdir(ch.storage.root)): ch.INFO("does not exist: %s" % ch.storage.root) return if (not ch.storage.valid_p()): ch.INFO("not a storage directory: %s" % ch.storage.root) return imgs = ch.ossafe(os.listdir, "can't list directory: %s" % ch.storage.root, imgdir) for img in sorted(imgs): print(ch.Image_Ref(img)) else: # list specified image img = ch.Image(ch.Image_Ref(cli.image_ref)) print("details of image: %s" % img.ref) # present locally? if (not img.unpack_exist_p): stored = "no" else: img.metadata_load() stored = "yes (%s)" % img.metadata["arch"] print("in local storage: %s" % stored) # present remotely? print("full remote ref: %s" % img.ref.canonical) pullet = pull.Image_Puller(img, not cli.no_cache) pullet.fatman_load() if (pullet.architectures is not None): remote = "yes" arch_aware = "yes" arch_avail = " ".join(sorted(pullet.architectures.keys())) else: pullet.manifest_load(True) if (pullet.layer_hashes is not None): remote = "yes" arch_aware = "no" arch_avail = "unknown" else: remote = "no" arch_aware = "n/a" arch_avail = "n/a" pullet.done() print("available remotely: %s" % remote) print("remote arch-aware: %s" % arch_aware) print("host architecture: %s" % ch.arch_host) print("archs available: %s" % arch_avail)
def execute_(self): # Complain about unsupported stuff. if (self.options.pop("platform", False)): self.unsupported_yet_fatal("--platform", 778) # Any remaining options are invalid. self.options_assert_empty() # Update image globals. global image_i image_i += 1 global image_alias image_alias = self.alias if (image_i == image_ct - 1): # Last image; use tag unchanged. tag = cli.tag elif (image_i > image_ct - 1): # Too many images! ch.FATAL("expected %d stages but found at least %d" % (image_ct, image_i + 1)) else: # Not last image; append stage index to tag. tag = "%s/_stage%d" % (cli.tag, image_i) image = ch.Image(ch.Image_Ref(tag)) images[image_i] = image if (self.alias is not None): images[self.alias] = image ch.VERBOSE("image path: %s" % image.unpack_path) # Other error checking. if (str(image.ref) == str(self.base_ref)): ch.FATAL("output image ref same as FROM: %s" % self.base_ref) # Initialize image. self.base_image = ch.Image(self.base_ref) if (os.path.isdir(self.base_image.unpack_path)): ch.VERBOSE("base image found: %s" % self.base_image.unpack_path) else: ch.VERBOSE("base image not found, pulling") # a young hen, especially one less than one year old. pullet = pull.Image_Puller(self.base_image, not cli.no_cache) pullet.pull_to_unpacked() pullet.done() image.copy_unpacked(self.base_image) image.metadata_load() env.reset() # Find fakeroot configuration, if any. global fakeroot_config fakeroot_config = fakeroot.detect(image.unpack_path, cli.force, cli.no_force_detect)