|
| 1 | +# pylint: disable=too-many-lines |
| 2 | + |
1 | 3 | import base64
|
2 | 4 | import hashlib
|
3 | 5 | import json
|
@@ -651,7 +653,7 @@ def test_manifest_disk_customization_dos(tmp_path, build_container):
|
651 | 653 | build_container,
|
652 | 654 | "manifest", f"{container_ref}",
|
653 | 655 | ])
|
654 |
| - st = find_sfdisk_stage_from(output) |
| 656 | + st = find_stage_options_from(output, "org.osbuild.sfdisk") |
655 | 657 | assert st["label"] == "dos"
|
656 | 658 |
|
657 | 659 |
|
@@ -852,14 +854,14 @@ def test_manifest_customization_custom_file_smoke(tmp_path, build_container):
|
852 | 854 | ',"options":{"filename":"disk.raw"') in output
|
853 | 855 |
|
854 | 856 |
|
855 |
| -def find_sfdisk_stage_from(manifest_str): |
| 857 | +def find_stage_options_from(manifest_str, stage_type): |
856 | 858 | manifest = json.loads(manifest_str)
|
857 | 859 | for pipl in manifest["pipelines"]:
|
858 | 860 | if pipl["name"] == "image":
|
859 | 861 | for st in pipl["stages"]:
|
860 |
| - if st["type"] == "org.osbuild.sfdisk": |
| 862 | + if st["type"] == stage_type: |
861 | 863 | return st["options"]
|
862 |
| - raise ValueError(f"cannot find sfdisk stage manifest:\n{manifest_str}") |
| 864 | + raise ValueError(f"cannot find {stage_type} stage manifest:\n{manifest_str}") |
863 | 865 |
|
864 | 866 |
|
865 | 867 | def test_manifest_image_customize_filesystem(tmp_path, build_container):
|
@@ -900,7 +902,7 @@ def test_manifest_image_customize_filesystem(tmp_path, build_container):
|
900 | 902 | "manifest",
|
901 | 903 | f"localhost/{container_tag}",
|
902 | 904 | ], encoding="utf8")
|
903 |
| - sfdisk_options = find_sfdisk_stage_from(manifest_str) |
| 905 | + sfdisk_options = find_stage_options_from(manifest_str, "org.osbuild.sfdisk") |
904 | 906 | assert sfdisk_options["partitions"][2]["size"] == 3 * 1024 * 1024 * 1024 / 512
|
905 | 907 |
|
906 | 908 |
|
@@ -946,5 +948,71 @@ def test_manifest_image_customize_disk(tmp_path, build_container):
|
946 | 948 | "manifest",
|
947 | 949 | f"localhost/{container_tag}",
|
948 | 950 | ], encoding="utf8")
|
949 |
| - sfdisk_options = find_sfdisk_stage_from(manifest_str) |
| 951 | + sfdisk_options = find_stage_options_from(manifest_str, "org.osbuild.sfdisk") |
950 | 952 | assert sfdisk_options["partitions"][2]["size"] == 3 * 1024 * 1024 * 1024 / 512
|
| 953 | + |
| 954 | + |
| 955 | +def test_manifest_image_aboot(tmp_path, build_container): |
| 956 | + # no need to parameterize this test, overrides behaves same for all containers |
| 957 | + container_ref = "quay.io/centos-bootc/centos-bootc:stream9" |
| 958 | + testutil.pull_container(container_ref) |
| 959 | + |
| 960 | + cfg = { |
| 961 | + "blueprint": { |
| 962 | + "customizations": { |
| 963 | + "disk": { |
| 964 | + "partitions": [ |
| 965 | + { |
| 966 | + "part_label": "ukiboot_a", |
| 967 | + "part_uuid": "DF331E4D-BE00-463F-B4A7-8B43E18FB53A", |
| 968 | + "fs_type": "none", |
| 969 | + "minsize": "1 GiB", |
| 970 | + }, |
| 971 | + { |
| 972 | + "part_label": "ukiboot_b", |
| 973 | + "part_uuid": "DF331E4D-BE00-463F-B4A7-8B43E18FB53A", |
| 974 | + "fs_type": "none", |
| 975 | + "minsize": "1 GiB", |
| 976 | + }, |
| 977 | + { |
| 978 | + "part_label": "ukibootctl", |
| 979 | + "part_uuid": "FEFD9070-346F-4C9A-85E6-17F07F922773", |
| 980 | + "fs_type": "none", |
| 981 | + "minsize": "1 GiB", |
| 982 | + }, |
| 983 | + ], |
| 984 | + }, |
| 985 | + }, |
| 986 | + }, |
| 987 | + } |
| 988 | + |
| 989 | + config_json_path = tmp_path / "config.json" |
| 990 | + config_json_path.write_text(json.dumps(cfg), encoding="utf-8") |
| 991 | + |
| 992 | + testdata_path = tmp_path / "testdata" |
| 993 | + testdata_path.write_text("some test data", encoding="utf-8") |
| 994 | + |
| 995 | + # Create derived container with the custom partitioning with an aboot |
| 996 | + # partition and a kernel module dir with an aboot.img file |
| 997 | + cntf_path = tmp_path / "Containerfile" |
| 998 | + cntf_path.write_text(textwrap.dedent(f"""\n |
| 999 | + FROM {container_ref} |
| 1000 | + RUN mkdir -p -m 0755 /usr/lib/bootc-image-builder |
| 1001 | + COPY config.json /usr/lib/bootc-image-builder/ |
| 1002 | + RUN rm -rf /usr/lib/modules/* |
| 1003 | + RUN mkdir -p -m 0755 /usr/lib/modules/5.0-x86_64/ |
| 1004 | + COPY testdata /usr/lib/modules/5.0-x86_64/vmlinuz |
| 1005 | + COPY testdata /usr/lib/modules/5.0-x86_64/aboot.img |
| 1006 | + """), encoding="utf8") |
| 1007 | + |
| 1008 | + print(f"building filesystem customize container from {container_ref}") |
| 1009 | + with make_container(tmp_path) as container_tag: |
| 1010 | + print(f"using {container_tag}") |
| 1011 | + manifest_str = subprocess.check_output([ |
| 1012 | + *testutil.podman_run_common, |
| 1013 | + build_container, |
| 1014 | + "manifest", |
| 1015 | + f"localhost/{container_tag}", |
| 1016 | + ], encoding="utf8") |
| 1017 | + write_device_options = find_stage_options_from(manifest_str, "org.osbuild.write-device") |
| 1018 | + assert write_device_options["from"] == "input://tree/usr/lib/modules/5.0-x86_64/aboot.img" |
0 commit comments