Commit Graph

190 Commits

Author SHA1 Message Date
cvlc12
c82cc3709e Make ukify the default ifUKI_GENERATOR is unset 2023-08-10 21:49:21 +01:00
Luca Boccassi
bd95029c3e Merge pull request #28743 from mrc0mmand/lint-python-scripts
tools: lint Python scripts
2023-08-10 19:13:45 +01:00
Frantisek Sumsal
79f902eb09 Add .pylintrc to globally suppress warnings we don't really care about
Also, drop the respective disable directives from existing files.
2023-08-10 18:13:29 +02:00
Zbigniew Jędrzejewski-Szmek
288cc26803 60-ukify.install: fix whitespace 2023-08-09 13:56:07 +02:00
Yu Watanabe
9289e093ae meson: use install_emptydir() and drop meson-make-symlink.sh
The script is mostly equivalent to 'mkdir -p' and 'ln -sfr'.
Let's replace it with install_emptydir() builtin function and
inline meson call.
2023-08-08 22:11:34 +01:00
Emil Renner Berthing
2bca841137 90-loaderentry: support installing device trees
Like the cmdline file we look for a devicetree file in
$KERNEL_INSTALL_CONF_ROOT, /etc/kernel and /usr/lib/kernel. If it is
present we look for the specified device tree that comes with the kernel
we're adding and install it into $ENTRY_DIR_ABS and add a devicetree
stanza to the loader entry.

Unfortunately it seems there is no common consensus on where to install
device tree blobs, so we have to look in a few different places for it.
2023-08-07 14:54:23 +02:00
Marc Pervaz Boocha
f3d1d7609d Teach 60-ukify.install to search the staging dir
60-ukify.install would only work with initrd provided by command line
arguements. Fixed to look for both microcode and initrd is found in
$KERNEL_INSTALL_STAGING_AREA which is placed by initrd generator like
mkinitcpio
2023-08-07 12:11:05 +02:00
Yu Watanabe
87e7979de4 meson: move declarations of kernel-install and sulogin-shell 2023-08-01 21:37:31 +09:00
Daan De Meyer
4435da1f17 kernel-install: Make sure KERNEL_INSTALL_BYPASS is disabled in tests 2023-07-31 20:58:31 +02:00
Daan De Meyer
b4afa94c5f kernel-install: Only bypass "add" and "remove"
KERNEL_INSTALL_BYPASS should only bypass verbs that actually change
the system, not harmless verbs such as "inspect".
2023-07-31 20:56:14 +02:00
Yu Watanabe
149aedb89b kernel-install: silently ignore unexpected arguments for 'remove' command
The shell script version of kernel-install silently ignored unexpected
arguments, but C version refused that. Unfortunately, Fedora's kernel
script specifies kernel file even for 'remove' command. Let's accept
extra arguments and silently ignore them to keep backward compatibility.

Fixes #28448.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2223794.
2023-07-19 07:24:36 +02:00
Daan De Meyer
a061312324 kernel-install: Avoid reopening file descriptor via /proc
kernel-install used to work without /proc mounted before the rewrite
in C. Let's restore that property by making sure we don't reopen
file descriptors via /proc. In this case, parse_env_file_fdv() calls
fdopen_independent() to get a FILE * for the given file descriptor
(which itself calls fd_reopen()). Let's avoid the call to
fdopen_independent() by using chase_and_fopenat_unlocked() which
gives us a FILE * immediately without having to reopen any file
descriptors.
2023-07-14 12:28:26 +02:00
Yu Watanabe
1782534bb1 meson: shorten code a bit 2023-06-22 14:37:24 +09:00
cvlc12
1c2c00dbb6 Fix quoting 2023-06-20 00:51:32 +01:00
cvlc12
4221065237 Add docs, improve log comments. 2023-06-19 17:34:53 +02:00
cvlc12
a6d8884120 Define 'microcode' type of initrd for the kernel-install staging area.
This allows microcode to be referenced first for UKIs and loader entries.
2023-06-18 20:38:20 +02:00
Yu Watanabe
a5ebaf7982 kernel-install: skip to read /etc/machine-info in test
We do not provide any way to override /etc/machine-info.
As the file is deprecated in kernel-install, let's skip to read it when
we test kernel-install.

