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
1=== modified file 'tools/boot/focal/boot-amd64'
2--- tools/boot/focal/boot-amd64 2020-03-13 14:09:59 +0000
3+++ tools/boot/focal/boot-amd64 2020-03-24 15:59:51 +0000
4@@ -151,10 +151,15 @@
5 done
6 fi
7 if [ "$CDIMAGE_LIVE" = 1 ]; then
8- mv $CDDIR/casper/filesystem.kernel-$FLAVOUR $CDDIR/casper/vmlinuz
9 CASPER_KERNEL=/casper/vmlinuz
10- CASPER_INITRD="/casper/initrd$(initrd_suffix "$CDDIR/casper/filesystem.initrd-$FLAVOUR")"
11- mv $CDDIR/casper/filesystem.initrd-$FLAVOUR "$CDDIR$CASPER_INITRD"
12+ CASPER_INITRD=/casper/initrd
13+ for kernel in $CDDIR/casper/filesystem.kernel-*; do
14+ flavour=${kernel##*filesystem.kernel-}
15+ flavour2="-${flavour}"
16+ [ "$flavour" = "generic" ] && flavour2=""
17+ mv $CDDIR/casper/filesystem.kernel-$flavour $CDDIR$CASPER_KERNEL${flavour2}
18+ mv $CDDIR/casper/filesystem.initrd-$flavour $CDDIR$CASPER_INITRD${flavour2}
19+ done
20 fi
21 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
22 case "$MKISOFS" in
23@@ -305,6 +310,24 @@
24 rmdir boot$N/isolinux/grub
25 sed -i '/^menuentry/Q' $CDDIR/boot/grub/grub.cfg
26
27+
28+# FIXME: dmi_modalias.cfg should be shipped in grub, with autopkgtest
29+cp $BASEDIR/tools/boot/$DI_CODENAME/dmi_modalias.cfg $CDDIR/boot/grub
30+
31+# This dumps all oem meta packages in the cache, dumps their Modaliases fields,
32+# extracts all dmi: modaliases, joins them together using |, and then converts
33+# to a regular expressions by: anchoring it using ^(...)$, and converting *
34+# to .*.
35+# Then it uses grub's regexp module to match that one regex against the
36+# dmi_modalias variable that dmi_modalias.cfg generated for us.
37+cat >> $CDDIR/boot/grub/grub.cfg <<EOF
38+set casper_flavour=""
39+source \$prefix/dmi_modalias.cfg
40+if 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
41+ set casper_flavour="-oem"
42+fi
43+EOF
44+
45 if [ "$BACKPORT_KERNEL" ]; then
46 cat > $CDDIR/boot/grub/hwe-grub.cfg <<EOF
47 submenu 'Boot and Install with the HWE kernel' {
48@@ -455,16 +478,16 @@
49 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
50 menuentry "${livelabel#^}${suffix}" {
51 set gfxpayload=keep
52- linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT $QUIET $SPLASH$extra_kopt ---
53- initrd $CASPER_INITRD
54+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT $QUIET $SPLASH$extra_kopt ---
55+ initrd $CASPER_INITRD\$casper_flavour
56 }
57 EOF
58 done
59 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
60 menuentry "${livelabel#^}" {
61 set gfxpayload=keep
62- linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
63- initrd $CASPER_INITRD
64+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$liveparams$LAYERFS_PATH_OPT iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
65+ initrd $CASPER_INITRD\$casper_flavour
66 }
67 EOF
68 if [ "$NOTRYONLYDO" != "true" ]; then
69@@ -480,15 +503,15 @@
70 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
71 menuentry "Install $HUMANPROJECT${suffix}" {
72 set gfxpayload=keep
73- linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity $QUIET $SPLASH$extra_kopt ---
74- initrd $CASPER_INITRD
75+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity $QUIET $SPLASH$extra_kopt ---
76+ initrd $CASPER_INITRD\$casper_flavour
77 }
78 EOF
79 done
80 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
81 menuentry "Install $HUMANPROJECT" {
82- linux $CASPER_KERNEL $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
83- initrd $CASPER_INITRD
84+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS $DEFAULT_PRESEED$LAYERFS_PATH_OPT only-ubiquity iso-scan/filename=\${iso_path} $QUIET $SPLASH ---
85+ initrd $CASPER_INITRD\$casper_flavour
86 }
87 EOF
88 fi
89@@ -569,8 +592,8 @@
90 cat >> $CDDIR/boot/grub/${!kp}grub.cfg <<EOF
91 menuentry "OEM install (for manufacturers)" {
92 set gfxpayload=keep
93- linux $CASPER_KERNEL $KERNEL_PARAMS ${DEFAULT_PRESEED/$PREFIX_PRESEED/$PREFIX_PRESEED${!kp}}$LAYERFS_PATH_OPT only-ubiquity quiet splash oem-config/enable=true ---
94- initrd $CASPER_INITRD
95+ 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 ---
96+ initrd $CASPER_INITRD\$casper_flavour
97 }
98 EOF
99 else
100@@ -631,14 +654,14 @@
101 cat >> $CDDIR/boot/grub/grub.cfg <<EOF
102 menuentry "Check disc for defects" {
103 set gfxpayload=keep
104- linux $CASPER_KERNEL $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check quiet splash ---
105- initrd $CASPER_INITRD
106+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check quiet splash ---
107+ initrd $CASPER_INITRD\$casper_flavour
108 }
109 EOF
110 cat >> $CDDIR/boot/grub/loopback.cfg <<EOF
111 menuentry "Check disc for defects" {
112- linux $CASPER_KERNEL $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check iso-scan/filename=\${iso_path} quiet splash ---
113- initrd $CASPER_INITRD
114+ linux $CASPER_KERNEL\$casper_flavour $KERNEL_PARAMS$LAYERFS_PATH_OPT integrity-check iso-scan/filename=\${iso_path} quiet splash ---
115+ initrd $CASPER_INITRD\$casper_flavour
116 }
117 EOF
118 elif [ "$CDIMAGE_INSTALL_BASE" = 1 ]; then
119
120=== added file 'tools/boot/focal/dmi_modalias.cfg'
121--- tools/boot/focal/dmi_modalias.cfg 1970-01-01 00:00:00 +0000
122+++ tools/boot/focal/dmi_modalias.cfg 2020-03-24 15:59:51 +0000
123@@ -0,0 +1,28 @@
124+# grub dmi modalias generator. buggy.
125+#
126+# (C) 2020 Canonical Ltd.
127+# SPDX-License-Identifier: GPL-2.0
128+
129+insmod smbios
130+
131+# Extract dmi information
132+
133+smbios --type 0 --get-string 4 --linux --set dmi_bvn # DMI_BIOS_VENDOR
134+smbios --type 0 --get-string 5 --linux --set dmi_bvr # DMI_BIOS_VERSION
135+smbios --type 0 --get-string 8 --linux --set dmi_bd # DMI_BIOS_DATE
136+
137+smbios --type 1 --get-string 4 --linux --set dmi_svn # DMI_SYS_VENDOR
138+smbios --type 1 --get-string 5 --linux --set dmi_pn # DMI_PRODUCT_NAME
139+smbios --type 1 --get-string 6 --linux --set dmi_pvr # DMI_PRODUCT_VERSION
140+
141+smbios --type 2 --get-string 4 --linux --set dmi_rvn # DMI_BOARD_VENDOR
142+smbios --type 2 --get-string 5 --linux --set dmi_rn # DMI_BOARD_NAME
143+smbios --type 2 --get-string 6 --linux --set dmi_rvr # DMI_BOARD_VERSION
144+
145+smbios --type 3 --get-string 4 --linux --set dmi_cvn # DMI_CHASSIS_VENDOR
146+smbios --type 3 --get-byte 5 --set dmi_ct # DMI_CHASSIS_TYPE
147+smbios --type 3 --get-string 6 --linux --set dmi_cvr # DMI_CHASSIS_VERSION
148+
149+# Construct a modalias string
150+
151+set 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