Commit Graph

198 Commits

Author SHA1 Message Date
Daan De Meyer
4f5278eead kernel-install: Log location that uki is installed in
Let's log where we install a UKI when running in verbose mode.
2023-11-05 15:26:20 +00:00
Marc Pervaz Boocha
abca74cb48 Fixed a typo in kernel-install/60-ukify.install.in for globing microcode
searches in a non-existent micocode/* dir instead of micocode* due a typo in #28592
2023-11-01 12:44:52 +09:00
Zbigniew Jędrzejewski-Szmek
02d8d787f3 kernel-install/60-ukify: also support the convention with 'devicetree' file
Requested in https://github.com/systemd/systemd/pull/28582#issuecomment-1673300596.
The is the last requested changed, so fixes #28771.

90-loaderentry.install is modified to also check $KERNEL_INSTALL_CONF_ROOT
when looking for the devicetree file. For normal use this is probably not
needed, but it's nice to be consistent and it also makes it much easier to
write the tests.

In tests, also do 'ukify inspect' now that we have it.
2023-10-11 17:34:43 +02:00
Zbigniew Jędrzejewski-Szmek
40c0c9d4bc kernel-install/60-ukify: add helper function for locating input files
Also rename config_file_location() to uki_conf_location() to make
it obvious which config file was meant.
2023-10-11 17:34:43 +02:00
Zbigniew Jędrzejewski-Szmek
91767ab082 kernel-install/90-loaderentry: do not read dtbs from /boot
/boot is not trusted, so we shouldn't use load files from there. Also, space in
/boot is limited, so it doesn't make sense to install the files under one
location there and then copy them to a different location. We should only copy
the files from /usr somewhere and then install it in the appropriate place under
/boot.

Also use "/usr/lib" instead of the "/lib" prefix. We don't support unmerged-user
anymore.

Addresses some of the feedback in
https://github.com/systemd/systemd/pull/28582#discussion_r1285820556.
2023-10-11 17:28:29 +02:00
Zbigniew Jędrzejewski-Szmek
eb25844f83 kernel-install: describe usage as installkernel
For us, this is a compatibility mode, but most likely it is there to stay: the
kernel Makefile's install target expects to be able to call /bin/installkernel.
We want people who build their own kernels to use this, so that they use
kernel-install and get support for all the functionality provided by it,
including building of UKIs and other new features. So let's actually advertise
that this exists and works.
2023-09-28 12:40:28 +02:00
Zbigniew Jędrzejewski-Szmek
f65aa477d9 ukify: move to /usr/bin and mark as non non-experimental
The notice in the man page is removed and the tool is moved into the $PATH.
A compat symlink is provided.

It is fairly widely used now, and realistically we need to keep backwards
compat or people will be very unhappy.
2023-08-29 15:16:35 +03:00
Zbigniew Jędrzejewski-Szmek
d66ad6ff85 sd-id128: introduce ERRNO_IS_NEG_MACHINE_ID_UNSET 2023-08-16 12:52:56 +02:00
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