Fixes #28011.
2023-06-15 18:53:29 +09:00
Zbigniew Jędrzejewski-Szmek
2b8628c704 Merge pull request #27946 from keszybz/ukify-genkey-verb
Add 'genkey' verb to ukify
2023-06-14 17:57:24 +02:00
Zbigniew Jędrzejewski-Szmek
b09a5315f5 ukify: move verb mangling to finalize_options()
This simplifies the logic: finalize_options() is the step that does the
checks and the mangling. The checks for consistency are done in more places,
so we need to pass a verb (we only have 'build', but once we add other verbs,
any would do).
2023-06-12 11:12:02 +02:00
Luca Boccassi
d45ed5bf25 Merge pull request #26848 from yuwata/kernel-install
kernel-install: rewrite in C
2023-06-08 20:23:10 +01:00
Zbigniew Jędrzejewski-Szmek
1df35a4638 ukify: simplify creation of parser
00e5933f57 made all the positional arguments
optional, so let's take advantage of this to simplify variuos callers.
2023-06-06 15:41:01 +02:00
Yu Watanabe
d1e96f2f6c test-kernel-install: add tests for --entry-token= 2023-06-05 14:23:54 +09:00
Yu Watanabe
1fd90ed3ed kernel-install: introduce --entry-token= option
For consistency with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe
88e94af2ab test-kernel-install: add tests for --make-entry-directory= 2023-06-05 14:23:54 +09:00
Yu Watanabe
b79621aa99 kernel-install: introduce --make-entry-directory= option
For consistency with bootctl. However, unlike the same option for
bootctl, defaults to 'auto' for backward compatibility.
2023-06-05 14:23:54 +09:00
Yu Watanabe
4cff5e92a9 kernel-install: add --esp-path= and --boot-path= options
Then, kernel-install takes one more step for compatibility with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe
1fd2af1ab8 kernel-install: also parse KERNEL_INSTALL_LAYOUT from /etc/machine-info
For consistency with bootctl.
2023-06-05 14:23:54 +09:00
Yu Watanabe
f7665b7f6c kernel-install: make inspect command optionally take kernel image
If the kernel image is provided, then we can inspect the kernel image
and may determine the layout based on the kernel image type.
2023-06-05 14:23:54 +09:00
Yu Watanabe
42551ea7e9 kernel-install: rewrite in C
This is mostly a one-to-one translation of kernel-install.sh, except for
the followings:
- BOOT_ROOT is searched with find_{esp,xbootldr}_and_warn().
- entry token is searched with boot_entry_token_ensure().
- inspect command verboses more information, e.g. found plugins,
  environment variables explicitly passed to plugins, arguments passed
  to plugins.
- paths specified in $KERNEL_INSTALL_PLUGINS must be absolute.
- LC_COLLATE is set to C.UTF-8 (or any specified on build time).

By writing kernel-install C, we can share the code used by bootctl or
so, and can introduce --root and/or --image options later.
2023-06-05 14:23:54 +09:00
Zbigniew Jędrzejewski-Szmek
3f80c1393e test/60-ukify: override stub location in tests
Without this, build would fail if the stub is not available in /usr/lib/.
2023-05-05 18:42:37 +02:00
Zbigniew Jędrzejewski-Szmek
f9a6cb0e13 test-kernel-install: test 60-ukify.install and 90-uki-copy.install
We install a kernel with layout=uki and uki_generator=ukify, and test
that a UKI gets installed in the expected place. The two plugins cooperate,
so it's easiest to test them together.
2023-05-05 18:42:37 +02:00
Zbigniew Jędrzejewski-Szmek
ca1abaa5c4 60-ukify: kernel-install plugin that calls ukify to create a UKI
60-ukify.install calls ukify with a config file, so singing and policies and
splash will be done through the ukify config file, without 60-ukify.install
knowing anything directly.

In meson.py, the variable for loaderentry.install.in is used just once, let's
drop it. (I guess this approach was copied from kernel_install_in, which is
used in another file.)

The general idea is based on cvlc12's #27119, but now in Python instead of
bash.
2023-05-05 18:42:37 +02:00
Zbigniew Jędrzejewski-Szmek
d3533162d1 90-loaderentry: make sure that variables are set
We unconditionally use the variables later on, so let's make sure
that they were passed as expected.
2023-05-03 12:29:40 +02:00
Yu Watanabe
0362953e9a test-kernel-install: several cleanups
- allow to run without $PROJECT_BUILD_ROOT,
- drop unnecessary export for bootctl,
- enable -x option to show commands,
- use 'test ! -e' to check the nonexistence of files,
- show more debugging logs.
2023-03-30 09:23:07 +02:00
Gertalitec
600362aa11 Define $KERNEL_INSTALL_UKI_GENERATOR
Define $KERNEL_INSTALL_UKI_GENERATOR in case one wants it to be different from $KERNEL_INSTALL_INITRD_GENERATOR. This can be useful if one wants to use mkinitcpio / Dracut to generate the initrd, but without creating the UKI so this can be left for e.g. ukify or something else. Right now these initrd generators will read /etc/kernel/install.conf and generate the UKI
2023-03-26 16:54:16 +02:00
Yu Watanabe
b0e339547f kernel-install: check all entry candidates first, then check existence of $pref/loader/entries only once
If we have multiple entries in $ENTRY_TOKEN_SEARCH, and $pref/loader/entries
exists, then previously we would always exit after the first candidate and
ignore the second and later candidates.

