Merge lp:~juliank/debian-cd/boot-oem-kernel into lp:~ubuntu-cdimage/debian-cd/ubun3

Proposed by Julian Andres Klode
Status: Merged
Merged at revision: 2045
Proposed branch: lp:~juliank/debian-cd/boot-oem-kernel
Merge into: lp:~ubuntu-cdimage/debian-cd/ubun3
Diff against target: 151 lines (+68/-17)
2 files modified
tools/boot/focal/boot-amd64 (+40/-17)
tools/boot/focal/dmi_modalias.cfg (+28/-0)
To merge this branch: bzr merge lp:~juliank/debian-cd/boot-oem-kernel
Reviewer Review Type Date Requested Status
Iain Lane Approve
Steve Langasek Needs Fixing
Review via email: mp+380532@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Julian Andres Klode (juliank) wrote :

This is missing the --linux argument to smbios, as I first need to upload grub with that in, but otherwise works fine.

2044. By Julian Andres Klode

focal amd64 boot: Automatically load OEM kernels (initial version)

Add support for automatically loading oem kernels to the ISO. This initial
version is not entirely correct: We should be passing --linux to smbios, but
first need to upload a grub with that patch in.

The kernels are installed so that generic kernel remains at /casper/vmlinuz,
while oem kernel (or other flavours) are installed to /casper-$flavour.

2045. By Julian Andres Klode

simplify the grub.cfg by using casper_flavour instead of casper_{kernel,initrd}

One variable is one variable less than two variables. We save two lines
and redundant stuff.

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
2046. By Julian Andres Klode

dmi_modalias.cfg: Add --linux argument to smbios executions

It has landed

2047. By Julian Andres Klode

Address review comments

Revision history for this message
Julian Andres Klode (juliank) :
Revision history for this message
Julian Andres Klode (juliank) wrote :

This may have gone hidden, but I prefer to ship dmi_modalias.cfg now rather than building an extra grub update just to ship that file, because I don't have autopkgtests for it yet, and that all takes extra time, and we gotta get moving.

2048. By Julian Andres Klode

Do not use oem kernel for Ubuntu-OEM-Kernel-Flavour default systems

If the meta package declares Ubuntu-OEM-Kernel-Flavour: default, do
not use the oem kernel, but the default one (generic, later hwe).

Revision history for this message
Iain Lane (laney) wrote :

> This may have gone hidden, but I prefer to ship dmi_modalias.cfg now rather than building an extra grub update just to ship that file

We discussed this. Julian is going to take a task (card?) to do that with the next grub update.

I'm reviewing now.

Revision history for this message
Iain Lane (laney) wrote :

