diff --git a/ogscm/app/builder.py b/ogscm/app/builder.py index 1a93e35eca48f80cd6be77e4b0ee47743b83f0e7..361bc754acb0a3007bd1cec6852b75d7b6c70c09 100644 --- a/ogscm/app/builder.py +++ b/ogscm/app/builder.py @@ -51,14 +51,24 @@ class builder(object): if self.__args.upload: subprocess.run(f"docker push {self.__tag}", shell=True) + image_base_name = f"{self.__images_out_dir}/{self.__img_file}-{image_id_short}" if self.__args.sif_file: self.image_file = f"{self.__images_out_dir}/{self.__args.sif_file}" else: - self.image_file = ( - f"{self.__images_out_dir}/{self.__img_file}-{image_id_short}.sif" - ) + self.image_file = f"{image_base_name}.sif" if self.__args.convert and not os.path.exists(self.image_file): subprocess.run( f"cd {self.__cwd} && singularity build --force {self.image_file} docker-daemon:{self.__tag}", shell=True, ) + + if self.__args.enroot_file: + self.image_file = f"{self.__images_out_dir}/{self.__args.enroot_file}" + else: + self.image_file = f"{image_base_name}.sqsh" + if self.__args.convert_enroot and not os.path.exists(self.image_file): + subprocess.run( + f"cd {self.__cwd} && ENROOT_SQUASH_OPTIONS='-comp lz4 -noD' enroot import -o {self.image_file} dockerd://{self.__tag}", + shell=True, + ) + print(f"Wrote image file {self.image_file}") diff --git a/ogscm/cli.py b/ogscm/cli.py index cb05e22bbe352563ee9e69b74ec0f7da7baa0f25..65fdbe5b7d3a6829eeeda29022c38555c9e2a732 100644 --- a/ogscm/cli.py +++ b/ogscm/cli.py @@ -44,6 +44,12 @@ def main(): # pragma: no cover default="", help="Overwrite output singularity image file name", ) + parser.add_argument( + "--enroot_file", + type=str, + default="", + help="Overwrite output enroot image file name", + ) parser.add_argument( "--print", "-P", @@ -103,6 +109,13 @@ def main(): # pragma: no cover action="store_true", help="Convert Docker image to Singularity image", ) + build_g.add_argument( + "--convert-enroot", + "-E", + dest="convert_enroot", + action="store_true", + help="Convert Docker image to enroot image", + ) build_g.add_argument( "--runtime-only", "-R",