Follow-up for 1b43f86893.
2023-03-17 20:41:17 +09:00
Yu Watanabe
561d801370 Revert "kernel-install: also try to find $BOOT by partition GUID"
This reverts commit 41f39e2144.

From the post merge comment in #26648:

> Hmm, this is highly problematic, no? if I boot from my ssd and then
> plug in a fedora live usb stick, then there will be two ESPs around,
> the one from my ssd and the one from the live usb one, and this code
> might find the wrong one and bad things will happen
2023-03-17 20:41:17 +09:00
Luca Boccassi
25a45b0dd1 Merge pull request #26119 from kraxel/uki.install
kernel-install: improve uki handling
2023-03-08 21:25:25 +00:00
Gerd Hoffmann
3d5f0bfe4e kernel-install: handle uki installs automatically
Detect image type using "bootctl kernel-identify $kernel",
store result in KERNEL_INSTALL_IMAGE_TYPE.

Extend layout autodetection to check the kernel image type
and pick layout=uki for UKIs.

Resolves: #25822
2023-03-07 08:14:46 +01:00
Gerd Hoffmann
c7314ee7e2 90-uki-copy.install: create $BOOT/EFI/Linux directory if needed
Do not consider a missing 'Linux' subdirectory an error.
Just create it instead.
2023-03-07 08:14:46 +01:00
Luca Boccassi
41f39e2144 kernel-install: also try to find $BOOT by partition GUID
When there is nothing set up on /boot, /boot/efi or /efi, try to find the
$BOOT partition checking for the XBOOTLDR or ESP partition GUIDs.
Prefer XBOOTLDR as per BLS.

Fixes https://github.com/systemd/systemd/issues/26644
2023-03-03 10:50:57 +00:00
Luca Boccassi
3bf7e3c06e kernel-install: use log_verbose everywhere 2023-03-02 23:19:57 +00:00
Daan De Meyer
77db9ef2ab boot: Make sure we take --root into account everywhere. 2023-02-09 14:46:17 +00:00
Jan Janssen
4c181c1a33 meson: Properly install 90-uki-copy.install 2023-01-27 17:47:09 +01:00
Ludwig Nussel
8702496bfb bootctl: unlink and cleanup functions
The unlink command removes an entry from the ESP including
referenced files that are not referenced in other entries. That is
useful eg to have multiple entries that use the same kernel with
different options.

The cleanup command removes all files that are not referenced by any
entry.
2023-01-19 14:24:43 +01:00
Ludwig Nussel
5fe34dbfeb kernel-install: refactor some variables
In preparation for plugin support
2023-01-10 13:49:31 +01:00
Ludwig Nussel
dd003f1621 kernel-install: run depmod only if writeable 2023-01-05 21:46:09 +01:00
Joerg Behrmann
0ccfd3564b kernel-install: Add uki layout
Currently the kernel-install man page only documents the bls layout for use
with the boot loader spec type #1. 90-loaderentry.install uses this layout to
generate loader entries and copy the kernel image and initrd to $BOOT.

This commit documents a second layout "uki" and adds 90-uki-copy.install,
which copies a UKI "uki.efi" from the staging area or any file with the .efi
extension given on the command line to
$BOOT/EFI/Linux/$ENTRY_TOKEN-$KERNEl_VERSION(+$TRIES).efi

This allows for both locally generated and distro-provided UKIs to be handled
by kernel-install.
2022-11-29 11:33:27 +01:00
Zbigniew Jędrzejewski-Szmek
0be160136e kernel-install: add header to generate entry files
I was looking at a bug in bugzilla about some boot loader issue, and it was
hard to say if the boot entry files were generated by our plugin or something
else. Add a header to make this clear.

kernel-install invokes the plugins via absolute path always, so $0 gives as
the full path the location where the plugin is installed. This is what we want:

  title      Fedora Linux 37 (Workstation Edition)
  # Boot Loader Specification type#1 entry
  # File created by /usr/lib/kernel/install.d/90-loaderentry.install (systemd 252-409-g5028904^)
2022-11-23 10:14:25 +01:00
Zbigniew Jędrzejewski-Szmek
04fea8407c kernel-install: make 90-loadentry.install templated
It's a bit annoying that this causes so much churn, but I don't see a different
way to do this.
2022-11-22 16:12:09 +01:00