public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-catalyst] Patch to fix silent fail when custom subarch defined
@ 2023-08-01  8:18 Azamat H. Hackimov
  2023-08-01  8:18 ` [gentoo-catalyst] [PATCH] Implementing distkernel installation Azamat H. Hackimov
  0 siblings, 1 reply; 3+ messages in thread
From: Azamat H. Hackimov @ 2023-08-01  8:18 UTC (permalink / raw
  To: gentoo-catalyst

When custom subarch is defined ("core2", for example), it will override hostarch, and all logic for creation bootloader entries and ISO image will be broken. Introduced basearch variable that may used for these cases.
Added some die statement in some case switches for default values to prevent silent failure.

Closes: https://bugs.gentoo.org/911536



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gentoo-catalyst] [PATCH] Implementing distkernel installation
  2023-08-01  8:18 [gentoo-catalyst] Patch to fix silent fail when custom subarch defined Azamat H. Hackimov
@ 2023-08-01  8:18 ` Azamat H. Hackimov
  2023-08-22 20:38   ` Andreas K. Huettel
  0 siblings, 1 reply; 3+ messages in thread
From: Azamat H. Hackimov @ 2023-08-01  8:18 UTC (permalink / raw
  To: gentoo-catalyst; +Cc: Azamat H. Hackimov

---
 catalyst/base/stagebase.py          | 22 ++++++--
 targets/livecd-stage2/controller.sh |  5 ++
 targets/support/bootloader-setup.sh | 19 ++++++-
 targets/support/kmerge.sh           | 85 ++++++++++++++++++++++++-----
 targets/support/pre-distkmerge.sh   |  7 +++
 5 files changed, 116 insertions(+), 22 deletions(-)
 create mode 100644 targets/support/pre-distkmerge.sh

diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 057d9960..474013f1 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -695,6 +695,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
                     "boot/kernel/" + x + "/aliases",
                     "boot/kernel/" + x + "/config",
                     "boot/kernel/" + x + "/console",
+                    "boot/kernel/" + x + "/distkernel",
+                    "boot/kernel/" + x + "/dracut_args",
                     "boot/kernel/" + x + "/extraversion",
                     "boot/kernel/" + x + "/gk_action",
                     "boot/kernel/" + x + "/gk_kernargs",
@@ -717,6 +719,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
             self.settings["gk_mainargs"] = self.settings[gk_mainargs]
             del self.settings[gk_mainargs]
 
+        dracut_mainargs = prefix + "/dracut_args"
+        if dracut_mainargs in self.settings:
+            self.settings["dracut_args"] = self.settings[dracut_mainargs]
+            del self.settings[dracut_mainargs]
+
         # Ask genkernel to include b2sum if <target>/verify is set
         verify = prefix + "/verify"
         if verify in self.settings:
@@ -1554,7 +1561,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
                 self.resume.enable("build_packages")
 
     def build_kernel(self):
-        '''Build all configured kernels'''
+        """Build all configured kernels"""
         if "autoresume" in self.settings["options"] \
                 and self.resume.is_enabled("build_kernel"):
             log.notice(
@@ -1565,19 +1572,23 @@ class StageBase(TargetBase, ClearBase, GenBase):
             mynames = self.settings["boot/kernel"]
             if isinstance(mynames, str):
                 mynames = [mynames]
-            # Execute the script that sets up the kernel build environment
-            cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
             for kname in [sanitize_name(name) for name in mynames]:
+                if "boot/kernel/" + kname + "/distkernel" in self.settings:
+                    cmd([self.settings['controller_file'], 'pre-distkmerge'], env=self.env)
+                else:
+                    # Execute the script that sets up the kernel build environment
+                    cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
                 self._build_kernel(kname=kname)
             self.resume.enable("build_kernel")
 
     def _build_kernel(self, kname):
-        "Build a single configured kernel by name"
+        """Build a single configured kernel by name"""
         if "autoresume" in self.settings["options"] \
                 and self.resume.is_enabled("build_kernel_" + kname):
             log.notice('Resume point detected, skipping build_kernel '
                        'for %s operation...', kname)
             return
+
         self._copy_kernel_config(kname=kname)
 
         key = 'boot/kernel/' + kname + '/extraversion'
@@ -1587,8 +1598,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
         self._copy_initramfs_overlay(kname=kname)
 
         # Execute the script that builds the kernel
-        cmd([self.settings['controller_file'], 'kernel', kname],
-            env=self.env)
+        cmd([self.settings['controller_file'], 'kernel', kname], env=self.env)
 
         if "boot/kernel/" + kname + "/initramfs_overlay" in self.settings:
             log.notice('Cleaning up temporary overlay dir')
diff --git a/targets/livecd-stage2/controller.sh b/targets/livecd-stage2/controller.sh
index f6522e63..57d947a1 100755
--- a/targets/livecd-stage2/controller.sh
+++ b/targets/livecd-stage2/controller.sh
@@ -20,6 +20,11 @@ case $1 in
 		extract_modules ${clst_chroot_path} ${kname}
 		;;
 
+	pre-distkmerge)
+		# Install dracut
+		exec_in_chroot ${clst_shdir}/support/pre-distkmerge.sh
+		;;
+
 	preclean)
 		# Move over the motd (if applicable)
 		case ${clst_livecd_type} in
diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh
index 7fa3133f..8699779e 100755
--- a/targets/support/bootloader-setup.sh
+++ b/targets/support/bootloader-setup.sh
@@ -54,6 +54,7 @@ memtest_grub() {
 }
 
 default_append_line=(${cmdline_opts[@]} cdroot)
+default_dracut_append_line=(root=live:CDLABEL=ISOIMAGE rd.live.dir=/ rd.live.squashimg=image.squashfs)
 
 case ${clst_basearch} in
 	alpha)
@@ -115,14 +116,28 @@ case ${clst_basearch} in
 		for x in ${clst_boot_kernel}
 		do
 			eval "kernel_console=\$clst_boot_kernel_${x}_console"
+			eval "distkernel=\$clst_boot_kernel_${x}_distkernel"
 
 			echo "menuentry 'Boot LiveCD (kernel: ${x})' --class gnu-linux --class os {"  >> ${iacfg}
-			echo "	linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg}
+			if [ ${distkernel} = "yes" ]
+			then
+				echo "	search --no-floppy --set=root -l 'ISOIMAGE'" >> ${iacfg}
+				echo "	linux ${kern_subdir}/${x} ${default_dracut_append_line[@]}" >> ${iacfg}
+			else
+				echo "	linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg}
+			fi
 			echo "	initrd ${kern_subdir}/${x}.igz" >> ${iacfg}
 			echo "}" >> ${iacfg}
 			echo "" >> ${iacfg}
 			echo "menuentry 'Boot LiveCD (kernel: ${x}) (cached)' --class gnu-linux --class os {"  >> ${iacfg}
-			echo "	linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg}
+			if [ ${distkernel} = "yes" ]
+			then
+				echo "	search --no-floppy --set=root -l 'ISOIMAGE'" >> ${iacfg}
+				echo "	linux ${kern_subdir}/${x} ${default_dracut_append_line[@]} rd.live.ram=1" >> ${iacfg}
+			else
+				echo "	linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg}
+			fi
+
 			echo "	initrd ${kern_subdir}/${x}.igz" >> ${iacfg}
 			echo "}" >> ${iacfg}
 			if [ -n "${kernel_console}" ]
diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
index 20b471f1..c5beddc9 100755
--- a/targets/support/kmerge.sh
+++ b/targets/support/kmerge.sh
@@ -4,6 +4,29 @@ source /tmp/chroot-functions.sh
 
 install -d /tmp/kerncache
 
+distkmerge_get_image_path() {
+    case ${clst_basearch} in
+        amd64|x86)
+            echo arch/x86/boot/bzImage
+            ;;
+        arm64)
+            echo arch/arm64/boot/Image.gz
+            ;;
+        arm)
+            echo arch/arm/boot/zImage
+            ;;
+        hppa|ppc|ppc64)
+            echo ./vmlinux
+            ;;
+        riscv)
+            echo arch/riscv/boot/Image.gz
+            ;;
+        *)
+            die "unsupported ARCH=${clst_basearch}"
+            ;;
+    esac
+}
+
 genkernel_compile() {
 	# default genkernel args
 	GK_ARGS=(
@@ -78,8 +101,15 @@ eval "initramfs_overlay=\$clst_boot_kernel_${kname}_initramfs_overlay"
 eval "kernel_merge=\$clst_boot_kernel_${kname}_packages"
 eval "kernel_use=\$clst_boot_kernel_${kname}_use"
 eval eval kernel_gk_kernargs=( \$clst_boot_kernel_${kname}_gk_kernargs )
+eval eval kernel_dracut_kernargs=( \$clst_boot_kernel_${kname}_dracut_args )
 eval "ksource=\$clst_boot_kernel_${kname}_sources"
-[[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources"
+eval "distkernel=\$clst_boot_kernel_${kname}_distkernel"
+
+if [[ ${distkernel} = "yes" ]] ; then
+  [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-kernel"
+else
+  [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources"
+fi
 
 kernel_version=$(portageq best_visible / "${ksource}")
 
@@ -103,7 +133,11 @@ if [[ -n ${clst_KERNCACHE} ]]; then
 fi
 
 if [[ ! ${cached_kernel_found} ]]; then
-	USE=symlink run_merge --update "${ksource}"
+  if [[ ${distkernel} = "yes" ]] ; then
+USE="-initramfs" run_merge --update "${ksource}"
+  else
+USE="symlink" run_merge --update "${ksource}"
+  fi
 fi
 
 if [[ -n ${clst_KERNCACHE} ]]; then
@@ -117,20 +151,43 @@ if [[ -n ${clst_KERNCACHE} ]]; then
 	ln -snf "${SOURCESDIR}" /usr/src/linux
 fi
 
-if [[ -n ${clst_kextraversion} ]]; then
-	echo "Setting EXTRAVERSION to ${clst_kextraversion}"
-
-	if [[ -e /usr/src/linux/Makefile.bak ]]; then
-		cp /usr/src/linux/Makefile{.bak,}
-	else
-		cp /usr/src/linux/Makefile{,.bak}
-	fi
-	sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \
-		/usr/src/linux/Makefile
+if [[ ${distkernel} = "yes" ]] ; then
+  # Kernel already built, let's run dracut to make initramfs
+  distkernel_source_path=$(equery -Cq f ${ksource} | grep "/usr/src/linux-" -m1)
+  distkernel_image_path=$(distkmerge_get_image_path)
+  distkernel_version=${distkernel_source_path##"/usr/src/linux-"}
+
+  DRACUT_ARGS=(
+    "${kernel_dracut_kernargs[@]}"
+    --force
+    --kernel-image="${distkernel_source_path}/${distkernel_image_path}"
+    --kver="${distkernel_version}"
+  )
+
+  dracut "${DRACUT_ARGS[@]}" || exit 1
+
+  # Create minkernel package to mimic genkernel's behaviour
+  cd /boot
+  tar jcvf /tmp/kerncache/${kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 System.map* config* initramfs* vmlinuz*
+  cd /
+  tar jcvf /tmp/kerncache/${kname}-modules-${clst_version_stamp}.tar.bz2 lib/modules
+
+else
+  if [[ -n ${clst_kextraversion} ]]; then
+    echo "Setting EXTRAVERSION to ${clst_kextraversion}"
+
+    if [[ -e /usr/src/linux/Makefile.bak ]]; then
+      cp /usr/src/linux/Makefile{.bak,}
+    else
+      cp /usr/src/linux/Makefile{,.bak}
+    fi
+    sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \
+      /usr/src/linux/Makefile
+  fi
+
+  genkernel_compile
 fi
 
-genkernel_compile
-
 # Write out CONFIG, USE, VERSION, and EXTRAVERSION files
 if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then
 	pushd "/tmp/kerncache/${kname}" >/dev/null
diff --git a/targets/support/pre-distkmerge.sh b/targets/support/pre-distkmerge.sh
new file mode 100644
index 00000000..08409a93
--- /dev/null
+++ b/targets/support/pre-distkmerge.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+RUN_DEFAULT_FUNCS="yes"
+
+source /tmp/chroot-functions.sh
+
+run_merge --oneshot sys-kernel/dracut
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [gentoo-catalyst] [PATCH] Implementing distkernel installation
  2023-08-01  8:18 ` [gentoo-catalyst] [PATCH] Implementing distkernel installation Azamat H. Hackimov
