diff --git a/.gitignore b/.gitignore index f862310..ab96fe3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ repo/ _build/ *.repo/ +*.tar diff --git a/Makefile b/Makefile index 5bd05bc..3f6309f 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ endif export CHECKPOINTS=build IMAGETYPES := regular ostree -FORMATS := img qcow2 oci.tar repo rootfs ext4 tar +FORMATS := oci.tar repo tar COMMON_TARGETS := qemu HOST_TARGETS := $(COMMON_TARGETS) $($(HOST_ARCH)_TARGETS) ALL_TARGETS := $(COMMON_TARGETS) $(foreach a,$(ARCHES), $($(a)_TARGETS)) @@ -66,9 +66,7 @@ help: @echo @echo Other extensions are also supported: @echo \ \* .repo: Generate a repo with an ostree commit \(only works for ostree targets\) - @echo \ \* .rootfs: Generate a directory with the rootfs content @echo \ \* .tar: Generate a tar file with the rootfs content - @echo \ \* .ext4: Generate an ext4 filesystem with the rootfs content \(size from \"image_size\"\) @echo \ \* oci.tar: Generate an oci container image with the rootfs content @echo @echo You can pass variable declarations to osbuild-mpp with the DEFINES make variable. @@ -76,9 +74,6 @@ help: @echo For example, to add extra rpms to a minimal regular image, use: @echo " make cs9-qemu-minimal-regular.$(HOST_ARCH).qcow2 DEFINES='extra_rpms=[\"gdb\",\"strace\"]'" @echo - @echo To easily run the image with qemu, you can use the included runvm tool, like: - @echo \ \ ./runvm cs9-qemu-minimal-regular.$(HOST_ARCH).qcow2 - @echo @echo There are some additional targets: @echo \ \ manifests: generates resolved json manifests for all images without building them. @echo \ \ clean_caches: Removes intermediate image build artifacts \(that improve rebuild speed\) @@ -86,8 +81,6 @@ help: @echo \ \ clean: Run clean_caches and clean_downloads @echo @echo There are also some common conversion rules: - @echo \ \ foo.ext4.simg will build foo.ext4 and then convert it with img2simg - @echo \ \ foo.simg will build foo.img and then convert it with img2simg @echo \ \ foo.tar.gz will build $foo.tar and then gzip it @echo @echo "When building a custom variant of an image (say with an extra package) you can use a" @@ -180,13 +173,5 @@ clean: clean_downloads clean_caches VM_SUDO=sudo VM_OSBUILD=sudo osbuild -%.ext4.simg : %.ext4 - img2simg $< $@ - rm $< - -%.simg : %.img - img2simg $< $@ - rm $< - %.tar.gz : %.tar gzip -f $< diff --git a/images/minimal.mpp.yml b/images/minimal.mpp.yml index 6a5f5b2..84f5f8e 100644 --- a/images/minimal.mpp.yml +++ b/images/minimal.mpp.yml @@ -47,12 +47,6 @@ pipelines: - type: org.osbuild.locale options: language: en_US.UTF-8 - - type: org.osbuild.users - options: - users: - guest: - password: - mpp-eval: guest_password - type: org.osbuild.systemd options: enabled_services: diff --git a/include/build-x86_64.ipp.yml b/include/build-x86_64.ipp.yml deleted file mode 100644 index 142e2c5..0000000 --- a/include/build-x86_64.ipp.yml +++ /dev/null @@ -1,50 +0,0 @@ -version: '2' -mpp-vars: - efiarch: x64 - boot_rpms: - mpp-join: - - mpp-eval: boot_rpms - - - grub2-efi-x64 - - grub2-pc - base_rpms: - mpp-join: - - mpp-eval: base_rpms - - - microcode_ctl -pipelines: -- name: build - runner: org.osbuild.centos9 - stages: - - type: org.osbuild.rpm - inputs: - packages: - type: org.osbuild.files - origin: org.osbuild.source - mpp-depsolve: - architecture: $arch - module-platform-id: $distro_module_id - baseurl: $distro_baseurl/BaseOS/$arch/os/ - repos: - mpp-eval: distro_repos - packages: - mpp-join: - - mpp-eval: build_rpms - - mpp-eval: extra_build_rpms - - - grub2-efi-x64 - - grub2-efi-x64-cdboot - - grub2-tools-efi - - grub2-pc - - grub2-pc-modules - - grub2-tools - - shim-x64 - options: - gpgkeys: - - mpp-eval: centos_gpg_key - - mpp-eval: redhat_gpg_key - exclude: - docs: true - - type: org.osbuild.selinux - options: - file_contexts: etc/selinux/targeted/contexts/files/file_contexts - labels: - /usr/bin/cp: system_u:object_r:install_exec_t:s0 - /usr/bin/tar: system_u:object_r:install_exec_t:s0 diff --git a/include/build.ipp.yml b/include/build.ipp.yml index d4c4cf8..f858218 100644 --- a/include/build.ipp.yml +++ b/include/build.ipp.yml @@ -3,36 +3,46 @@ version: '2' mpp-vars: distro_name: cs9 # The default -mpp-define-image: - size: $image_size - table: - uuid: $parttab_uuid - label: $partition_label - partitions: - - id: efi - start: - mpp-eval: "0 if partition_label == 'gpt' else 2048" - size: $efipart_size - type: - mpp-eval: "'C12A7328-F81F-11D2-BA4B-00A0C93EC93B' if partition_label == 'gpt' else 'ef'" - uuid: $efipart_uuid - - id: boot - size: $bootpart_size - type: - mpp-eval: "'0FC63DAF-8483-4772-8E79-3D69D8477DE4' if partition_label == 'gpt' else '83'" - uuid: $bootpart_uuid - - id: root - type: - mpp-eval: "'0FC63DAF-8483-4772-8E79-3D69D8477DE4' if partition_label == 'gpt' else '83'" - uuid: $rootpart_uuid pipelines: - mpp-import-pipelines: path: distro/$distro_name.ipp.yml - mpp-import-pipelines: path: defaults.ipp.yml -- mpp-import-pipelines: - path: target-$target.ipp.yml -- mpp-import-pipeline: - path: build-$arch.ipp.yml - id: build +- name: build + runner: org.osbuild.centos9 + stages: + - type: org.osbuild.rpm + inputs: + packages: + type: org.osbuild.files + origin: org.osbuild.source + mpp-depsolve: + architecture: $arch + module-platform-id: $distro_module_id + baseurl: $distro_baseurl/BaseOS/$arch/os/ + repos: + mpp-eval: distro_repos + packages: + mpp-join: + - mpp-eval: build_rpms + - mpp-eval: extra_build_rpms + - - grub2-efi-x64 + - grub2-efi-x64-cdboot + - grub2-tools-efi + - grub2-pc + - grub2-pc-modules + - grub2-tools + - shim-x64 + options: + gpgkeys: + - mpp-eval: centos_gpg_key + - mpp-eval: redhat_gpg_key + exclude: + docs: true + - type: org.osbuild.selinux + options: + file_contexts: etc/selinux/targeted/contexts/files/file_contexts + labels: + /usr/bin/cp: system_u:object_r:install_exec_t:s0 + /usr/bin/tar: system_u:object_r:install_exec_t:s0 runner: org.osbuild.centos9 diff --git a/include/defaults.ipp.yml b/include/defaults.ipp.yml index 31bba01..12efd08 100644 --- a/include/defaults.ipp.yml +++ b/include/defaults.ipp.yml @@ -5,36 +5,17 @@ mpp-vars: default_ostree_ref: $distro_name/$arch/$target-$name default_ostree_os_version: $distro_version default_osname: centos - default_uefi_vendor: centos default_kernel_rpm: kernel default_linux_firmware_rpm: linux-firmware - default_partition_label: gpt default_extra_rpms: [] default_extra_build_rpms: [] default_extra_repos: [] default_target_repos: [] - default_root_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU. - default_guest_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU. - default_root_ssh_key: "" - default_ssh_permit_root_login: false - default_image_size: '8589934592' - default_efipart_size: 204800 - default_bootpart_size: 614400 - default_kernel_loglevel: 4 static_uuids: mpp-eval: locals().get('static_uuids', True) default_rootfs_uuid: mpp-eval: ('76a22bf4-f153-4541-b6c7-0332c0dfaeac' if static_uuids else str(__import__('uuid').uuid4())) - default_bootfs_uuid: - mpp-eval: ('156f0420-627b-4151-ae6f-fda298097515' if static_uuids else str(__import__('uuid').uuid4())) - default_parttab_uuid: - mpp-eval: ('d209c89e-ea5e-4fbd-b161-b461cce297e0' if static_uuids else str(__import__('uuid').uuid4())) - default_efipart_uuid: - mpp-eval: ('68b2905b-df3e-4fb3-80fa-49d1e773aa33' if static_uuids else str(__import__('uuid').uuid4())) - default_bootpart_uuid: - mpp-eval: ('61b2905b-df3e-4fb3-80fa-49d1e773aa32' if static_uuids else str(__import__('uuid').uuid4())) - default_rootpart_uuid: - mpp-eval: ('6264d520-3fb9-423f-8ab8-7a0a8e3d3562' if static_uuids else str(__import__('uuid').uuid4())) + default_kernel_loglevel: 4 default_use_efi_runtime: true default_kernel_opts: - console=tty0 @@ -86,10 +67,6 @@ mpp-vars: mpp-eval: locals().get('ostree_os_version', default_ostree_os_version) osname: mpp-eval: locals().get('osname', default_osname) - uefi_vendor: - mpp-eval: locals().get('uefi_vendor', default_uefi_vendor) - partition_label: - mpp-eval: locals().get('partition_label', default_partition_label) extra_rpms: mpp-eval: locals().get('extra_rpms', default_extra_rpms) extra_build_rpms: @@ -98,26 +75,10 @@ mpp-vars: mpp-eval: locals().get('extra_repos', default_extra_repos) target_repos: mpp-eval: locals().get('target_repos', default_target_repos) - image_size: - mpp-eval: locals().get('image_size', default_image_size) rootfs_uuid: mpp-eval: locals().get('rootfs_uuid', default_rootfs_uuid) - bootfs_uuid: - mpp-eval: locals().get('bootfs_uuid', default_bootfs_uuid) - parttab_uuid: - mpp-eval: locals().get('parttab_uuid', default_parttab_uuid) - rootpart_uuid: - mpp-eval: locals().get('rootpart_uuid', default_rootpart_uuid) - bootpart_uuid: - mpp-eval: locals().get('bootpart_uuid', default_bootpart_uuid) - efipart_uuid: - mpp-eval: locals().get('efipart_uuid', default_efipart_uuid) kernel_opts: mpp-eval: locals().get('kernel_opts', default_kernel_opts) - efipart_size: - mpp-eval: locals().get('efipart_size', default_efipart_size) - bootpart_size: - mpp-eval: locals().get('bootpart_size', default_bootpart_size) dracut_add_modules: mpp-eval: locals().get('dracut_add_modules', default_dracut_add_modules) dracut_omit_modules: @@ -128,14 +89,6 @@ mpp-vars: mpp-eval: locals().get('dracut_add_drivers', default_dracut_add_drivers) dracut_install: mpp-eval: locals().get('dracut_install', default_dracut_install) - root_password: - mpp-eval: locals().get('root_password', default_root_password) - root_ssh_key: - mpp-eval: locals().get('root_ssh_key', default_root_ssh_key) - ssh_permit_root_login: - mpp-eval: locals().get('ssh_permit_root_login', default_ssh_permit_root_login) - guest_password: - mpp-eval: locals().get('guest_password', default_guest_password) ostree_repo_url: mpp-eval: locals().get('ostree_repo_url', default_ostree_repo_url) ostree_remote_name: @@ -237,24 +190,6 @@ mpp-vars: iA== =+Gxh -----END PGP PUBLIC KEY BLOCK----- - fstab: - - uuid: - mpp-eval: rootfs_uuid - vfs_type: ext4 - path: / - freq: 1 - passno: 1 - - label: ESP - vfs_type: vfat - path: /boot/efi - freq: 1 - passno: 1 - - uuid: - mpp-eval: bootfs_uuid - vfs_type: ext4 - path: /boot - freq: 1 - passno: 1 build_rpms: - dnf - dosfstools @@ -275,9 +210,12 @@ mpp-vars: boot_rpms: - dracut-config-generic - grub2-tools-minimal + - grub2-efi-x64 + - grub2-pc - $kernel_rpm base_rpms: - $linux_firmware_rpm + - microcode_ctl - NetworkManager - audit - chrony diff --git a/include/image-ostree.ipp.yml b/include/image-ostree.ipp.yml index a81aaff..fb807c1 100644 --- a/include/image-ostree.ipp.yml +++ b/include/image-ostree.ipp.yml @@ -96,114 +96,3 @@ pipelines: mpp-if: ostree_ref in locals().get("ostree_parent_refs", {}) then: mpp-eval: ostree_parent_refs[ostree_ref] -- name: image-tree - build: name:build - stages: - - type: org.osbuild.ostree.init-fs - - type: org.osbuild.ostree.pull - options: - repo: /ostree/repo - remote: - mpp-eval: ostree_remote_name - inputs: - commits: - type: org.osbuild.ostree - origin: org.osbuild.pipeline - references: - name:ostree-commit: - ref: - mpp-eval: ostree_ref - - type: org.osbuild.ostree.os-init - options: - osname: - mpp-eval: osname - - type: org.osbuild.ostree.config - options: - repo: /ostree/repo - config: - sysroot: - readonly: true - bootloader: none - - type: org.osbuild.ostree.remotes - options: - repo: /ostree/repo - remotes: - - name: - mpp-eval: ostree_remote_name - url: - mpp-eval: ostree_repo_url - - type: org.osbuild.mkdir - options: - paths: - - path: /boot/efi - mode: 448 - - type: org.osbuild.ostree.deploy - options: - osname: - mpp-eval: osname - ref: - mpp-eval: ostree_ref - remote: - mpp-eval: ostree_remote_name - mounts: - - /boot - - /boot/efi - rootfs: - label: root - kernel_opts: - mpp-eval: kernel_opts - - type: org.osbuild.ostree.fillvar - options: - deployment: - osname: - mpp-eval: osname - ref: - mpp-eval: ostree_ref - - type: org.osbuild.users - mounts: - - type: org.osbuild.ostree.deployment - name: ostree.deployment - options: - deployment: - osname: - mpp-eval: osname - ref: - mpp-eval: ostree_ref - options: - users: - root: - password: - mpp-eval: root_password - key: - mpp-eval: root_ssh_key - - type: org.osbuild.fstab - options: - ostree: - deployment: - osname: - mpp-eval: osname - ref: - mpp-eval: ostree_ref - filesystems: - mpp-eval: fstab - - type: org.osbuild.ostree.selinux - options: - deployment: - osname: - mpp-eval: osname - ref: - mpp-eval: ostree_ref - - type: org.osbuild.grub2 - options: - rootfs: - label: root - bootfs: - label: boot - uefi: - vendor: - mpp-eval: uefi_vendor - unified: false - install: true - legacy: true - write_defaults: false - greenboot: true diff --git a/include/image-regular.ipp.yml b/include/image-regular.ipp.yml deleted file mode 100644 index 1132515..0000000 --- a/include/image-regular.ipp.yml +++ /dev/null @@ -1,73 +0,0 @@ -version: '2' -mpp-vars: - image_rpms: - mpp-join: - - mpp-eval: locals().get('extra_image_rpms', []) - - mpp-eval: boot_rpms - - mpp-eval: locals().get('extra_boot_rpms', []) - - - shim -pipelines: -- name: image-tree - build: name:build - stages: - mpp-join: - - - type: org.osbuild.copy - inputs: - tree: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:rootfs - options: - paths: - mpp-join: - - - from: input://tree/ - to: tree:/// - - type: org.osbuild.users - options: - users: - root: - password: - mpp-eval: root_password - key: - mpp-eval: root_ssh_key - - mpp-eval: target_stages - - - type: org.osbuild.dracut - options: - kernel: - - mpp-eval: rpms['rootfs'][kernel_rpm + '-core'].evra - add_modules: - mpp-eval: dracut_add_modules - omit_modules: - mpp-eval: dracut_omit_modules - add_drivers: - mpp-eval: dracut_add_drivers - filesystems: - mpp-eval: dracut_filesystems - install: - mpp-eval: dracut_install - - type: org.osbuild.fstab - options: - filesystems: - mpp-eval: fstab - - type: org.osbuild.grub2 - options: - root_fs_uuid: - mpp-eval: rootfs_uuid - boot_fs_uuid: - mpp-eval: bootfs_uuid - kernel_opts: - mpp-eval: ''' '' .join(kernel_opts)' - uefi: - vendor: - mpp-eval: uefi_vendor - unified: false - legacy: true - write_defaults: false - greenboot: true - - type: org.osbuild.fix-bls - options: - prefix: / - - type: org.osbuild.selinux - options: - file_contexts: etc/selinux/targeted/contexts/files/file_contexts diff --git a/include/image.ipp.yml b/include/image.ipp.yml index aa7af03..044269a 100644 --- a/include/image.ipp.yml +++ b/include/image.ipp.yml @@ -11,138 +11,10 @@ mpp-vars: then: efi=runtime - mpp-eval: kernel_opts pipelines: -# Some variables need to be written to files, do that here + +# ostree pipeline is in other file. - mpp-import-pipelines: - path: image-$image_type.ipp.yml -- name: image - build: name:build - stages: - - type: org.osbuild.truncate - options: - filename: disk.img - size: - mpp-eval: image.size - - type: org.osbuild.sfdisk - devices: - device: - type: org.osbuild.loopback - options: - filename: disk.img - options: - mpp-format-json: '{image.layout}' - - type: org.osbuild.mkfs.fat - devices: - device: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['efi'].start - size: - mpp-eval: image.layout['efi'].size - options: - label: ESP - volid: 7B7795E7 - - type: org.osbuild.mkfs.ext4 - devices: - device: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['boot'].start - size: - mpp-eval: image.layout['boot'].size - options: - uuid: - mpp-eval: bootfs_uuid - label: boot - - type: org.osbuild.mkfs.ext4 - devices: - device: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['root'].start - size: - mpp-eval: image.layout['root'].size - options: - uuid: - mpp-eval: rootfs_uuid - label: root - - type: org.osbuild.copy - inputs: - tree: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:image-tree - build-tree: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:build - options: - paths: - mpp-join: - - - from: input://tree/ - to: mount://root/ - - mpp-eval: locals().get('extra_image_copy_' + image_type, []) - devices: - efi: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['efi'].start - size: - mpp-eval: image.layout['efi'].size - boot: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['boot'].start - size: - mpp-eval: image.layout['boot'].size - root: - type: org.osbuild.loopback - options: - filename: disk.img - start: - mpp-eval: image.layout['root'].start - size: - mpp-eval: image.layout['root'].size - mounts: - - name: root - type: org.osbuild.ext4 - source: root - target: / - - name: boot - type: org.osbuild.ext4 - source: boot - target: /boot - - name: efi - type: org.osbuild.fat - source: efi - target: /boot/efi -- name: qcow2 - build: name:build - stages: - - type: org.osbuild.qemu - inputs: - image: - type: org.osbuild.files - origin: org.osbuild.pipeline - references: - name:image: - file: disk.img - options: - filename: disk.qcow2 - format: - type: qcow2 - compat: '1.1' + path: image-ostree.ipp.yml - name: container build: name:build @@ -161,85 +33,6 @@ pipelines: Cmd: - "/usr/bin/bash" -# We need a smaller fstab for the non-partitioned case -- name: ext4-fstab - build: name:build - stages: - # We copy /etc to get the right selinux context on the new file - - type: org.osbuild.copy - inputs: - image-tree: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:image-tree - options: - paths: - - from: input://image-tree/etc - to: tree:///etc - - type: org.osbuild.fstab - options: - filesystems: - - uuid: - mpp-eval: rootfs_uuid - vfs_type: ext4 - path: / - -- name: ext4 - build: name:build - stages: - - type: org.osbuild.truncate - options: - filename: rootfs.ext4 - size: - mpp-eval: image.size - - type: org.osbuild.mkfs.ext4 - devices: - device: - type: org.osbuild.loopback - options: - filename: rootfs.ext4 - start: 0 - size: - mpp-format-int: "{int(image.size) // 512}" - options: - uuid: - mpp-eval: rootfs_uuid - label: root - - type: org.osbuild.copy - inputs: - tree: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:image-tree - fstab: - type: org.osbuild.tree - origin: org.osbuild.pipeline - references: - - name:ext4-fstab - options: - paths: - mpp-join: - - - from: input://tree/ - to: mount://root/ - - from: input://fstab/etc/fstab - to: mount://root/etc/fstab - - mpp-eval: locals().get('extra_image_copy_' + image_type, []) - devices: - root: - type: org.osbuild.loopback - options: - filename: rootfs.ext4 - start: 0 - size: - mpp-format-int: "{int(image.size) // 512}" - mounts: - - name: root - type: org.osbuild.ext4 - source: root - target: / - - name: tar build: name:build stages: diff --git a/include/target-qemu.ipp.yml b/include/target-qemu.ipp.yml deleted file mode 100644 index 3ba1623..0000000 --- a/include/target-qemu.ipp.yml +++ /dev/null @@ -1,2 +0,0 @@ -version: '2' -pipelines: [] diff --git a/k8s/run.sh b/k8s/run.sh index 1e702d3..ead1dd6 100755 --- a/k8s/run.sh +++ b/k8s/run.sh @@ -1,6 +1,8 @@ +echo "========> Building minimal." sudo podman run --rm \ --privileged \ -v $PWD:/project:Z \ -w /project \ localhost/j7s-os-builder:latest \ make cs9-qemu-minimal-ostree.x86_64.repo + diff --git a/tools/runosbuild b/tools/runosbuild index a054183..0d4032c 100755 --- a/tools/runosbuild +++ b/tools/runosbuild @@ -25,22 +25,14 @@ EXTENSION="$6" # Map extension => export pipeline name declare -A EXPORT_BY_EXT -EXPORT_BY_EXT[img]=image EXPORT_BY_EXT[oci.tar]=container -EXPORT_BY_EXT[qcow2]=qcow2 EXPORT_BY_EXT[repo]=ostree-commit -EXPORT_BY_EXT[rootfs]=rootfs -EXPORT_BY_EXT[ext4]=ext4 EXPORT_BY_EXT[tar]=tar # Map extension to name of exported file by pipeline declare -A EXPORT_FILE_BY_EXT -EXPORT_FILE_BY_EXT[img]=disk.img -EXPORT_FILE_BY_EXT[qcow2]=disk.qcow2 EXPORT_FILE_BY_EXT[oci.tar]=container.tar EXPORT_FILE_BY_EXT[repo]=repo -EXPORT_FILE_BY_EXT[rootfs]= -EXPORT_FILE_BY_EXT[ext4]=rootfs.ext4 EXPORT_FILE_BY_EXT[tar]=rootfs.tar EXPORT=${EXPORT_BY_EXT[${EXTENSION}]}