1 |
On Wed, 2021-01-13 at 11:47 -0600, Matthew Thode wrote: |
2 |
> On 21-01-13 15:35:15, Michał Górny wrote: |
3 |
> > Support dracut's uefi=yes configuration option that creates a combined |
4 |
> > UEFI stub, kernel and initramfs in a single UEFI executable. If such |
5 |
> > an output is detected, install it in place of the actual kernel image |
6 |
> > and stub out the duplicate initrd to save space. |
7 |
> > |
8 |
> > Signed-off-by: Michał Górny <mgorny@g.o> |
9 |
> > --- |
10 |
> > eclass/dist-kernel-utils.eclass | 31 ++++++++++++++++++++++++++++++- |
11 |
> > 1 file changed, 30 insertions(+), 1 deletion(-) |
12 |
> > |
13 |
> > diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass |
14 |
> > index d65dc0924b40..50ad15f8b1fd 100644 |
15 |
> > --- a/eclass/dist-kernel-utils.eclass |
16 |
> > +++ b/eclass/dist-kernel-utils.eclass |
17 |
> > @@ -41,8 +41,20 @@ dist-kernel_build_initramfs() { |
18 |
> > local output=${1} |
19 |
> > local version=${2} |
20 |
> > |
21 |
> > |
22 |
> > |
23 |
> > |
24 |
> > + local rel_image_path=$(dist-kernel_get_image_path) |
25 |
> > + local image=${output%/*}/${rel_image_path##*/} |
26 |
> > + |
27 |
> > + local args=( |
28 |
> > + --force |
29 |
> > + # if uefi=yes is used, dracut needs to locate the kernel image |
30 |
> > + --kernel-image "${image}" |
31 |
> > + |
32 |
> > + # positional arguments |
33 |
> > + "${output}" "${version}" |
34 |
> > + ) |
35 |
> > + |
36 |
> > ebegin "Building initramfs via dracut" |
37 |
> > - dracut --force "${output}" "${version}" |
38 |
> > + dracut "${args[@]}" |
39 |
> > eend ${?} || die -n "Building initramfs failed" |
40 |
> > } |
41 |
> > |
42 |
> > |
43 |
> > |
44 |
> > |
45 |
> > @@ -85,6 +97,23 @@ dist-kernel_install_kernel() { |
46 |
> > local image=${2} |
47 |
> > local map=${3} |
48 |
> > |
49 |
> > |
50 |
> > |
51 |
> > |
52 |
> > + # if dracut is used in eufi=yes mode, initrd will actually |
53 |
> > + # be a combined kernel+initramfs UEFI executable. we can easily |
54 |
> > + # recognize it by PE magic (vs cpio for a regular initramfs) |
55 |
> > + local initrd=${image%/*}/initrd |
56 |
> > + local magic |
57 |
> > + [[ -s ${initrd} ]] && read -n 2 magic < "${initrd}" |
58 |
> > + if [[ ${magic} == MZ ]]; then |
59 |
> |
60 |
> This magic header is matched by both the kernel and the new uefi |
61 |
> executible. I think a better check would be... |
62 |
> |
63 |
> if file "${image_path}" | grep -q 'EFI application'; then |
64 |
|
65 |
...but we're not testing image but initrd which can't be the kernel |
66 |
otherwise. |
67 |
|
68 |
> |
69 |
> > + einfo "Combined UEFI kernel+initramfs executable found" |
70 |
> > + # install the combined executable in place of kernel |
71 |
> > + image=${initrd}.uefi |
72 |
> > + mv "${initrd}" "${image}" || die |
73 |
> > + # put an empty file in place of initrd. installing a duplicate |
74 |
> > + # file would waste disk space, and removing it entirely provokes |
75 |
> > + # kernel-install to regenerate it via dracut. |
76 |
> > + > "${initrd}" |
77 |
> > + fi |
78 |
> > + |
79 |
> > ebegin "Installing the kernel via installkernel" |
80 |
> > # note: .config is taken relatively to System.map; |
81 |
> > # initrd relatively to bzImage |
82 |
> > -- |
83 |
> > 2.30.0 |
84 |
> |
85 |
> I want to make sure you are not overwriting the original kernel image, |
86 |
> if you do then subsiquent --config runs will include the kernel image, |
87 |
> making the final image grow. |
88 |
> |
89 |
> In order to avoid that I did some file juggling, but it looks like it's |
90 |
> cleaner here. |
91 |
|
92 |
I still don't understand why it has been overwriting the kernel for you. |
93 |
|
94 |
> |
95 |
> https://gist.github.com/prometheanfire/aeffa1c3f92d3d2af312b3b6915051fb |
96 |
> 'worked' but was kinda unclean. |
97 |
> |
98 |
> |
99 |
|
100 |
-- |
101 |
Best regards, |
102 |
Michał Górny |