[sys-kernel/dracut] sync
This commit is contained in:
		| @@ -1 +1 @@ | ||||
| DIST dracut-059.tar.gz 486487 BLAKE2B 86bbe18875cd3507e187b724cab212dc82e1daca7cedf79aeef13c34601adfff72bf2c0ba4c652e715b43c9a16f7be6a4a2b29dc75bef014640e1ec07c8d455b SHA512 196bc8bf18703c72bffb51a7e0493719c58173ad2da7d121eb42f9a8de47e953af36d109214dc4a10b2dc2d3bd19e844f7f51c2bdec087e064ea11f75124032d | ||||
| DIST dracut-059_p20231027.tar.gz 491099 BLAKE2B 02c5de4577bc5fc87fd11b7b9760b0f1a4a83ed7ef1fc2de22ea3f9588e9b03b347c1be4f26965d26ab8b88736b0da70e01ecb4a50c2951d1ec4009222aaa97a SHA512 da26c798f8c3856f7b9488278f26f1f392e6f6e1863bd6bb590f940854cde6633a45cf60acf52a2a184a1a47250a23e6ee53cb3f5fa759eb0146a4c0d172c07e | ||||
|   | ||||
| @@ -5,23 +5,29 @@ EAPI=7 | ||||
| 
 | ||||
| CARGO_OPTIONAL=1 | ||||
| 
 | ||||
| inherit bash-completion-r1 cargo linux-info optfeature systemd toolchain-funcs | ||||
| 
 | ||||
| inherit bash-completion-r1 cargo edo linux-info optfeature systemd toolchain-funcs | ||||
| if [[ ${PV} == 9999 ]] ; then | ||||
| 	inherit git-r3 | ||||
| 	EGIT_REPO_URI="https://github.com/dracutdevs/dracut" | ||||
| else | ||||
| 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" | ||||
| 	if [[ ${PV} == *_p* ]] ; then | ||||
| 		EGIT_COMMIT="b2af8c8bcfc72802e02e2c0adc2eed9279101624" | ||||
| 		SRC_URI="https://github.com/dracutdevs/dracut/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz" | ||||
| 		S="${WORKDIR}"/${PN}-${EGIT_COMMIT} | ||||
| 	else | ||||
| 		SRC_URI="https://github.com/dracutdevs/dracut/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz" | ||||
| 	fi | ||||
| fi | ||||
| 
 | ||||
| DESCRIPTION="Generic initramfs generation tool" | ||||
| HOMEPAGE="https://github.com/dracutdevs/dracut/wiki" | ||||
| 
 | ||||
| LICENSE="GPL-2" | ||||
| SLOT="0" | ||||
| if [[ "${PV}" != *_rc* ]]; then | ||||
| 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" | ||||
| fi | ||||
| IUSE="dracut-cpio selinux test" | ||||
| 
 | ||||
| RESTRICT="!test? ( test )" | ||||
| 
 | ||||
| RDEPEND=" | ||||
| @@ -64,11 +70,6 @@ QA_MULTILIB_PATHS="usr/lib/dracut/.*" | ||||
| 
 | ||||
| PATCHES=( | ||||
| 	"${FILESDIR}"/gentoo-ldconfig-paths-r1.patch | ||||
| 	"${FILESDIR}"/gentoo-network-r1.patch | ||||
| 	"${FILESDIR}"/059-kernel-install-uki.patch | ||||
| 	"${FILESDIR}"/059-uefi-split-usr.patch | ||||
| 	"${FILESDIR}"/059-uki-systemd-254.patch | ||||
| 	"${FILESDIR}"/059-gawk.patch | ||||
| ) | ||||
| 
 | ||||