Thanks. Please do take that task to fix the FIXME.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tools/boot/focal/boot-amd64'
--- tools/boot/focal/boot-amd64 2020-03-13 14:09:59 +0000
+++ tools/boot/focal/boot-amd64 2020-03-24 15:59:51 +0000
@@ -151,10 +151,15 @@
151 done151 done
152 fi152 fi
153 if [ "$CDIMAGE_LIVE" = 1 ]; then153 if [ "$CDIMAGE_LIVE" = 1 ]; then
154 mv $CDDIR/casper/filesystem.kernel-$FLAVOUR $CDDIR/casper/vmlinuz
155 CASPER_KERNEL=/casper/vmlinuz154 CASPER_KERNEL=/casper/vmlinuz
156 CASPER_INITRD="/casper/initrd$(initrd_suffix "$CDDIR/casper/filesystem.initrd-$FLAVOUR")"155 CASPER_INITRD=/casper/initrd
157 mv $CDDIR/casper/filesystem.initrd-$FLAVOUR "$CDDIR$CASPER_INITRD"156 for kernel in $CDDIR/casper/filesystem.kernel-*; do
157 flavour=${kernel##*filesystem.kernel-}
158 flavour2="-${flavour}"
159 [ "$flavour" = "generic" ] && flavour2=""
160 mv $CDDIR/casper/filesystem.kernel-$flavour $CDDIR$CASPER_KERNEL${flavour2}
161 mv $CDDIR/casper/filesystem.initrd-$flavour $CDDIR$CASPER_INITRD${flavour2}
162 done
158 fi163 fi
159 echo -n "-cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table " >> $N.mkisofs_opts164 echo -n "-cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table " >> $N.mkisofs_opts
160 case "$MKISOFS" in165 case "$MKISOFS" in
@@ -305,6 +310,24 @@
305rmdir boot$N/isolinux/grub310rmdir boot$N/isolinux/grub
306sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg311sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg
307312
313
314# FIXME: dmi_modalias.cfg should be shipped in grub, with autopkgtest
315cp $BASEDIR/tools/boot/$DI_CODENAME/dmi_modalias.cfg $CDDIR/boot/grub
316
317# This dumps all oem meta packages in the cache, dumps their Modaliases fields,
318# extracts all dmi: modaliases, joins them together using |, and then converts
319# to a regular expressions by: anchoring it using ^(...)$, and converting *
320# to .*.
321# Then it uses grub's regexp module to match that one regex against the
322# dmi_modalias variable that dmi_modalias.cfg generated for us.
323cat >> $CDDIR/boot/grub/grub.cfg <<EOF
324set casper_flavour=""
325source \$prefix/dmi_modalias.cfg
326if regexp '$($BASEDIR/tools/apt-selection cache show ^oem-.*-meta$ | grep-dctrl -v -XF Ubuntu-OEM-Kernel-Flavour default | grep-dctrl -P "" -nsModaliases | grep -o 'dmi:[^), ]*' | tr '\n' '|' | sed -E -e 's/(.*)/^(\1)$/' -e 's/\*/.*/g')' "\$dmi_modalias"; then
327 set casper_flavour="-oem"
328fi
329EOF
330
308if [ "$BACKPORT_KERNEL" ]; then331if [ "$BACKPORT_KERNEL" ]; then
309 cat > $CDDIR/boot/grub/hwe-grub.cfg <<EOF332 cat > $CDDIR/boot/grub/hwe-grub.cfg <<EOF
310submenu 'Boot and Install with the HWE kernel' {333submenu 'Boot and Install with the HWE kernel' {
@@ -455,16 +478,16 @@
455 cat >> $CDDIR/boot/grub/grub.cfg <<EOF478 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
456menuentry "${livelabel#^}${suffix}" {479menuentry "${livelabel#^}${suffix}" {
457 set gfxpayload=keep480 set gfxpayload=keep
458 linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT $QUIET $SPLASH$extra_kopt ---481 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT $QUIET $SPLASH$extra_kopt ---
459 initrd $CASPER_INITRD482 initrd $CASPER_INITRD\$casper_flavour
460}483}
461EOF484EOF
462done485done
463 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF486 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
464menuentry "${livelabel#^}" {487menuentry "${livelabel#^}" {
465 set gfxpayload=keep488 set gfxpayload=keep
466 linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} $QUIET $SPLASH ---489 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
467 initrd $CASPER_INITRD490 initrd $CASPER_INITRD\$casper_flavour
468}491}
469EOF492EOF
470 if [ "$NOTRYONLYDO" != "true" ]; then493 if [ "$NOTRYONLYDO" != "true" ]; then
@@ -480,15 +503,15 @@
480 cat >> $CDDIR/boot/grub/grub.cfg <<EOF503 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
481menuentry "Install $HUMANPROJECT${suffix}" {504menuentry "Install $HUMANPROJECT${suffix}" {
482 set gfxpayload=keep505 set gfxpayload=keep
483 linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity $QUIET $SPLASH$extra_kopt ---506 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity $QUIET $SPLASH$extra_kopt ---
484 initrd $CASPER_INITRD507 initrd $CASPER_INITRD\$casper_flavour
485}508}
486EOF509EOF
487 done510 done
488 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF511 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
489menuentry "Install $HUMANPROJECT" {512menuentry "Install $HUMANPROJECT" {
490 linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} $QUIET $SPLASH ---513 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
491 initrd $CASPER_INITRD514 initrd $CASPER_INITRD\$casper_flavour
492}515}
493EOF516EOF
494 fi517 fi
@@ -569,8 +592,8 @@
569 cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF592 cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
570menuentry "OEM install (for manufacturers)" {593menuentry "OEM install (for manufacturers)" {
571 set gfxpayload=keep594 set gfxpayload=keep
572 linux $CASPER_KERNEL $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}}$LAYERFS_PATH_OPT only-ubiquity quiet splash oem-config/enable=true ---595 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}}$LAYERFS_PATH_OPT only-ubiquity quiet splash oem-config/enable=true ---
573 initrd $CASPER_INITRD596 initrd $CASPER_INITRD\$casper_flavour
574}597}
575EOF598EOF
576else599else
@@ -631,14 +654,14 @@
631 cat >> $CDDIR/boot/grub/grub.cfg <<EOF654 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
632menuentry "Check disc for defects" {655menuentry "Check disc for defects" {
633 set gfxpayload=keep656 set gfxpayload=keep
634 linux $CASPER_KERNEL $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check quiet splash ---657 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check quiet splash ---
635 initrd $CASPER_INITRD658 initrd $CASPER_INITRD\$casper_flavour
636}659}
637EOF660EOF
638 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF661 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
639menuentry "Check disc for defects" {662menuentry "Check disc for defects" {
640 linux $CASPER_KERNEL $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check iso-scan/filename=\${iso_path} quiet splash ---663 linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check iso-scan/filename=\${iso_path} quiet splash ---
641 initrd $CASPER_INITRD664 initrd $CASPER_INITRD\$casper_flavour
642}665}
643EOF666EOF
644elif [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then667elif [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
645668
=== added file 'tools/boot/focal/dmi_modalias.cfg'
--- tools/boot/focal/dmi_modalias.cfg 1970-01-01 00:00:00 +0000
+++ tools/boot/focal/dmi_modalias.cfg 2020-03-24 15:59:51 +0000
@@ -0,0 +1,28 @@
1# grub dmi modalias generator. buggy.
2#
3# (C) 2020 Canonical Ltd.
4# SPDX-License-Identifier: GPL-2.0
5
6insmod smbios
7
8# Extract dmi information
9
10smbios --type 0 --get-string 4 --linux --set dmi_bvn # DMI_BIOS_VENDOR
11smbios --type 0 --get-string 5 --linux --set dmi_bvr # DMI_BIOS_VERSION
12smbios --type 0 --get-string 8 --linux --set dmi_bd # DMI_BIOS_DATE
13
14smbios --type 1 --get-string 4 --linux --set dmi_svn # DMI_SYS_VENDOR
15smbios --type 1 --get-string 5 --linux --set dmi_pn # DMI_PRODUCT_NAME
16smbios --type 1 --get-string 6 --linux --set dmi_pvr # DMI_PRODUCT_VERSION
17
18smbios --type 2 --get-string 4 --linux --set dmi_rvn # DMI_BOARD_VENDOR
19smbios --type 2 --get-string 5 --linux --set dmi_rn # DMI_BOARD_NAME
20smbios --type 2 --get-string 6 --linux --set dmi_rvr # DMI_BOARD_VERSION
21
22smbios --type 3 --get-string 4 --linux --set dmi_cvn # DMI_CHASSIS_VENDOR
23smbios --type 3 --get-byte 5 --set dmi_ct # DMI_CHASSIS_TYPE
24smbios --type 3 --get-string 6 --linux --set dmi_cvr # DMI_CHASSIS_VERSION
25
26# Construct a modalias string
27
28set dmi_modalias="dmi:bvn${dmi_bvn}:bvr${dmi_bvr}:bd${dmi_bd}:svn${dmi_svn}:pn${dmi_pn}:pvr${dmi_pvr}:rvn${dmi_rvn}:rn${dmi_rn}:rvr${dmi_rvr}:cvn${dmi_cvn}:ct${dmi_ct}:cvr${dmi_cvr}"

Subscribers

People subscribed via source and target branches