@@ -826,3 +826,101 @@ def test_manifest_customization_custom_file_smoke(tmp_path, build_container):
826826 '[{"path":"/etc/custom_dir","exist_ok":true}]},'
827827 '"devices":{"disk":{"type":"org.osbuild.loopback"'
828828 ',"options":{"filename":"disk.raw"' ) in output
829+
830+
831+
832+ def find_sfdisk_stage_from (manifest_str ):
833+ manifest = json .loads (manifest_str )
834+ for pipl in manifest ["pipelines" ]:
835+ if pipl ["name" ] == "image" :
836+ for st in pipl ["stages" ]:
837+ if st ["type" ] == "org.osbuild.sfdisk" :
838+ return st ["options" ]
839+ raise ValueError (f"cannot find sfdisk stage manifest:\n { manifest_str } " )
840+
841+ def test_manifest_image_customize_filesystem (tmp_path , build_container ):
842+ # no need to parameterize this test, overrides behaves same for all containers
843+ container_ref = "quay.io/centos-bootc/centos-bootc:stream9"
844+ testutil .pull_container (container_ref )
845+
846+ cfg = {
847+ "blueprint" : {
848+ "customizations" : {
849+ "filesystem" : [
850+ {
851+ "mountpoint" : "/boot" ,
852+ "minsize" : "3GiB"
853+ }
854+ ]
855+ },
856+ },
857+ }
858+
859+ config_json_path = tmp_path / "config.json"
860+ config_json_path .write_text (json .dumps (cfg ), encoding = "utf-8" )
861+
862+ # create derrived container with filesystem customization
863+ cntf_path = tmp_path / "Containerfile"
864+ cntf_path .write_text (textwrap .dedent (f"""\n
865+ FROM { container_ref }
866+ RUN mkdir -p -m 0755 /usr/lib/bootc-image-builder
867+ COPY config.json /usr/lib/bootc-image-builder/
868+ """ ), encoding = "utf8" )
869+
870+ print (f"building filesystem customize container from { container_ref } " )
871+ with make_container (tmp_path ) as container_tag :
872+ print (f"using { container_tag } " )
873+ manifest_str = subprocess .check_output ([
874+ * testutil .podman_run_common ,
875+ build_container ,
876+ "manifest" ,
877+ f"localhost/{ container_tag } " ,
878+ ], encoding = "utf8" )
879+ sfdisk_options = find_sfdisk_stage_from (manifest_str )
880+ assert sfdisk_options ["partitions" ][2 ]["size" ] == 3 * 1024 * 1024 * 1024 / 512
881+
882+
883+ def test_manifest_image_customize_disk (tmp_path , build_container ):
884+ # no need to parameterize this test, overrides behaves same for all containers
885+ container_ref = "quay.io/centos-bootc/centos-bootc:stream9"
886+ testutil .pull_container (container_ref )
887+
888+ cfg = {
889+ "blueprint" : {
890+ "customizations" : {
891+ "disk" : {
892+ "partitions" : [
893+ {
894+ "label" : "var" ,
895+ "mountpoint" : "/var" ,
896+ "fs_type" : "ext4" ,
897+ "minsize" : "3 GiB" ,
898+ },
899+ ],
900+ },
901+ },
902+ },
903+ }
904+
905+ config_json_path = tmp_path / "config.json"
906+ config_json_path .write_text (json .dumps (cfg ), encoding = "utf-8" )
907+
908+ # create derrived container with disk customization
909+ cntf_path = tmp_path / "Containerfile"
910+ cntf_path .write_text (textwrap .dedent (f"""\n
911+ FROM { container_ref }
912+ RUN mkdir -p -m 0755 /usr/lib/bootc-image-builder
913+ COPY config.json /usr/lib/bootc-image-builder/
914+ """ ), encoding = "utf8" )
915+
916+ print (f"building filesystem customize container from { container_ref } " )
917+ with make_container (tmp_path ) as container_tag :
918+ print (f"using { container_tag } " )
919+ manifest_str = subprocess .check_output ([
920+ * testutil .podman_run_common ,
921+ build_container ,
922+ "manifest" ,
923+ f"localhost/{ container_tag } " ,
924+ ], encoding = "utf8" )
925+ sfdisk_options = find_sfdisk_stage_from (manifest_str )
926+ assert sfdisk_options ["partitions" ][2 ]["size" ] == 3 * 1024 * 1024 * 1024 / 512
0 commit comments