@ 2023-08-22 20:38   ` Andreas K. Huettel
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas K. Huettel @ 2023-08-22 20:38 UTC (permalink / raw
  To: gentoo-catalyst

[-- Attachment #1: Type: text/plain, Size: 11329 bytes --]

Thanks, pushed! -a

Am Dienstag, 1. August 2023, 10:18:31 CEST schrieb Azamat H. Hackimov:
> ---
>  catalyst/base/stagebase.py          | 22 ++++++--
>  targets/livecd-stage2/controller.sh |  5 ++
>  targets/support/bootloader-setup.sh | 19 ++++++-
>  targets/support/kmerge.sh           | 85 ++++++++++++++++++++++++-----
>  targets/support/pre-distkmerge.sh   |  7 +++
>  5 files changed, 116 insertions(+), 22 deletions(-)
>  create mode 100644 targets/support/pre-distkmerge.sh
> 
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index 057d9960..474013f1 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -695,6 +695,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                      "boot/kernel/" + x + "/aliases",
>                      "boot/kernel/" + x + "/config",
>                      "boot/kernel/" + x + "/console",
> +                    "boot/kernel/" + x + "/distkernel",
> +                    "boot/kernel/" + x + "/dracut_args",
>                      "boot/kernel/" + x + "/extraversion",
>                      "boot/kernel/" + x + "/gk_action",
>                      "boot/kernel/" + x + "/gk_kernargs",
> @@ -717,6 +719,11 @@ class StageBase(TargetBase, ClearBase, GenBase):
>              self.settings["gk_mainargs"] = self.settings[gk_mainargs]
>              del self.settings[gk_mainargs]
>  
> +        dracut_mainargs = prefix + "/dracut_args"
> +        if dracut_mainargs in self.settings:
> +            self.settings["dracut_args"] = self.settings[dracut_mainargs]
> +            del self.settings[dracut_mainargs]
> +
>          # Ask genkernel to include b2sum if <target>/verify is set
>          verify = prefix + "/verify"
>          if verify in self.settings:
> @@ -1554,7 +1561,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
>                  self.resume.enable("build_packages")
>  
>      def build_kernel(self):
> -        '''Build all configured kernels'''
> +        """Build all configured kernels"""
>          if "autoresume" in self.settings["options"] \
>                  and self.resume.is_enabled("build_kernel"):
>              log.notice(
> @@ -1565,19 +1572,23 @@ class StageBase(TargetBase, ClearBase, GenBase):
>              mynames = self.settings["boot/kernel"]
>              if isinstance(mynames, str):
>                  mynames = [mynames]
> -            # Execute the script that sets up the kernel build environment
> -            cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
>              for kname in [sanitize_name(name) for name in mynames]:
> +                if "boot/kernel/" + kname + "/distkernel" in self.settings:
> +                    cmd([self.settings['controller_file'], 'pre-distkmerge'], env=self.env)
> +                else:
> +                    # Execute the script that sets up the kernel build environment
> +                    cmd([self.settings['controller_file'], 'pre-kmerge'], env=self.env)
>                  self._build_kernel(kname=kname)
>              self.resume.enable("build_kernel")
>  
>      def _build_kernel(self, kname):
> -        "Build a single configured kernel by name"
> +        """Build a single configured kernel by name"""
>          if "autoresume" in self.settings["options"] \
>                  and self.resume.is_enabled("build_kernel_" + kname):
>              log.notice('Resume point detected, skipping build_kernel '
>                         'for %s operation...', kname)
>              return
> +
>          self._copy_kernel_config(kname=kname)
>  
>          key = 'boot/kernel/' + kname + '/extraversion'
> @@ -1587,8 +1598,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
>          self._copy_initramfs_overlay(kname=kname)
>  
>          # Execute the script that builds the kernel
> -        cmd([self.settings['controller_file'], 'kernel', kname],
> -            env=self.env)
> +        cmd([self.settings['controller_file'], 'kernel', kname], env=self.env)
>  
>          if "boot/kernel/" + kname + "/initramfs_overlay" in self.settings:
>              log.notice('Cleaning up temporary overlay dir')
> diff --git a/targets/livecd-stage2/controller.sh b/targets/livecd-stage2/controller.sh
> index f6522e63..57d947a1 100755
> --- a/targets/livecd-stage2/controller.sh
> +++ b/targets/livecd-stage2/controller.sh
> @@ -20,6 +20,11 @@ case $1 in
>  		extract_modules ${clst_chroot_path} ${kname}
>  		;;
>  
> +	pre-distkmerge)
> +		# Install dracut
> +		exec_in_chroot ${clst_shdir}/support/pre-distkmerge.sh
> +		;;
> +
>  	preclean)
>  		# Move over the motd (if applicable)
>  		case ${clst_livecd_type} in
> diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh
> index 7fa3133f..8699779e 100755
> --- a/targets/support/bootloader-setup.sh
> +++ b/targets/support/bootloader-setup.sh
> @@ -54,6 +54,7 @@ memtest_grub() {
>  }
>  
>  default_append_line=(${cmdline_opts[@]} cdroot)
> +default_dracut_append_line=(root=live:CDLABEL=ISOIMAGE rd.live.dir=/ rd.live.squashimg=image.squashfs)
>  
>  case ${clst_basearch} in
>  	alpha)
> @@ -115,14 +116,28 @@ case ${clst_basearch} in
>  		for x in ${clst_boot_kernel}
>  		do
>  			eval "kernel_console=\$clst_boot_kernel_${x}_console"
> +			eval "distkernel=\$clst_boot_kernel_${x}_distkernel"
>  
>  			echo "menuentry 'Boot LiveCD (kernel: ${x})' --class gnu-linux --class os {"  >> ${iacfg}
> -			echo "	linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg}
> +			if [ ${distkernel} = "yes" ]
> +			then
> +				echo "	search --no-floppy --set=root -l 'ISOIMAGE'" >> ${iacfg}
> +				echo "	linux ${kern_subdir}/${x} ${default_dracut_append_line[@]}" >> ${iacfg}
> +			else
> +				echo "	linux ${kern_subdir}/${x} ${default_append_line[@]}" >> ${iacfg}
> +			fi
>  			echo "	initrd ${kern_subdir}/${x}.igz" >> ${iacfg}
>  			echo "}" >> ${iacfg}
>  			echo "" >> ${iacfg}
>  			echo "menuentry 'Boot LiveCD (kernel: ${x}) (cached)' --class gnu-linux --class os {"  >> ${iacfg}
> -			echo "	linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg}
> +			if [ ${distkernel} = "yes" ]
> +			then
> +				echo "	search --no-floppy --set=root -l 'ISOIMAGE'" >> ${iacfg}
> +				echo "	linux ${kern_subdir}/${x} ${default_dracut_append_line[@]} rd.live.ram=1" >> ${iacfg}
> +			else
> +				echo "	linux ${kern_subdir}/${x} ${default_append_line[@]} docache" >> ${iacfg}
> +			fi
> +
>  			echo "	initrd ${kern_subdir}/${x}.igz" >> ${iacfg}
>  			echo "}" >> ${iacfg}
>  			if [ -n "${kernel_console}" ]
> diff --git a/targets/support/kmerge.sh b/targets/support/kmerge.sh
> index 20b471f1..c5beddc9 100755
> --- a/targets/support/kmerge.sh
> +++ b/targets/support/kmerge.sh
> @@ -4,6 +4,29 @@ source /tmp/chroot-functions.sh
>  
>  install -d /tmp/kerncache
>  
> +distkmerge_get_image_path() {
> +    case ${clst_basearch} in
> +        amd64|x86)
> +            echo arch/x86/boot/bzImage
> +            ;;
> +        arm64)
> +            echo arch/arm64/boot/Image.gz
> +            ;;
> +        arm)
> +            echo arch/arm/boot/zImage
> +            ;;
> +        hppa|ppc|ppc64)
> +            echo ./vmlinux
> +            ;;
> +        riscv)
> +            echo arch/riscv/boot/Image.gz
> +            ;;
> +        *)
> +            die "unsupported ARCH=${clst_basearch}"
> +            ;;
> +    esac
> +}
> +
>  genkernel_compile() {
>  	# default genkernel args
>  	GK_ARGS=(
> @@ -78,8 +101,15 @@ eval "initramfs_overlay=\$clst_boot_kernel_${kname}_initramfs_overlay"
>  eval "kernel_merge=\$clst_boot_kernel_${kname}_packages"
>  eval "kernel_use=\$clst_boot_kernel_${kname}_use"
>  eval eval kernel_gk_kernargs=( \$clst_boot_kernel_${kname}_gk_kernargs )
> +eval eval kernel_dracut_kernargs=( \$clst_boot_kernel_${kname}_dracut_args )
>  eval "ksource=\$clst_boot_kernel_${kname}_sources"
> -[[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources"
> +eval "distkernel=\$clst_boot_kernel_${kname}_distkernel"
> +
> +if [[ ${distkernel} = "yes" ]] ; then
> +  [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-kernel"
> +else
> +  [[ -z ${ksource} ]] && ksource="sys-kernel/gentoo-sources"
> +fi
>  
>  kernel_version=$(portageq best_visible / "${ksource}")
>  
> @@ -103,7 +133,11 @@ if [[ -n ${clst_KERNCACHE} ]]; then
>  fi
>  
>  if [[ ! ${cached_kernel_found} ]]; then
> -	USE=symlink run_merge --update "${ksource}"
> +  if [[ ${distkernel} = "yes" ]] ; then
> +USE="-initramfs" run_merge --update "${ksource}"
> +  else
> +USE="symlink" run_merge --update "${ksource}"
> +  fi
>  fi
>  
>  if [[ -n ${clst_KERNCACHE} ]]; then
> @@ -117,20 +151,43 @@ if [[ -n ${clst_KERNCACHE} ]]; then
>  	ln -snf "${SOURCESDIR}" /usr/src/linux
>  fi
>  
> -if [[ -n ${clst_kextraversion} ]]; then
> -	echo "Setting EXTRAVERSION to ${clst_kextraversion}"
> -
> -	if [[ -e /usr/src/linux/Makefile.bak ]]; then
> -		cp /usr/src/linux/Makefile{.bak,}
> -	else
> -		cp /usr/src/linux/Makefile{,.bak}
> -	fi
> -	sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \
> -		/usr/src/linux/Makefile
> +if [[ ${distkernel} = "yes" ]] ; then
> +  # Kernel already built, let's run dracut to make initramfs
> +  distkernel_source_path=$(equery -Cq f ${ksource} | grep "/usr/src/linux-" -m1)
> +  distkernel_image_path=$(distkmerge_get_image_path)
> +  distkernel_version=${distkernel_source_path##"/usr/src/linux-"}
> +
> +  DRACUT_ARGS=(
> +    "${kernel_dracut_kernargs[@]}"
> +    --force
> +    --kernel-image="${distkernel_source_path}/${distkernel_image_path}"
> +    --kver="${distkernel_version}"
> +  )
> +
> +  dracut "${DRACUT_ARGS[@]}" || exit 1
> +
> +  # Create minkernel package to mimic genkernel's behaviour
> +  cd /boot
> +  tar jcvf /tmp/kerncache/${kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 System.map* config* initramfs* vmlinuz*
> +  cd /
> +  tar jcvf /tmp/kerncache/${kname}-modules-${clst_version_stamp}.tar.bz2 lib/modules
> +
> +else
> +  if [[ -n ${clst_kextraversion} ]]; then
> +    echo "Setting EXTRAVERSION to ${clst_kextraversion}"
> +
> +    if [[ -e /usr/src/linux/Makefile.bak ]]; then
> +      cp /usr/src/linux/Makefile{.bak,}
> +    else
> +      cp /usr/src/linux/Makefile{,.bak}
> +    fi
> +    sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" \
> +      /usr/src/linux/Makefile
> +  fi
> +
> +  genkernel_compile
>  fi
>  
> -genkernel_compile
> -
>  # Write out CONFIG, USE, VERSION, and EXTRAVERSION files
>  if [[ -n ${clst_KERNCACHE} && ! ${cached_kernel_found} ]]; then
>  	pushd "/tmp/kerncache/${kname}" >/dev/null
> diff --git a/targets/support/pre-distkmerge.sh b/targets/support/pre-distkmerge.sh
> new file mode 100644
> index 00000000..08409a93
> --- /dev/null
> +++ b/targets/support/pre-distkmerge.sh
> @@ -0,0 +1,7 @@
> +#!/bin/bash
> +
> +RUN_DEFAULT_FUNCS="yes"
> +
> +source /tmp/chroot-functions.sh
> +
> +run_merge --oneshot sys-kernel/dracut
> 


-- 
Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer
(council, toolchain, base-system, perl, libreoffice)

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 981 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-22 20:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-01  8:18 [gentoo-catalyst] Patch to fix silent fail when custom subarch defined Azamat H. Hackimov
2023-08-01  8:18 ` [gentoo-catalyst] [PATCH] Implementing distkernel installation Azamat H. Hackimov
2023-08-22 20:38   ` Andreas K. Huettel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox