Commit Graph

65 Commits

Author SHA1 Message Date
Yu Watanabe cd0d230e7b kernel-install: drop redundant "/"
Follow-up for 1cdbff1c84.

After the commit 1cdbff1c84, each entry .conf contains
redundant slash like the following:
```
$ cat xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-5.9.8-200.fc33.x86_64.conf
title      Fedora 33 (Thirty Three)
version    5.9.8-200.fc33.x86_64
machine-id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
options    root=/dev/nvme0n1p2 ro rootflags=subvol=system/fedora selinux=0 audit=0
linux      //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/5.9.8-200.fc33.x86_64/linux
initrd     //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/5.9.8-200.fc33.x86_64/initrd
```
2020-11-24 11:18:40 +01:00
Jörg Thalheim d7aa78c32f meson: add option to skip installing to $sysconfdir
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to https://github.com/systemd/systemd/pull/17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
2020-11-12 11:21:46 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek c3bbc90b4a
Merge pull request #16777 from DaanDeMeyer/kernel-install-followup
kernel-install: "Linux" => "Default" and reuse $BOOT/Default if it already exists
2020-08-25 09:30:44 +02:00
Daan De Meyer 2c46d523ac kernel-install: Reuse $BOOT/Default if it already exists
Avoids duplicate installation problems when the machine ID is
initialized after a kernel is already installed under $BOOT/Default.
2020-08-24 19:24:19 +01:00
Daan De Meyer 6426c98ac5 kernel-install: Use "Default" as fallback instead of "Linux"
"Linux" conflicts /efi/Linux when /efi is the install location.
/efi/Linux is already reserved for unified kernel images so we can't use
it for type #1 images. Instead, we use "Default".
2020-08-24 19:22:11 +01:00
Zbigniew Jędrzejewski-Szmek 2aed63f427 tree-wide: fix spelling of "fallback"
Similarly to "setup" vs. "set up", "fallback" is a noun, and "fall back"
is the verb. (This is pretty clear when we construct a sentence in the
present continous: "we are falling back" not "we are fallbacking").
2020-08-20 17:45:32 +02:00
Daan De Meyer 6f77906ad3 kernel-install: Add fallback to "Linux" if no machine-id is found
This allows kernel-install to be used by image builders such as mkosi
which don't have a machine-id available when they call kernel-install.
2020-08-10 19:56:32 +01:00
Kir Kolyshkin 1cdbff1c84 kernel-install/90-loaderentry: fix when /boot is not mountpoint
I happen to have a machine where /boot is not a separate mountpoint,
but rather just a directory under /. After upgrade to recent Fedora,
I found out that grub2 can't find any new kernels.

This happens because loadentry script generates kernel and initrd file
paths relative to /boot, while grub2 expects path to be relative to the
root of filesystem on which they are residing.

This commit fixes this issue by using stat's %m to find the mount point
of a partition holding the images, and using it as a prefix to be
removed from ENTRY_DIR_ABS.

Note that %m for stat requires coreutils 8.6, released in Oct 2010.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-08-03 10:01:03 +02:00
Zbigniew Jędrzejewski-Szmek 3ac33bc966 kernel-install: extend --help 2020-06-05 16:34:05 +02:00
Jakov Smolic 5fa5c3e2d0 Add meson build option to prevent building kernel-install
This commit introduces new meson build option "kernel-install" to prevent kernel-install from building if the user
sets the added option as "false".
Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr>
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
2020-04-14 20:22:32 +02:00
Jörg Thalheim ff12a7954c treewide: more portable bash shebangs
As in 2a5fcfae02
and in 3e67e5c992
using /usr/bin/env allows bash to be looked up in PATH
rather than being hard-coded.

As with the previous changes the same arguments apply
- distributions have scripts to rewrite shebangs on installation and
  they know what locations to rely on.
- For tests/compilation we should rather rely on the user to have setup
  there PATH correctly.

In particular this makes testing from git easier on NixOS where do not provide
/bin/bash to improve compose-ability.
2020-03-05 17:27:07 +01:00
Zbigniew Jędrzejewski-Szmek e60228bf68 kernel-install: strip BOOT_IMAGE= from kernel options
https://bugzilla.redhat.com/show_bug.cgi?id=1716164.
2020-02-26 23:34:41 +01:00
Zbigniew Jędrzejewski-Szmek 88e1306af6 kernel-install: do not require non-empty kernel cmdline
When booting with Fedora-Server-dvd-x86_64-30-20190411.n.0.iso,
/proc/cmdline is empty (libvirt, qemu host with bios, not sure if that
matters), after installation to disk, anaconda would "crash" in kernel-core
%posttrans, after calling kernel-install, because dracut would fail
with

