Commit Graph

222 Commits

Author SHA1 Message Date
Lennart Poettering
69f3c61990 tree-wide: port over various pieces of code to strv_extend_many() 2024-01-17 11:32:11 +01:00
Yu Watanabe
f8a6fc51a6 Merge pull request #30851 from lnussel/kernel-install
kernel-install fixes
2024-01-16 14:55:35 +09:00
Daan De Meyer
16e4efa7d3 tree-wide: Load entry-token and layout.conf from /usr/lib/kernel/ as well 2024-01-16 14:54:04 +09:00
Ludwig Nussel
ec9ff6ea94 kernel-install: silence num kernels installed 2024-01-15 17:16:37 +01:00
Ludwig Nussel
27d420f466 kernel-install: fix context_copy
Don't reopen or dup values that weren't set before. Fixes add-all.
2024-01-15 17:16:37 +01:00
Daan De Meyer
50cc0ee647 Add --root= support for list and prepare add-all for --root= support
Let's make sure these follow the rest of kernel-install and always
operate on the given root directory, even if the verb itself can't
support --root= just yet.
2024-01-12 14:37:00 +00:00
Antonio Alvarez Feijoo
398760c84a kernel-install: clarify what is currently supported with --root and --image
`list` and `add-all` ignore `--root` or `--image`, working on the running
system instead.
Also improve the error message if `--image` is used.
2024-01-10 12:40:35 +00:00
Antonio Alvarez Feijoo
d1b1cf8f26 kernel-install: fix memory leak 2024-01-10 09:20:15 +01:00
Zbigniew Jędrzejewski-Szmek
0b4cf0a540 Merge pull request #30232 from keszybz/ukify-imports
Use exec() to import ukify
2023-12-13 14:38:03 +01:00
Daan De Meyer
dbab005645 kernel-install: Fix inspect with --root= when no version is specified
Using the kernel version from the host is incorrect in this case, so
fix the logic so it handles no version being specified correctly with
--root=.
2023-12-11 12:06:51 +00:00
Daan De Meyer
fc7cdb2dde kernel-install: Look for uki.conf in /usr/lib/kernel as well 2023-12-11 10:29:57 +01:00
Zbigniew Jędrzejewski-Szmek
2060509d12 kernel-install/60-ukify: use exec() instead of runpy
As suggested by Daniele Nicolodi.

Also drop left-over debug line.
2023-12-01 10:30:16 +01:00
Paymon MARANDI
b99e4922ea ukify: be more explicit about where to find ukify
when KERNEL_INSTALL_UKIFY is not supplied we set ukify to $PWD/ukify

that will fail (perhaps only for manual installations):
FileNotFoundError: [Errno 2] No such file or directory: '/usr/src/linux-6.7-rc1/ukify'

this will make sure we have a sane default for UKIFY

Signed-off-by: Paymon MARANDI <paymon@utubeipod.xyz>
2023-11-25 12:53:29 +09:00
Yu Watanabe
54bc114fec kernel-install: do not resolve symlink in paths passed to plugins
When we resolve symlinks, paths (especially filenames) may be changed,
but plugins may expect to see the kernel added under the name specified,
not under the final name that the symlink chain resolves to.

This makes symlinks in specified paths that passed to plugins are not
resolved when neither --root nor --image specified.

Fixes #29317.
2023-11-21 12:57:00 +00:00
Yu Watanabe
0c710e0377 test: add test cases about plugin exit code 2023-11-20 10:17:54 +09:00
Yu Watanabe
e42931b0ac kernel-install: propagate failures in plugins
This fixes a regression introduced by
42551ea7e9.

In the shell script version, plugin failures are propagated to the
caller. But after the commit, failures in plugins are logged, but never
propagated as the exit code of the execution.

Fixes #30087.
2023-11-20 09:55:53 +09:00
Yu Watanabe
c62345ffc7 tree-wide: fix typo 2023-11-08 14:57:33 +09:00
Lennart Poettering
8353229e10 update CI 2023-11-07 16:08:06 +01:00
Lennart Poettering
758d14767d kernel-install: make "inspect" work more like "add" regarding omission of parameters
This makes "kernel-install inspect" work more "kernel-install add": if
the version or kernel image is specified as "-" or omitted we'll make it
up.
2023-11-07 16:07:57 +01:00
Lennart Poettering
ec1399f567 kernel-install: add add-all verb 2023-11-07 16:07:55 +01:00
Lennart Poettering
9d9e99a8f0 kernel-install: make version/kernel image parameters optional for "add"
Let's make kernel-install a bit easier to use:

If the kernel version is not specified, let's imply "uname -r", so that
we regnerate the entries for the current kernel.

If the kernel image is not specified let's imply using
/usr/lib/modules/$version/vmlinuz, i.e. the location distros like Fedora
drop the kernel into, which we generally recommend people to use.

If the kernel is not found there, don't try to automatically pick the
kernel path, and fail, as before.
2023-11-07 16:07:25 +01:00
Lennart Poettering
658e6cc4ae kernel-install: add command to list installed kernels
This simply dumps the dirs in /usr/lib/modules/ and whether they contain
a vmlinuz binary.
2023-11-07 16:07:05 +01:00
Daan De Meyer
04a8c2ce30 kernel-install: Add --root, --image and --image-policy
Currently only supported for the "inspect" verb as "add" and "remove"
require figuring out what to do with plugins.
2023-11-06 22:29:36 +01:00
Daan De Meyer
bdd36c003d kernel-install: Add --json option for inspect verb
In mkosi, we can't use kernel-install directly but we do want to
mimick its behavior as much as possible. Let's make that easier by
making it easy to fetch data from kernel-install as JSON.

To get all the necessary data, we extend the inspect verb to also
allow passing in a kernel version and initrds, to mimick the "add"
verb. The kernel version is used to determine the "Entry Directory",
and in absence of auto-detection of kernel version in kernel-install
we have to allow users to pass it.

We also add --no-pager while we're at it.
2023-11-06 14:43:09 +01:00
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