From 09444a2e76d91b6300923426dd06a4bd25de87d4 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Jul 2023 14:16:44 +0200 Subject: [PATCH 1/5] elf2efi: Make compatible with python 3.6 again CentOS 8 ships python 3.6 so let's try and stay compatible with that since the only feature we're using that requires python 3.9 is the streamlined type annotations which are trivial to convert back to the older stuff to stay compatible with python 3.6. --- meson.build | 5 ++--- tools/elf2efi.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index f8af69911b..395eca1943 100644 --- a/meson.build +++ b/meson.build @@ -2143,8 +2143,8 @@ if efi_arch == 'x64' and cc.links(''' endif have_pyelftools = pymod.find_installation('python3', required : false, modules : ['elftools']).found() -if get_option('bootloader') == 'true' and (not python_39 or not have_pyelftools) - error('EFI bootloader support requires Python >= 3.9 and pyelftools.') +if get_option('bootloader') == 'true' and not have_pyelftools + error('EFI bootloader support requires pyelftools.') endif conf.set10( @@ -2152,7 +2152,6 @@ conf.set10( get_option('efi') and get_option('bootloader') in ['auto', 'true'] and efi_arch != '' and - python_39 and have_pyelftools, ) diff --git a/tools/elf2efi.py b/tools/elf2efi.py index 20d25321c4..e233c8e3ab 100755 --- a/tools/elf2efi.py +++ b/tools/elf2efi.py @@ -80,7 +80,7 @@ class PeRelocationBlock(LittleEndianStructure): def __init__(self, PageRVA: int): super().__init__(PageRVA) - self.entries: list[PeRelocationEntry] = [] + self.entries: typing.List[PeRelocationEntry] = [] class PeRelocationEntry(LittleEndianStructure): @@ -281,7 +281,7 @@ def convert_elf_section(elf_s: ELFSection) -> PeSection: return pe_s -def copy_sections(elf: ELFFile, opt: PeOptionalHeader) -> list[PeSection]: +def copy_sections(elf: ELFFile, opt: PeOptionalHeader) -> typing.List[PeSection]: sections = [] for elf_s in elf.iter_sections(): @@ -304,7 +304,7 @@ def copy_sections(elf: ELFFile, opt: PeOptionalHeader) -> list[PeSection]: def apply_elf_relative_relocation( - reloc: ElfRelocation, image_base: int, sections: list[PeSection], addend_size: int + reloc: ElfRelocation, image_base: int, sections: typing.List[PeSection], addend_size: int ): # fmt: off [target] = [ @@ -330,8 +330,8 @@ def convert_elf_reloc_table( elf: ELFFile, elf_reloc_table: ElfRelocationTable, image_base: int, - sections: list[PeSection], - pe_reloc_blocks: dict[int, PeRelocationBlock], + sections: typing.List[PeSection], + pe_reloc_blocks: typing.Dict[int, PeRelocationBlock], ): NONE_RELOC = { "EM_386": ENUM_RELOC_TYPE_i386["R_386_NONE"], @@ -377,7 +377,7 @@ def convert_elf_reloc_table( def convert_elf_relocations( - elf: ELFFile, opt: PeOptionalHeader, sections: list[PeSection] + elf: ELFFile, opt: PeOptionalHeader, sections: typing.List[PeSection] ) -> typing.Optional[PeSection]: dynamic = elf.get_section_by_name(".dynamic") if dynamic is None: @@ -387,7 +387,7 @@ def convert_elf_relocations( if not flags_tag["d_val"] & ENUM_DT_FLAGS_1["DF_1_PIE"]: raise RuntimeError("ELF file is not a PIE.") - pe_reloc_blocks: dict[int, PeRelocationBlock] = {} + pe_reloc_blocks: typing.Dict[int, PeRelocationBlock] = {} for reloc_type, reloc_table in dynamic.get_relocation_tables().items(): if reloc_type not in ["REL", "RELA"]: raise RuntimeError("Unsupported relocation type {elf_reloc_type}.") @@ -433,7 +433,7 @@ def convert_elf_relocations( def write_pe( - file, coff: PeCoffHeader, opt: PeOptionalHeader, sections: list[PeSection] + file, coff: PeCoffHeader, opt: PeOptionalHeader, sections: typing.List[PeSection] ): file.write(b"MZ") file.seek(0x3C, io.SEEK_SET) From 5b79e9d7a987f8f2f46ae7f66bb39465958a008c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Jul 2023 14:43:19 +0200 Subject: [PATCH 2/5] mkosi: Update to latest mkosi now supports CentOS SIGs natively so we drop our own definition of that and use the mkosi builtin one. We also enable hyperscale for both CentOS 8 and CentOS 9 for consistency and add epel-next as well which is a requirement for Hyperscale. --- .github/workflows/mkosi.yml | 2 +- mkosi.conf.d/10-centos.conf | 2 ++ mkosi.conf.d/11-centos-8/mkosi.conf | 8 -------- .../mkosi.reposdir/CentOS-Stream-Hyperscale.repo | 7 ------- .../11-centos-8/mkosi.reposdir/powertools.repo | 10 ---------- 5 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 mkosi.conf.d/11-centos-8/mkosi.conf delete mode 100644 mkosi.conf.d/11-centos-8/mkosi.reposdir/CentOS-Stream-Hyperscale.repo delete mode 100644 mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml index 984e6a8e06..2a0f7a9096 100644 --- a/.github/workflows/mkosi.yml +++ b/.github/workflows/mkosi.yml @@ -76,7 +76,7 @@ jobs: steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - - uses: systemd/mkosi@b1a570550ee077ed7a9a9359e4732636034807e6 + - uses: systemd/mkosi@5866c0ff3b36d350c943016e5a3b115f7a95d37f - name: Configure run: | diff --git a/mkosi.conf.d/10-centos.conf b/mkosi.conf.d/10-centos.conf index 4181f03414..6932b8b29c 100644 --- a/mkosi.conf.d/10-centos.conf +++ b/mkosi.conf.d/10-centos.conf @@ -6,3 +6,5 @@ Distribution=centos [Distribution] Release=9 Repositories=epel + epel-next + hyperscale-packages-main diff --git a/mkosi.conf.d/11-centos-8/mkosi.conf b/mkosi.conf.d/11-centos-8/mkosi.conf deleted file mode 100644 index 6b6ab8cccd..0000000000 --- a/mkosi.conf.d/11-centos-8/mkosi.conf +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=8 - -[Distribution] -PackageManagerTrees=mkosi.reposdir:/etc/yum.repos.d diff --git a/mkosi.conf.d/11-centos-8/mkosi.reposdir/CentOS-Stream-Hyperscale.repo b/mkosi.conf.d/11-centos-8/mkosi.reposdir/CentOS-Stream-Hyperscale.repo deleted file mode 100644 index c520c6f1e8..0000000000 --- a/mkosi.conf.d/11-centos-8/mkosi.reposdir/CentOS-Stream-Hyperscale.repo +++ /dev/null @@ -1,7 +0,0 @@ -[centos-hyperscale] -name=CentOS Stream $releasever - Hyperscale -mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=hyperscale-packages-main -#baseurl=http://mirror.centos.org/$contentdir/$stream/hyperscale/$basearch/packages-main/ -gpgcheck=1 -enabled=1 -gpgkey=https://git.centos.org/rpms/centos-release-hyperscale/raw/c8s-sig-hyperscale/f/SOURCES/RPM-GPG-KEY-CentOS-SIG-HyperScale diff --git a/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo b/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo deleted file mode 100644 index 1462257c08..0000000000 --- a/mkosi.conf.d/11-centos-8/mkosi.reposdir/powertools.repo +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[powertools-hotfixes] -name=powertools-hotfixes -mirrorlist=http://mirrorlist.centos.org/?release=$stream&arch=$basearch&repo=PowerTools -gpgkey=https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official -gpgcheck=1 -enabled=1 -module_hotfixes=1 -skip_if_unavailable=1 From 2defccf3e1b37db316ffce2d3346f8944b62b05d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Jul 2023 14:51:42 +0200 Subject: [PATCH 3/5] mkosi: Drop kernel command line arguments that are set by mkosi mkosi sets these by default now so let's drop them from our configuration. --- mkosi.conf.d/10-systemd.conf | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/mkosi.conf.d/10-systemd.conf b/mkosi.conf.d/10-systemd.conf index 8fe77e8fbe..51b821b658 100644 --- a/mkosi.conf.d/10-systemd.conf +++ b/mkosi.conf.d/10-systemd.conf @@ -22,21 +22,10 @@ KernelCommandLineExtra=systemd.crash_shell systemd.log_ratelimit_kmsg=0 systemd.journald.forward_to_console systemd.journald.max_level_console=warning - # Tell the kernel to only log warning and up to the console. - loglevel=4 # Disable the kernel's ratelimiting on userspace logging to kmsg. printk.devkmsg=on - # Tell networkd to manage the ethernet interface. - ip=enp0s1:any - # Make sure sulogin works even with a locked root account. - SYSTEMD_SULOGIN_FORCE=1 # Make sure /sysroot is mounted rw in the initrd. rw - # Make sure we pull in network related units even if nothing else depends on the - # network to be online. - systemd.wants=network-online.target - # Make sure we don't load vmw_vmci which messes with virtio vsock. - module_blacklist=vmw_vmci # Lower the default device timeout so we get a shell earlier if the root device does # not appear for some reason. systemd.default_device_timeout_sec=10 From 3e0718f28239c181636b163e9268e1767c340822 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Jul 2023 14:31:40 +0200 Subject: [PATCH 4/5] mkosi: Stop using python3.9 on CentOS 8 Let's get rid of all the complexity and just not build ukify on CentOS Stream 8. --- mkosi.presets/00-base/mkosi.build | 9 ++++++++- .../00-base/mkosi.conf.d/10-centos-fedora.conf | 7 +++++++ .../00-base/mkosi.conf.d/10-fedora.conf | 7 ------- .../00-base/mkosi.conf.d/11-centos-8.conf | 16 ---------------- .../00-base/mkosi.conf.d/11-centos-9.conf | 15 --------------- mkosi.presets/00-base/mkosi.prepare | 12 ------------ .../20-final/mkosi.conf.d/10-centos-fedora.conf | 5 +++++ .../20-final/mkosi.conf.d/10-fedora.conf | 4 ---- .../20-final/mkosi.conf.d/11-centos-8.conf | 14 -------------- .../20-final/mkosi.conf.d/11-centos-9.conf | 13 ------------- 10 files changed, 20 insertions(+), 82 deletions(-) delete mode 100644 mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf delete mode 100644 mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf delete mode 100755 mkosi.presets/00-base/mkosi.prepare delete mode 100644 mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf delete mode 100644 mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf diff --git a/mkosi.presets/00-base/mkosi.build b/mkosi.presets/00-base/mkosi.build index d31eb338c6..eb95d15201 100755 --- a/mkosi.presets/00-base/mkosi.build +++ b/mkosi.presets/00-base/mkosi.build @@ -48,6 +48,13 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then rootprefix=/${rootprefix#/} fi + . /etc/os-release + if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then + UKIFY=false + else + UKIFY=true + fi + CONFIGURE_OPTS=( -D sysvinit-path="$sysvinit_path" -D rootprefix="$rootprefix" @@ -133,7 +140,7 @@ if [ ! -f "$BUILDDIR"/build.ninja ]; then -D kernel-install=true -D analyze=true -D bpf-framework=true - -D ukify=true + -D ukify="$UKIFY" -D seccomp=true -D selinux=auto -D apparmor=auto diff --git a/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf b/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf index 283369ff10..4dec24cc20 100644 --- a/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-centos-fedora.conf @@ -28,6 +28,7 @@ BuildPackages= bpftool docbook-xsl findutils + libgcrypt-devel # CentOS Stream 8 libgcrypt-devel doesn't ship a pkg-config file. libxslt pam-devel pkgconfig(audit) @@ -65,4 +66,10 @@ BuildPackages= pkgconfig(tss2-tcti-device) pkgconfig(valgrind) pkgconfig(xkbcommon) + python3 + python3dist(jinja2) + python3dist(lxml) + python3dist(pefile) + python3dist(pyelftools) + python3dist(pytest) rpm diff --git a/mkosi.presets/00-base/mkosi.conf.d/10-fedora.conf b/mkosi.presets/00-base/mkosi.conf.d/10-fedora.conf index eba6f040da..9c4c12423c 100644 --- a/mkosi.presets/00-base/mkosi.conf.d/10-fedora.conf +++ b/mkosi.presets/00-base/mkosi.conf.d/10-fedora.conf @@ -8,11 +8,4 @@ Packages= python3dist(pytest-flakes) BuildPackages= - pkgconfig(libgcrypt) pkgconfig(xencontrol) - python3 - python3dist(jinja2) - python3dist(lxml) - python3dist(pefile) - python3dist(pyelftools) - python3dist(pytest) diff --git a/mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf b/mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf deleted file mode 100644 index ef001c92c9..0000000000 --- a/mkosi.presets/00-base/mkosi.conf.d/11-centos-8.conf +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=8 - -[Content] -BuildPackages= - libgcrypt-devel # CentOS Stream 8 libgcrypt-devel doesn't ship a pkg-config file. - platform-python - python3.9dist(jinja2) - python3.9dist(lxml) - python3.9dist(pefile) - python3.9dist(pyelftools) - python3.9dist(pytest) - python39 diff --git a/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf b/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf deleted file mode 100644 index 61c1d27f44..0000000000 --- a/mkosi.presets/00-base/mkosi.conf.d/11-centos-9.conf +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=9 - -[Content] -BuildPackages= - pkgconfig(libgcrypt) - platform-python - python3dist(jinja2) - python3dist(lxml) - python3dist(pefile) - python3dist(pyelftools) - python3dist(pytest) diff --git a/mkosi.presets/00-base/mkosi.prepare b/mkosi.presets/00-base/mkosi.prepare deleted file mode 100755 index c056d4fc59..0000000000 --- a/mkosi.presets/00-base/mkosi.prepare +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# SPDX-License-Identifier: LGPL-2.1-or-later -set -e - -if [ "$1" = "build" ]; then - . /etc/os-release - - if [ "$ID" = "centos" ] && [ "$VERSION" = "8" ]; then - alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 - alternatives --set python3 /usr/bin/python3.9 - fi -fi diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf index cb68c8dd1a..ad77a2b8d4 100644 --- a/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf +++ b/mkosi.presets/20-final/mkosi.conf.d/10-centos-fedora.conf @@ -23,5 +23,10 @@ Packages= passwd polkit procps-ng + python3 + python3dist(pefile) + python3dist(pluggy) # python3-pluggy is a pytest dependency that's not installed for some reason. + python3dist(psutil) + python3dist(pytest) quota vim-common diff --git a/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf b/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf index 5ae623e47d..42d0093a89 100644 --- a/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf +++ b/mkosi.presets/20-final/mkosi.conf.d/10-fedora.conf @@ -8,7 +8,3 @@ Packages= btrfs-progs compsize f2fs-tools - python3 - python3dist(pefile) - python3dist(psutil) - python3dist(pytest) diff --git a/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf b/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf deleted file mode 100644 index 2fa476454d..0000000000 --- a/mkosi.presets/20-final/mkosi.conf.d/11-centos-8.conf +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=8 - -[Content] -Packages= - platform-python - python3.9dist(pefile) - python3.9dist(pluggy) # python39-pluggy is a pytest dependency that's not installed for some reason. - python3.9dist(psutil) - python3.9dist(pytest) - python39 diff --git a/mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf b/mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf deleted file mode 100644 index d6ab3ee1c3..0000000000 --- a/mkosi.presets/20-final/mkosi.conf.d/11-centos-9.conf +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: LGPL-2.1-or-later - -[Match] -Distribution=centos -Release=9 - -[Content] -Packages= - platform-python - python3dist(pefile) - python3dist(pluggy) # python39-pluggy is a pytest dependency that's not installed for some reason. - python3dist(psutil) - python3dist(pytest) From 8229217327d54386a16a0a82726f97bc74cb352c Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Fri, 14 Jul 2023 14:52:58 +0200 Subject: [PATCH 5/5] mkosi: Move settings to right sections --- mkosi.conf.d/10-systemd.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mkosi.conf.d/10-systemd.conf b/mkosi.conf.d/10-systemd.conf index 51b821b658..d0e2cc997a 100644 --- a/mkosi.conf.d/10-systemd.conf +++ b/mkosi.conf.d/10-systemd.conf @@ -1,15 +1,15 @@ # SPDX-License-Identifier: LGPL-2.1-or-later [Output] +OutputDirectory=mkosi.output +BuildDirectory=mkosi.builddir +CacheDirectory=mkosi.cache + +[Content] # Prevent ASAN warnings when building the image and ship the real ASAN options prefixed with MKOSI_. Environment=ASAN_OPTIONS=verify_asan_link_order=false MKOSI_ASAN_OPTIONS=strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:disable_coredump=0:use_madv_dontdump=1 MKOSI_UBSAN_OPTIONS=print_stacktrace=1:print_summary=1:halt_on_error=1 -OutputDirectory=mkosi.output - -[Content] -BuildDirectory=mkosi.builddir -CacheDirectory=mkosi.cache [Host] Incremental=yes