| src_configure() { | ||||
| @@ -82,8 +83,7 @@ src_configure() { | ||||
| 
 | ||||
| 	tc-export CC PKG_CONFIG | ||||
| 
 | ||||
| 	echo ./configure "${myconf[@]}" | ||||
| 	./configure "${myconf[@]}" || die | ||||
| 	edo ./configure "${myconf[@]}" | ||||
| 
 | ||||
| 	if [[ ${PV} != 9999 && ! -f dracut-version.sh ]] ; then | ||||
| 		# Source tarball from github doesn't include this file | ||||
| @@ -180,7 +180,7 @@ pkg_postinst() { | ||||
| 	optfeature "Support TPM 2.0 TSS" app-crypt/tpm2-tools | ||||
| 	optfeature "Support Bluetooth (experimental)" net-wireless/bluez | ||||
| 	optfeature "Support BIOS-given device names" sys-apps/biosdevname | ||||
| 	optfeature "Support network NVMe" sys-apps/nvme-cli | ||||
| 	optfeature "Support network NVMe" sys-apps/nvme-cli app-misc/jq | ||||
| 	optfeature \ | ||||
| 		"Enable rngd service to help generating entropy early during boot" \ | ||||
| 		sys-apps/rng-tools | ||||
| @@ -5,23 +5,29 @@ EAPI=7 | ||||
|  | ||||
| CARGO_OPTIONAL=1 | ||||
|  | ||||
| inherit bash-completion-r1 cargo linux-info optfeature systemd toolchain-funcs | ||||
|  | ||||
| inherit bash-completion-r1 cargo edo linux-info optfeature systemd toolchain-funcs | ||||
| if [[ ${PV} == 9999 ]] ; then | ||||
| 	inherit git-r3 | ||||
| 	EGIT_REPO_URI="https://github.com/dracutdevs/dracut" | ||||
| else | ||||
| 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" | ||||
| 	if [[ ${PV} == *_p* ]] ; then | ||||
| 		EGIT_COMMIT="b2af8c8bcfc72802e02e2c0adc2eed9279101624" | ||||
| 		SRC_URI="https://github.com/dracutdevs/dracut/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz" | ||||
| 		S="${WORKDIR}"/${PN}-${EGIT_COMMIT} | ||||
| 	else | ||||
| 		SRC_URI="https://github.com/dracutdevs/dracut/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz" | ||||
| 	fi | ||||
| fi | ||||
|  | ||||
| DESCRIPTION="Generic initramfs generation tool" | ||||
| HOMEPAGE="https://github.com/dracutdevs/dracut/wiki" | ||||
|  | ||||
| LICENSE="GPL-2" | ||||
| SLOT="0" | ||||
| if [[ ${PV} != 9999 && ${PV} != *_rc* ]]; then | ||||
| 	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~sparc ~x86" | ||||
| fi | ||||
| IUSE="dracut-cpio selinux test" | ||||
|  | ||||
| RESTRICT="!test? ( test )" | ||||
|  | ||||
| RDEPEND=" | ||||
| @@ -64,7 +70,6 @@ QA_MULTILIB_PATHS="usr/lib/dracut/.*" | ||||
|  | ||||
| PATCHES=( | ||||
| 	"${FILESDIR}"/gentoo-ldconfig-paths-r1.patch | ||||
| 	"${FILESDIR}"/gentoo-network-r1.patch | ||||
| ) | ||||
|  | ||||
| src_configure() { | ||||
| @@ -78,8 +83,7 @@ src_configure() { | ||||
|  | ||||
| 	tc-export CC PKG_CONFIG | ||||
|  | ||||
| 	echo ./configure "${myconf[@]}" | ||||
| 	./configure "${myconf[@]}" || die | ||||
| 	edo ./configure "${myconf[@]}" | ||||
|  | ||||
| 	if [[ ${PV} != 9999 && ! -f dracut-version.sh ]] ; then | ||||
| 		# Source tarball from github doesn't include this file | ||||
|   | ||||
| @@ -1,35 +0,0 @@ | ||||
| https://github.com/dracutdevs/dracut/pull/2436 | ||||
|  | ||||
| From 77214c229dadd1441f0d6243221ceed0708cbfcf Mon Sep 17 00:00:00 2001 | ||||
| From: Sam James <sam@gentoo.org> | ||||
| Date: Thu, 20 Jul 2023 04:36:01 +0100 | ||||
| Subject: [PATCH] fix(dracut.sh): use gawk for strtonum | ||||
|  | ||||
| strtonum is a gawkism and is not available in all awks, e.g. mawk. Use gawk | ||||
| to avoid failure. | ||||
|  | ||||
| Fixes: f32e95bcadbc5158843530407adc1e7b700561b1 | ||||
| Signed-off-by: Sam James <sam@gentoo.org> | ||||
| --- a/dracut-functions.sh | ||||
| +++ b/dracut-functions.sh | ||||
| @@ -1047,7 +1047,7 @@ pe_file_format() { | ||||
|      if [[ $# -eq 1 ]]; then | ||||
|          local magic | ||||
|          magic=$(objdump -p "$1" \ | ||||
| -            | awk '{if ($1 == "Magic"){print strtonum("0x"$2)}}') | ||||
| +            | gawk '{if ($1 == "Magic"){print strtonum("0x"$2)}}') | ||||
|          magic=$(printf "0x%x" "$magic") | ||||
|          # 0x10b (PE32), 0x20b (PE32+) | ||||
|          [[ $magic == 0x20b || $magic == 0x10b ]] && return 0 | ||||
| --- a/dracut.sh | ||||
| +++ b/dracut.sh | ||||
| @@ -2467,7 +2467,7 @@ if [[ $uefi == yes ]]; then | ||||
|          fi | ||||
|      fi | ||||
|   | ||||
| -    offs=$(objdump -h "$uefi_stub" 2> /dev/null | awk 'NF==7 {size=strtonum("0x"$3);\ | ||||
| +    offs=$(objdump -h "$uefi_stub" 2> /dev/null | gawk 'NF==7 {size=strtonum("0x"$3);\ | ||||
|                  offset=strtonum("0x"$4)} END {print size + offset}') | ||||
|      if [[ $offs -eq 0 ]]; then | ||||
|          dfatal "Failed to get the size of $uefi_stub to create UEFI image file" | ||||
|  | ||||
| @@ -1,150 +0,0 @@ | ||||
| Combination of: | ||||
| - https://github.com/dracutdevs/dracut/pull/2405 | ||||
| - https://github.com/dracutdevs/dracut/pull/2495 | ||||
| - https://github.com/dracutdevs/dracut/pull/2521 | ||||
|  | ||||
| Fixes installing manually configured kernel in uki layout and | ||||
| allows dropping workaround from dist-kernel-utils.eclass | ||||
|  | ||||
| Provides compatibility with systemd-254's ukify plugin | ||||
|  | ||||
| --- a/dracut.sh | ||||
| +++ b/dracut.sh | ||||
| @@ -2594,6 +2594,9 @@ freeze_ok_for_fstype() { | ||||
|          zfs) | ||||
|              return 1 | ||||
|              ;; | ||||
| +        tmpfs) | ||||
| +            return 1 | ||||
| +            ;; | ||||
|          btrfs) | ||||
|              freeze_ok_for_btrfs "$outfile" | ||||
|              ;; | ||||
| --- a/install.d/50-dracut.install	2023-09-21 10:19:00.843827541 +0200 | ||||
| +++ b/install.d/50-dracut.install	2023-07-20 16:53:51.000000000 +0200 | ||||
| @@ -11,27 +11,69 @@ | ||||
|      exit 0 | ||||
|  fi | ||||
|  | ||||
| -if [[ -d "$BOOT_DIR_ABS" ]]; then | ||||
| -    INITRD="initrd" | ||||
| +# Do not attempt to create initramfs if the supplied image is already a UKI | ||||
| +if [[ "$KERNEL_INSTALL_IMAGE_TYPE" = "uki" ]]; then | ||||
| +    exit 0 | ||||
| +fi | ||||
| + | ||||
| +# Mismatching the install layout and the --uefi/--no-uefi opts just creates a mess. | ||||
| +if [[ $KERNEL_INSTALL_LAYOUT == "uki" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then | ||||
| +    BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA" | ||||
| +    if [[ -z $KERNEL_INSTALL_UKI_GENERATOR || $KERNEL_INSTALL_UKI_GENERATOR == "dracut" ]]; then | ||||
| +        # No uki generator preference set or we have been chosen | ||||
| +        IMAGE="uki.efi" | ||||
| +        UEFI_OPTS="--uefi" | ||||
| +    elif [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then | ||||
| +        # We aren't the uki generator, but we have been requested to make the initrd | ||||
| +        IMAGE="initrd" | ||||
| +        UEFI_OPTS="--no-uefi" | ||||
| +    else | ||||
| +        exit 0 | ||||
| +    fi | ||||
| +elif [[ $KERNEL_INSTALL_LAYOUT == "bls" && -n $KERNEL_INSTALL_STAGING_AREA ]]; then | ||||
| +    BOOT_DIR_ABS="$KERNEL_INSTALL_STAGING_AREA" | ||||
| +    if [[ -z $KERNEL_INSTALL_INITRD_GENERATOR || $KERNEL_INSTALL_INITRD_GENERATOR == "dracut" ]]; then | ||||
| +        IMAGE="initrd" | ||||
| +        UEFI_OPTS="--no-uefi" | ||||
| +    else | ||||
| +        exit 0 | ||||
| +    fi | ||||
|  else | ||||
| -    BOOT_DIR_ABS="/boot" | ||||
| -    INITRD="initramfs-${KERNEL_VERSION}.img" | ||||
| +    # No layout information, use users --uefi/--no-uefi preference | ||||
| +    UEFI_OPTS="" | ||||
| +    if [[ -d $BOOT_DIR_ABS ]]; then | ||||
| +        IMAGE="initrd" | ||||
| +    else | ||||
| +        BOOT_DIR_ABS="/boot" | ||||
| +        IMAGE="initramfs-${KERNEL_VERSION}.img" | ||||
| +    fi | ||||
|  fi | ||||
|  | ||||
|  ret=0 | ||||
| + | ||||
|  case "$COMMAND" in | ||||
|      add) | ||||
| -        INITRD_IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd | ||||
| -        if [[ -f ${INITRD_IMAGE_PREGENERATED} ]]; then | ||||
| -            # we found an initrd at the same place as the kernel | ||||
| +        if [[ $IMAGE == "uki.efi" ]]; then | ||||
| +            IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/uki.efi | ||||
| +        else | ||||
| +            IMAGE_PREGENERATED=${KERNEL_IMAGE%/*}/initrd | ||||
| +        fi | ||||
| +        if [[ -f ${IMAGE_PREGENERATED} ]]; then | ||||
| +            # we found an initrd or uki.efi at the same place as the kernel | ||||
|              # use this and don't generate a new one | ||||
| -            cp --reflink=auto "$INITRD_IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$INITRD" \ | ||||
| -                && chown root:root "$BOOT_DIR_ABS/$INITRD" \ | ||||
| -                && chmod 0600 "$BOOT_DIR_ABS/$INITRD" \ | ||||
| +            [[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo \ | ||||
| +                "There is an ${IMAGE} image at the same place as the kernel, skipping generating a new one" | ||||
| +            cp --reflink=auto "$IMAGE_PREGENERATED" "$BOOT_DIR_ABS/$IMAGE" \ | ||||
| +                && chown root:root "$BOOT_DIR_ABS/$IMAGE" \ | ||||
| +                && chmod 0600 "$BOOT_DIR_ABS/$IMAGE" \ | ||||
|                  && exit 0 | ||||
|          fi | ||||
|  | ||||
| -        if [[ -f /etc/kernel/cmdline ]]; then | ||||
| +        if [ -n "$KERNEL_INSTALL_CONF_ROOT" ]; then | ||||
| +            if [ -f "$KERNEL_INSTALL_CONF_ROOT/cmdline" ]; then | ||||
| +                read -r -d '' -a BOOT_OPTIONS < "$KERNEL_INSTALL_CONF_ROOT/cmdline" | ||||
| +            fi | ||||
| +        elif [[ -f /etc/kernel/cmdline ]]; then | ||||
|              read -r -d '' -a BOOT_OPTIONS < /etc/kernel/cmdline | ||||
|          elif [[ -f /usr/lib/kernel/cmdline ]]; then | ||||
|              read -r -d '' -a BOOT_OPTIONS < /usr/lib/kernel/cmdline | ||||
| @@ -40,14 +82,14 @@ | ||||
|  | ||||
|              read -r -d '' -a line < /proc/cmdline | ||||
|              for i in "${line[@]}"; do | ||||
| -                [[ "${i#initrd=*}" != "$i" ]] && continue | ||||
| +                [[ ${i#initrd=*} != "$i" ]] && continue | ||||
|                  BOOT_OPTIONS+=("$i") | ||||
|              done | ||||
|          fi | ||||
|  | ||||
|          unset noimageifnotneeded | ||||
|  | ||||
| -        for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do | ||||
| +        for ((i = 0; i < "${#BOOT_OPTIONS[@]}"; i++)); do | ||||
|              # shellcheck disable=SC1001 | ||||
|              if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then | ||||
|                  noimageifnotneeded="yes" | ||||
| @@ -55,16 +97,21 @@ | ||||
|              fi | ||||
|          done | ||||
|  | ||||
| +        # shellcheck disable=SC2046 | ||||
|          dracut -f \ | ||||
|              ${noimageifnotneeded:+--noimageifnotneeded} \ | ||||
| -            $([[ "$KERNEL_INSTALL_VERBOSE" == 1 ]] && echo --verbose) \ | ||||
| -            "$BOOT_DIR_ABS/$INITRD" \ | ||||
| -            "$KERNEL_VERSION" | ||||
| +            $([[ $KERNEL_INSTALL_VERBOSE == 1 ]] && echo --verbose) \ | ||||
| +            $([[ -n $KERNEL_IMAGE ]] && echo --kernel-image "$KERNEL_IMAGE") \ | ||||
| +            "$UEFI_OPTS" \ | ||||
| +            --kver "$KERNEL_VERSION" \ | ||||
| +            "$BOOT_DIR_ABS/$IMAGE" | ||||
|          ret=$? | ||||
| -	;; | ||||
| +        ;; | ||||
| + | ||||
|      remove) | ||||
| -        rm -f -- "$BOOT_DIR_ABS/$INITRD" | ||||
| +        rm -f -- "$BOOT_DIR_ABS/$IMAGE" | ||||
|          ret=$? | ||||
| -	;; | ||||
| +        ;; | ||||
|  esac | ||||
| + | ||||
|  exit $ret | ||||
| @@ -1,48 +0,0 @@ | ||||
| https://github.com/dracutdevs/dracut/pull/2365 | ||||
|  | ||||
| From 3462e0ac6f3562a5247bbeda2dc41eaf4e4ebf5e Mon Sep 17 00:00:00 2001 | ||||
| From: Mike Gilbert <floppym@gentoo.org> | ||||
| Date: Fri, 26 May 2023 15:56:45 -0400 | ||||
| Subject: [PATCH] Fix path to UEFI stub on split-usr systems | ||||
|  | ||||
| systemd always installs the UEFI stub in ${prefix}/lib/systemd/boot/efi. | ||||
|  | ||||
| On split-usr systems, systemdutildir is ${rootprefix}/lib/systemd, which | ||||
| makes dracut look in the wrong place. | ||||
|  | ||||
| Instead, grab 'prefix' from systemd.pc and store it in 'systemd_prefix'. | ||||
|  | ||||
| Bug: https://bugs.gentoo.org/765208 | ||||
| Signed-off-by: Mike Gilbert <floppym@gentoo.org> | ||||
| --- | ||||
|  dracut.sh | 7 ++++++- | ||||
|  1 file changed, 6 insertions(+), 1 deletion(-) | ||||
|  | ||||
| diff --git a/dracut.sh b/dracut.sh | ||||
| index bbb34697..52a83061 100755 | ||||
| --- a/dracut.sh | ||||
| +++ b/dracut.sh | ||||
| @@ -1389,6 +1389,11 @@ esac | ||||
|   | ||||
|  abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" | ||||
|   | ||||
| +[[ -n $systemd_prefix ]] \ | ||||
| +    || systemd_prefix=$(pkg-config systemd --variable=prefix 2> /dev/null) | ||||
| + | ||||
| +[[ -n $systemd_prefix ]] || systemd_prefix=/usr | ||||
| + | ||||
|  [[ -d $dracutsysrootdir$systemdutildir ]] \ | ||||
|      || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2> /dev/null) | ||||
|   | ||||
| @@ -1467,7 +1472,7 @@ if [[ ! $print_cmdline ]]; then | ||||
|          esac | ||||
|   | ||||
|          if ! [[ -s $uefi_stub ]]; then | ||||
| -            uefi_stub="$dracutsysrootdir${systemdutildir}/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" | ||||
| +            uefi_stub="$dracutsysrootdir${systemd_prefix}/lib/systemd/boot/efi/linux${EFI_MACHINE_TYPE_NAME}.efi.stub" | ||||
|          fi | ||||
|   | ||||
|          if ! [[ -s $uefi_stub ]]; then | ||||
| --  | ||||
| 2.40.1 | ||||
|  | ||||
| @@ -1,134 +0,0 @@ | ||||
| https://github.com/dracutdevs/dracut/issues/2431 | ||||
| https://github.com/dracutdevs/dracut/commit/f32e95bcadbc5158843530407adc1e7b700561b1 | ||||
|  | ||||
| From f32e95bcadbc5158843530407adc1e7b700561b1 Mon Sep 17 00:00:00 2001 | ||||
| From: Valentin Lefebvre <valentin.lefebvre@suse.com> | ||||
| Date: Mon, 13 Mar 2023 12:06:13 +0100 | ||||
| Subject: [PATCH] fix(dracut.sh): use dynamically uefi's sections offset | ||||
|  | ||||
| * Uefi section are creating by `objcopy` with hardcoded sections | ||||
| offset. This commit allow to have the correct offset between | ||||
| each part of the efi file, needed to create an UKI. Offsets | ||||
| are simply calculated so no sections overlap, as recommended | ||||
| in  https://wiki.archlinux.org/title/Unified_kernel_image#Manually | ||||
| Moreover, efi stub file's header is parsed to apply the correct | ||||
| offsets according the section alignment factor. | ||||
| * Remove EFI_SECTION_VMA_INITRD, no need anymore as initrd | ||||
| section offset dynamically calculated | ||||
|  | ||||
| Fixes dracutdevs#2275 | ||||
|  | ||||
| Signed-off-by: Valentin Lefebvre <valentin.lefebvre@suse.com> | ||||
| --- a/dracut-functions.sh | ||||
| +++ b/dracut-functions.sh | ||||
| @@ -1023,3 +1023,26 @@ get_dev_module() { | ||||
|      fi | ||||
|      echo "$dev_drivers" | ||||
|  } | ||||
| + | ||||
| +# Check if file is in PE format | ||||
| +pe_file_format() { | ||||
| +    if [[ $# -eq 1 ]]; then | ||||
| +        local magic | ||||
| +        magic=$(objdump -p "$1" \ | ||||
| +            | awk '{if ($1 == "Magic"){print strtonum("0x"$2)}}') | ||||
| +        magic=$(printf "0x%x" "$magic") | ||||
| +        # 0x10b (PE32), 0x20b (PE32+) | ||||
| +        [[ $magic == 0x20b || $magic == 0x10b ]] && return 0 | ||||
| +    fi | ||||
| +    return 1 | ||||
| +} | ||||
| + | ||||
| +# Get the sectionAlignment data from the PE header | ||||
| +pe_get_section_align() { | ||||
| +    local align_hex | ||||
| +    [[ $# -ne "1" ]] && return 1 | ||||
| +    [[ $(pe_file_format "$1") -eq 1 ]] && return 1 | ||||
| +    align_hex=$(objdump -p "$1" \ | ||||
| +        | awk '{if ($1 == "SectionAlignment"){print $2}}') | ||||
| +    echo "$((16#$align_hex))" | ||||
| +} | ||||
| --- a/dracut.sh | ||||
| +++ b/dracut.sh | ||||
| @@ -1506,7 +1506,6 @@ if [[ ! $print_cmdline ]]; then | ||||
|              exit 1 | ||||
|          fi | ||||
|          unset EFI_MACHINE_TYPE_NAME | ||||
| -        EFI_SECTION_VMA_INITRD=0x3000000 | ||||
|          case "${DRACUT_ARCH:-$(uname -m)}" in | ||||
|              x86_64) | ||||
|                  EFI_MACHINE_TYPE_NAME=x64 | ||||
| @@ -1516,8 +1515,6 @@ if [[ ! $print_cmdline ]]; then | ||||
|                  ;; | ||||
|              aarch64) | ||||
|                  EFI_MACHINE_TYPE_NAME=aa64 | ||||
| -                # aarch64 kernels are uncompressed and thus larger, so we need a bigger gap between vma sections | ||||
| -                EFI_SECTION_VMA_INITRD=0x4000000 | ||||
|                  ;; | ||||
|              *) | ||||
|                  dfatal "Architecture '${DRACUT_ARCH:-$(uname -m)}' not supported to create a UEFI executable" | ||||
| @@ -2467,29 +2464,57 @@ if [[ $uefi == yes ]]; then | ||||
|          fi | ||||
|      fi | ||||
|   | ||||
| +    offs=$(objdump -h "$uefi_stub" 2> /dev/null | awk 'NF==7 {size=strtonum("0x"$3);\ | ||||
| +                offset=strtonum("0x"$4)} END {print size + offset}') | ||||
| +    if [[ $offs -eq 0 ]]; then | ||||
| +        dfatal "Failed to get the size of $uefi_stub to create UEFI image file" | ||||
| +        exit 1 | ||||
| +    fi | ||||
| +    align=$(pe_get_section_align "$uefi_stub") | ||||
| +    if [[ $? -eq 1 ]]; then | ||||
| +        dfatal "Failed to get the sectionAlignment of the stub PE header to create the UEFI image file" | ||||
| +        exit 1 | ||||
| +    fi | ||||
| +    offs=$((offs + "$align" - offs % "$align")) | ||||
| +    [[ -s $dracutsysrootdir/usr/lib/os-release ]] && uefi_osrelease="$dracutsysrootdir/usr/lib/os-release" | ||||
| +    [[ -s $dracutsysrootdir/etc/os-release ]] && uefi_osrelease="$dracutsysrootdir/etc/os-release" | ||||
| +    [[ -s $uefi_osrelease ]] \ | ||||
| +        && uefi_osrelease_offs=${offs} \ | ||||
| +        && offs=$((offs + $(stat -Lc%s "$uefi_osrelease"))) \ | ||||
| +        && offs=$((offs + "$align" - offs % "$align")) | ||||
| + | ||||
|      if [[ $kernel_cmdline ]] || [[ $hostonly_cmdline == yes && -e "${uefi_outdir}/cmdline.txt" ]]; then | ||||
|          echo -ne "\x00" >> "$uefi_outdir/cmdline.txt" | ||||
|          dinfo "Using UEFI kernel cmdline:" | ||||
|          dinfo "$(tr -d '\000' < "$uefi_outdir/cmdline.txt")" | ||||
|          uefi_cmdline="${uefi_outdir}/cmdline.txt" | ||||
| +        uefi_cmdline_offs=${offs} | ||||
| +        offs=$((offs + $(stat -Lc%s "$uefi_cmdline"))) | ||||
| +        offs=$((offs + "$align" - offs % "$align")) | ||||
|      else | ||||
|          unset uefi_cmdline | ||||
|      fi | ||||
|   | ||||
| -    [[ -s $dracutsysrootdir/usr/lib/os-release ]] && uefi_osrelease="$dracutsysrootdir/usr/lib/os-release" | ||||
| -    [[ -s $dracutsysrootdir/etc/os-release ]] && uefi_osrelease="$dracutsysrootdir/etc/os-release" | ||||
|      if [[ -s ${dracutsysrootdir}${uefi_splash_image} ]]; then | ||||
|          uefi_splash_image="${dracutsysrootdir}${uefi_splash_image}" | ||||
| +        uefi_splash_offs=${offs} | ||||
| +        offs=$((offs + $(stat -Lc%s "$uefi_splash_image"))) | ||||
| +        offs=$((offs + "$align" - offs % "$align")) | ||||
|      else | ||||
|          unset uefi_splash_image | ||||
|      fi | ||||
|   | ||||
| +    uefi_linux_offs="${offs}" | ||||
| +    offs=$((offs + $(stat -Lc%s "$kernel_image"))) | ||||
| +    offs=$((offs + "$align" - offs % "$align")) | ||||
| +    uefi_initrd_offs="${offs}" | ||||
| + | ||||
|      if objcopy \ | ||||
| -        ${uefi_osrelease:+--add-section .osrel="$uefi_osrelease" --change-section-vma .osrel=0x20000} \ | ||||
| -        ${uefi_cmdline:+--add-section .cmdline="$uefi_cmdline" --change-section-vma .cmdline=0x30000} \ | ||||
| -        ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=0x40000} \ | ||||
| -        --add-section .linux="$kernel_image" --change-section-vma .linux=0x2000000 \ | ||||
| -        --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd="${EFI_SECTION_VMA_INITRD}" \ | ||||
| +        ${uefi_osrelease:+--add-section .osrel="$uefi_osrelease" --change-section-vma .osrel=$(printf 0x%x "$uefi_osrelease_offs")} \ | ||||
| +        ${uefi_cmdline:+--add-section .cmdline="$uefi_cmdline" --change-section-vma .cmdline=$(printf 0x%x "$uefi_cmdline_offs")} \ | ||||
| +        ${uefi_splash_image:+--add-section .splash="$uefi_splash_image" --change-section-vma .splash=$(printf 0x%x "$uefi_splash_offs")} \ | ||||
| +        --add-section .linux="$kernel_image" --change-section-vma .linux="$(printf 0x%x "$uefi_linux_offs")" \ | ||||
| +        --add-section .initrd="${DRACUT_TMPDIR}/initramfs.img" --change-section-vma .initrd="$(printf 0x%x "$uefi_initrd_offs")" \ | ||||
|          "$uefi_stub" "${uefi_outdir}/linux.efi"; then | ||||
|          if [[ -n ${uefi_secureboot_key} && -n ${uefi_secureboot_cert} ]]; then | ||||
|              if sbsign \ | ||||
| @@ -1,29 +0,0 @@ | ||||
| From 5443396f3cb591f2589888b25e07f21f03989057 Mon Sep 17 00:00:00 2001 | ||||
| From: Laszlo Gombos <laszlo.gombos@gmail.com> | ||||
| Date: Sat, 24 Dec 2022 01:48:04 +0000 | ||||
| Subject: [PATCH] When no systemd then only network-legacy is supported | ||||
|  | ||||
| Bug: https://github.com/dracutdevs/dracut/issues/1756 | ||||
| --- | ||||
|  modules.d/40network/module-setup.sh | 5 +++++ | ||||
|  1 file changed, 5 insertions(+) | ||||
|  | ||||
| diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh | ||||
| index 1ab13ef..da49947 100755 | ||||
| --- a/modules.d/40network/module-setup.sh | ||||
| +++ b/modules.d/40network/module-setup.sh | ||||
| @@ -16,6 +16,11 @@ depends() { | ||||
|          fi | ||||
|      done | ||||
|   | ||||
| +    # When systemd is not available only network-legacy is supported | ||||
| +    if [ -z "$network_handler" ] && ! find_binary systemctl > /dev/null; then | ||||
| +        network_handler="network-legacy" | ||||
| +    fi | ||||
| + | ||||
|      if [ -z "$network_handler" ]; then | ||||
|          if [[ -e $dracutsysrootdir$systemdsystemunitdir/wicked.service ]]; then | ||||
|              network_handler="network-wicked" | ||||
| --  | ||||
| 2.34.1 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user