aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'targets/support/kmerge.sh')
-rwxr-xr-xtargets/support/kmerge.sh85
1 files changed, 71 insertions, 14 deletions
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