Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions gen_bootloader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,36 @@ set_bootloader() {
grub2)
set_bootloader_grub2
;;
systemd-boot)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we just name it "systemd"?

set_bootloader_systemd
;;
*)
print_warning "Bootloader ${BOOTLOADER} is not currently supported"
;;
esac
}

set_bootloader_systemd() {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line.

if [[ ! -x `which kernel-install` ]]; then
gen_die "Unable to locate kernel-install, is systemd installed?"
fi

# Clear out the mistakenly installed copies, since kernel-install copies its own versions over
# We do this first, to prevent people thinking they have enough free space but needing twice the amount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compile_kernel() in gen_compile.sh should be modified:

@@ -416,19 +416,24 @@ compile_kernel() {

        if isTrue "${CMD_INSTALL}"
        then
-               copy_image_with_preserve "kernel" \
-                       "${tmp_kernel_binary}" \
-                       "kernel-${KNAME}-${ARCH}-${KV}"
+               if [ -n "${BOOTLOADER}" -a "${BOOTLOADER}" = "systemd" ]
+               then
+                       print_info 1 "$(getIndent 1)Not installing kernel; systemd's kernel-install will handle installation for us!"
+               else
+                       copy_image_with_preserve "kernel" \
+                               "${tmp_kernel_binary}" \
+                               "kernel-${KNAME}-${ARCH}-${KV}"

-               copy_image_with_preserve "System.map" \
-                       "${systemmap}" \
-                       "System.map-${KNAME}-${ARCH}-${KV}"
+                       copy_image_with_preserve "System.map" \
+                               "${systemmap}" \
+                               "System.map-${KNAME}-${ARCH}-${KV}"

-               if isTrue "${GENZIMAGE}"
-               then
-                       copy_image_with_preserve "kernelz" \
-                               "${tmp_kernel_binary2}" \
-                               "kernelz-${KV}"
+                       if isTrue "${GENZIMAGE}"
+                       then
+                               copy_image_with_preserve "kernelz" \
+                                       "${tmp_kernel_binary2}" \
+                                       "kernelz-${KV}"
+                       fi
                fi
        else
                cp "${tmp_kernel_binary}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it's moving bootloader logic into the compile_kernel logic. I'm happy to do that, I just figured you'd want it all stand-alone in its own little area, so that the it doesn't set a precedent for the next bootloader that comes along to start tinkering with the internals too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The suggestion was based on genkernel-3, before I decided to touch so much code and create genkernel-4. Now I think we can do it correctly: But before we are able to do that we need to tackle https://bugs.gentoo.org/505810 - i.e. I'll remove install logic from compile_* to genkernel main script. In the main script we will keep something like https://github.com/gentoo/genkernel/blob/v4.0.0_beta4/genkernel#L337, adjusted of course, which will call 1set_bootloader1 when genkernel was called with --install. We will use the case statement currently used to display a warning to decide if we have to call copy_image_with_preserve or not... then, when we finally call set_bootloader, which would call kernel-install in systemd-boot case.

You get my idea?

tl;dr
Before we get back to adding systemd-boot support, I'll have to refactor install logic. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I follow. Just give me a prod on here when it's ready for some reworking. I'm happy to pitch in, but don't want to step on your plans... 5:)

KERNEL_IMAGE=$(find_kernel_binary ${KERNEL_BINARY_OVERRIDE:-${KERNEL_BINARY}})
rm "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}"
INITRD_FILE=""
if [[ -f "${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}" ]]; then
rm "${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV}"
INITRD_FILE="${TMPDIR}/initramfs-${KV}"
fi

# Do the call
echo "Executing: kernel-install add $KV \"${KERNEL_IMAGE}\" \"${INITRD_FILE}\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use

print_info 2 "COMMAND: ${NICEOPTS}${MAKE} ${MAKEOPTS} -j1 ${ARGS} ${target} $*" 1 0 1

like command to show command..

kernel-install add $KV "${KERNEL_IMAGE}" "${INITRD_FILE}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error check, || gen_die "..."

}

set_bootloader_read_fstab() {
local ROOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "/" ) { print $1; exit }' /etc/fstab)
local BOOTFS=$(awk 'BEGIN{RS="((#[^\n]*)?\n)"}( $2 == "'${BOOTDIR}'") { print $1; exit }' /etc/fstab)
Expand Down