> Could not determine the kernel command line parameters.
> Please specify the kernel command line in /etc/kernel/cmdline!

I guess it's legitimate, even if unusual, to have no cmdline parameters.
Two changes are done in this patch:

1. do not fail if the cmdline is empty.
2. if /usr/lib/kernel/cmdline or /etc/kernel/cmdline are present, but
   empty, ignore /proc/cmdline. If there's explicit configuration to
   have empty cmdline, don't ignore it.

The same change was done in dracut:
https://github.com/dracutdevs/dracut/pull/561.
2019-08-27 18:30:49 +02:00
Zbigniew Jędrzejewski-Szmek 51be9a8c41 kernel-install: add a check that the vmlinuz arg is sane 2019-04-03 11:25:40 +02:00
Zbigniew Jędrzejewski-Szmek cf73f65089 kernel-install: create the entry directory only if $BOOT/$MACHINE_ID exists
Things are currently fairly ugly in Fedora: we create $BOOT/$MACHINE_ID/$KERNEL_VERSION/,
and then 20-grub.install that is installed by grub2-common.rpm wants to remove that
directory before 50-dracut.install get a chance to run. 50-dracut.install
checks for the presence of that directory to decide where to install the
kernel. So let's make the creation of the directory conditional. Previous
commit changes bootctl install to create $BOOT/$MACHINE_ID, and this commit
makes kernel-install not create it. In effect, the entry directory will only be
created if 'bootctl install' or something else created the parent directory.

https://bugzilla.redhat.com/show_bug.cgi?id=1648907
2019-03-12 09:45:16 +01:00
Zbigniew Jędrzejewski-Szmek d271c5d345 kernel-install: rename $BOOT_DIR[_ABS] to $ENTRY_DIR[_ABS]
"BOOT" is misleading, because it sounds like this refers to /boot or $BOOT,
when in fact it refers to some subdirectory. Those variable names are purely
interal, so we can change them. $BOOT_DIR_ABS was used in NEWS, but it should
not be (because it is an internal detail), so the old NEWS entry is reworded to
use "entry directory".
2019-03-12 09:45:16 +01:00
Zbigniew Jędrzejewski-Szmek 7054308a8d kernel-install: add --verbose
This makes it easier to see what is going on. Documentation for
--verbose and --help is added to the man page. Our plugins are updated
to also log a bit.
2019-03-11 15:49:53 +01:00
Zbigniew Jędrzejewski-Szmek 7061e4ca00 kernel-install/50-depmod: use standard header 2019-03-11 15:46:36 +01:00
Marc-Antoine Perennou d279b185c0 kernel-install: fix dracut initrd detection (240 backward compatibility) (#11570)
* kernel-install: fix initrd when called as installkernel

Running make install from the kernel runs e.g.:
installkernel 4.20.5 arch/x86/boot/bzImage System.map "/boot"

Since 0912c0b80e this would
cal 90-loaderentry.install with those arguments:
add 4.20.5 /boot/... arch/x86/boot/bzImage System.map "/boot"

The two last arguments would then be handled as the initrd files.
As System.map exists in current directory but not in /boot/...
it would get copied there, and used as initrd intead of the initrd
which has been generated by dracut.

With this change, nothing changes when kernel-install is called
directly, but when it's called as installkernel, we now pass
thos arguments to 90-loaderentry.install:
add 4.20.5 /boot/... arch/x86/boot/bzImage initrd
initrd is thus detected as the file to use for the initrd, and as it
exists, nothing is copied over and the initrd line generated is
consistent with what one would expect

* kernel-install: fix dracut initrd detection when called directly

This brings back the systemd 240 behaviour when called directly too

* kernel-install: unify initrd fallback

* kernel-install: move initrd fallback handling to 90-loaderentry.install

* kernel-install: move initrd fallback just before creating loader entry
2019-01-27 17:32:21 +01:00
Mike Auty 0912c0b80e Add multiple initrd file support to kernel-install
Instead of having just a single INITRD field, add support for all
additional parameters being INITRD fields in order.

Signed-off-by: Mike Auty <mike.auty@gmail.com>
2019-01-18 13:49:52 +01:00
ikelos 04ca4d191b Improve kernel-install support for initrd files. (#11281)
The current support in kernel-install for initrd images doesn't copy
over the initrd file or allow a means for it to be specified (it
requires a specific filename in a particular directory).

This patchset adds support for (optionally) providing the name of
initial ramdisk file to copied over and used by kernel-install.
2018-12-30 04:01:10 +09:00
Lennart Poettering bf7b6d28c3 kernel-install: teach bot loader spec entry generator to generate entries with "tries"
This makes two changes:

1. When called for "remove" any drop-ins with "+" suffix are removed
   too, so that the logic works for entries with boot counting enabled
   too and we don't lose track of configuration snippets created that
   way.

2. When called for "add" we optionally generate a "+" suffix, based on
   the data in /etc/kernel/tries if it exists.

   This basically means after "echo 5 > /etc/kernel/tries" any installed
   kernels will automatically set up for 5 boot tries before older
   kernels will be tried.
2018-10-19 22:34:50 +02:00
Marc-Antoine Perennou 8e7ab35744 kernel-install: don't try to run depmod when kernel doesn't support modules
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2018-08-08 10:42:04 +02:00
Zbigniew Jędrzejewski-Szmek 25612ecba4 tree-wide: drop copyright lines for more authors
Acks in https://github.com/systemd/systemd/issues/9320.
2018-06-22 16:39:45 +02:00
Zbigniew Jędrzejewski-Szmek 0cd41d4dff Drop my copyright headers
perl -i -0pe 's/\s*Copyright © .... Zbigniew Jędrzejewski.*?\n/\n/gms' man/*xml
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/(#\n)?# +Copyright © [0-9, -]+ Zbigniew Jędrzejewski.*?\n//gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s*\/\*\*\*\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*?\s*\*\*\*\/\s*/\n\n/gms'
git grep -e 'Copyright.*Jędrzejewski' -l | xargs perl -i -0pe 's/\s+Copyright © [0-9, -]+ Zbigniew Jędrzejewski[^\n]*//gms'
2018-06-14 13:03:20 +02:00
Lennart Poettering 96b2fb93c5 tree-wide: beautify remaining copyright statements
Let's unify an beautify our remaining copyright statements, with a
unicode ©. This means our copyright statements are now always formatted
the same way. Yay.
2018-06-14 10:20:21 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Javier Martinez Canillas 81818461c6 kernel-install: Don't install BLS kernel images if dest dir doesn't exist (#8306)
The script shouldn't rely on a previous script exiting with a status code
that prevents it to be executed. Instead, should check if the destination
directory for the BLS kernel image exists and exit otherwise.
2018-02-28 10:25:19 +01:00
Zbigniew Jędrzejewski-Szmek 3a726fcd08 Add license headers and SPDX identifiers to meson.build files
So far I avoided adding license headers to meson files, but they are pretty
big and important and should carry license headers like everything else.
I added my own copyright, even though other people modified those files too.
But this is mostly symbolic, so I hope that's OK.
2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek d9215cd838 Add SPDX license headers to various assorted files 2017-11-19 19:08:15 +01:00
Zbigniew Jędrzejewski-Szmek 72cdb3e783 build-sys: drop automake support
v2:
- also mention m4
2017-07-18 10:04:44 -04:00
Yu Watanabe 9d8813b3b4 kernel-install: support the case /etc/machine-id is missing or empty (#5975)
Some .install plugins does not require that machine ID is set such as
20-grubby.install for Fedora and 50-depmod.install.
To support such plugins to run without valid machine-id, this commit
makes the following change:
* if /etc/machine-id is missing or empty, create temporary directory
  and set its path to BOOT_DIR_ABS,
* run the .install helpers with KERNEL_INSTALL_MACHINE_ID environment
  variable that'd be empty if /etc/machine-id is missing or empty.
This may be useful for installing kernel for e.g. stateless systems
which initialize machine-id while booting the systems.
2017-05-30 09:45:10 -04:00
Zbigniew Jędrzejewski-Szmek 37efbbd821 meson: reindent all files with 8 spaces
The indentation for emacs'es meson-mode is added .dir-locals.

All files are reindented automatically, using the lasest meson-mode from git.
Indentation should now be fairly consistent.
2017-04-23 21:47:29 -04:00
Michael Biebl e17e5ba9bf meson: use join_paths consistently
With -Dsplit-usr=true, we set rootprefix to /. This leads to //lib/systemd or
//lib/udev for various dir variables. Using join_paths() avoids this.
2017-04-23 21:47:28 -04:00
Zbigniew Jędrzejewski-Szmek 94e75a5409 meson: create dirs and touch /usr
This is the equivalent of $(INSTALL_DIRS) and install-touch-usr-hook.
I did not bother to create the directories into which we install files,
since they will be created anyway.

v2:
- remove bashism
2017-04-23 21:47:27 -04:00
Zbigniew Jędrzejewski-Szmek 5c23128dab meson: build systemd using meson
It's crucial that we can build systemd using VS2010!

... er, wait, no, that's not the official reason. We need to shed old systems
by requring python 3! Oh, no, it's something else. Maybe we need to throw out
345 years of knowlege accumulated in autotools? Whatever, this new thing is
cool and shiny, let's use it.

This is not complete, I'm throwing it out here for your amusement and critique.

- rules for sd-boot are missing. Those might be quite complicated.

- rules for tests are missing too. Those are probably quite simple and
  repetitive, but there's lots of them.

- it's likely that I didn't get all the conditions right, I only tested "full"
  compilation where most deps are provided and nothing is disabled.

- busname.target and all .busname units are skipped on purpose.

  Otherwise, installation into $DESTDIR has the same list of files and the
  autoconf install, except for .la files.

It'd be great if people had a careful look at all the library linking options.
I added stuff until things compiled, and in the end there's much less linking
then in the old system. But it seems that there's still a lot of unnecessary
deps.

meson has a `shared_module` statement, which sounds like something appropriate
for our nss and pam modules. Unfortunately, I couldn't get it to work. For the
nss modules, we need an .so version of '2', but `shared_module` disallows the
version argument. For the pam module, it also didn't work, I forgot the reason.

The handling of .m4 and .in and .m4.in files is rather awkward. It's likely
that this could be simplified. If make support is ever dropped, I think it'd
make sense to switch to a different templating system so that two different
languages and not required, which would make everything simpler yet.

v2:
- use get_pkgconfig_variable
- use sh not bash
- use add_project_arguments

v3:
- drop required:true and fix progs/prog typo

v4:
- use find_library('bz2')
- add TTY_GID definition
- define __SANE_USERSPACE_TYPES__
- use join_paths(prefix, ...) is used on all paths to make them all absolute

v5:
- replace all declare_dependency's with []
- add more conf.get guards around optional components

v6:
- drop -pipe, -Wall which are the default in meson
- use compiler.has_function() and compiler.has_header_symbol instead of the
  hand-rolled checks.
- fix duplication in 'liblibsystemd' library name
- use the right .sym file for pam_systemd
- rename 'compiler' to 'cc': shorter, and more idiomatic.

v7:
- use ENABLE_ENVIRONMENT_D not HAVE_ENVIRONMENT_D
- rename prefix to prefixdir, rootprefix to rootprefixdir
  ("prefix" is too common of a name and too easy to overwrite by mistake)
- wrap more stuff with conf.get('ENABLE...') == 1
- use rootprefix=='/' and rootbindir as install_dir, to fix paths under
  split-usr==true.

v8:
- use .split() also for src/coredump. Now everything is consistent ;)
- add rootlibdir option and use it on the libraries that require it

v9:
- indentation

v10:
- fix check for qrencode and libaudit

v11:
- unify handling of executable paths, provide options for all progs

  This makes the meson build behave slightly differently than the
  autoconf-based one, because we always first try to find the executable in the
  filesystem, and fall back to the default. I think different handling of
  loadkeys, setfont, and telinit was just a historical accident.

  In addition to checking in $PATH, also check /usr/sbin/, /sbin for programs.
  In Fedora $PATH includes /usr/sbin, (and /sbin is is a symlink to /usr/sbin),
  but in Debian, those directories are not included in the path.

  C.f. https://github.com/mesonbuild/meson/issues/1576.

- call all the options 'xxx-path' for clarity.
- sort man/rules/meson.build properly so it's stable
2017-04-23 21:47:26 -04:00
Yu Watanabe 301fb51922 kernel-install: remove unneeded modules.* files created by depmod (#5766)
Fixes #5765.
2017-04-21 14:03:17 -04:00
Michal Schmidt db1e2bfc4f kernel-install: avoid process substitution
bash implements process substitution using /dev/fd/N (this is documented
in man bash). We'd like kernel-install to work in chrooted RPM
scriptlets without /dev.

We can use here-strings instead. bash uses temporary files to implement
those.
2017-01-11 15:34:54 -05:00
Yu Watanabe 9156493171 kernel-install: use exit instead of return (#4565)
/bin/kernel-install: line 143: return: can only `return' from a function or sourced script

https://bugzilla.redhat.com/show_bug.cgi?id=1391829
2016-11-04 08:58:41 -04:00
Zbigniew Jędrzejewski-Szmek eb93312810 kernel-install: allow plugins to terminate the procedure (#4174)
Replaces #4103.
2016-09-24 09:03:54 -04:00
Martin Pitt 7ce9cc1545 Revert "kernel-install: Add KERNEL_INSTALL_NOOP (#4103)"
Further discussion showed that this better gets addressed at the packaging
level.

This reverts commit 34210af7c6.
2016-09-17 16:39:00 +02:00
Colin Walters 34210af7c6 kernel-install: Add KERNEL_INSTALL_NOOP (#4103)
Will be used by rpm-ostree (and likely lorax) to suppress
RPM->kernel->%posttrans->dracut runs, and basically everything
else this script is doing.

I'll also likely change the `kernel.spec` to respect this as well.
2016-09-14 07:57:43 +02:00
Lennart Poettering 5b8411a2aa kernel-install: when searching for location to place kernel consider /efi
With this change kernel-install will now first look for an existing kernel
installation in /efi, /boot and /boot/efi. If none is found, /efi is used if it
is a mount point, otherwise /boot/efi if it is one. If nothing of that worked
/boot is used without further checking.

This means /boot should be the default unless something was installed before or
something else was explicitly mounted.
2016-07-21 11:37:59 +02:00
Harald Hoyer 340defcd06 kernel-install: recognize /boot/efi mountpoint (#3751)
install everything in /boot/efi, if this is a mountpoint
2016-07-19 12:10:09 +02:00
Harald Hoyer 6fd2ccc957 90-loaderentry.install: fixup BOOT_OPTIONS
better use "read -r -d '' -a" to read in the array. It handles multiple
lines and missing newline at the EOF.
2015-06-02 16:10:06 +02:00
Michael Chapman c008f6ee8d kernel-install/90-loaderentry.install: fix cmdline parsing
A recent commit (2f3a215) changed the parsing of /proc/cmdline to use a
shell array. Unfortunately, this introduced a bug: "read -ar line"
populates the shell variable $r, not $line. This breaks installation of
new loader entries:

  # kernel-install add 3.17.1-304.fc21.x86_64 \
      /boot/vmlinuz-3.17.1-304.fc21.x86_64
  Could not determine the kernel command line parameters.
  Please specify the kernel command line in /etc/kernel/cmdline!

This commit alters the read command to correctly populate the $line
array instead.
2014-11-01 14:39:48 -04:00
Harald Hoyer 2f3a215f61 kernel-install/90-loaderentry.install: fixed cmdline parsing
If /etc/kernel/cmdline is missing or empty, we read /proc/cmdline and
want to filter out the initrd line. Due to a bug, the whole contents was
filtered out.
2014-08-15 14:41:50 +02:00
Lennart Poettering de66f68d9f build-sys: add missing Makefile link 2014-06-16 12:33:23 +02:00
Lennart Poettering 5ae4d543cb os-release: define /usr/lib/os-release as fallback for /etc/os-release
The file should have been in /usr/lib/ in the first place, since it
describes the OS container in /usr (and not the configuration in /etc),
hence, let's support os-release files in /usr/lib as fallback if no
version in /etc exists, following the usual override logic.

A prior commit already enabled tmpfiles to create /etc/os-release as a
symlink to /usr/lib/os-release should it be missing, thus providing nice
compatibility with applications only checking in /etc.

While it's probably a good idea if all apps check both locations via a
fallback logic, it is only necessary in the early boot process, as long
as the /etc/os-release symlink has not been restored, in case we boot
with an empty /etc.
2014-06-13 20:11:59 +02:00