Commit Graph

366 Commits (d4caa86aba35b51dc1adda3ee3a5bae677420082)

Author SHA1 Message Date
Harald Hoyer 75d758e8f1 style: shfmt -s reformat
reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w -s .
```
2021-03-13 20:10:43 +01:00
Harald Hoyer 9a52c3fdb0 style: shfmt reformat
reproducible with:

```
$ shfmt_version=3.0.1
$ wget "https://github.com/mvdan/sh/releases/download/v${shfmt_version}/shfmt_v${shfmt_version}_linux_amd64" -O shfmt
$ chmod u+x shfmt
$ ./shfmt -w .
```
2021-03-13 20:10:43 +01:00
Harald Hoyer 560402c3dc style: shfmt pre correction 2021-03-13 20:10:43 +01:00
Kairui Song 7c0bc0b2fd perf: disable initrd compression when squash module is enabled
With squash module, the initramfs is double compressed, which slow down
the build progress and doesn't shrink the size much.
2021-03-09 13:40:35 +00:00
Kairui Song 5d05ffbd87 feat: squash module follow --compress option
Try to make mksquashfs follow --compress option if squash module is
included, if not specified or invalid, fall back to use mksquashfs's
default compressor.
2021-03-09 13:40:35 +00:00
Kairui Song a9345f6800 refactor: delay compressor detection
No function change, decide which compressor to use right before
compressing the initramfs.

This may delay the print of this message:
"dracut: no compression tool available. Initramfs image is going to be big."
but should be OK, this message is not an error.
2021-03-09 13:40:35 +00:00
Kairui Song 8f7c332e48 refactor(squash): structure in a cleaner way
Simplify the squash mount layout. Instead of overlay on each top
directory (/etc, /usr), just mount and switch_root into the squash
image, with a overlay on top of it.

Also install the binaries and setup scripts separately, so the squash
setup code and the squash image content is independent of each other,
all squash setup script and binaries can be deleted safely upon
switch_root.

With this change, previous squash clean up service and other tricky
implementations are all gone.

This commit depends on systemd commits from:
https://github.com/systemd/systemd/pull/18124

Previouly systemd doesn't recognize non-ramfs initramfs, now this is
doable with SYSTEMD_IN_INITRD=lenient

Signed-off-by: Kairui Song <kasong@redhat.com>
2021-03-09 13:40:35 +00:00
Kairui Song 8c8aecdc63 fix(squash): post install should be the last step before stripping
Ensure dracut squash module doesn't effect other steps, and stripping
can cover the new binaries installed by it.
2021-03-09 13:40:35 +00:00
Kairui Song 95ea16aa60 refactor(squash): move the post install scripts into the module-setup.sh
No function change, just move the post install code to 99squash to clean
up dracut.sh.
2021-03-09 13:40:35 +00:00
Jóhann B. Guðmundsson 9cf7b1c529 fix: always use mkdir -p
Ensuring that directory creations dont trigger error if directory
previously existed as well as create parent directories if needed.
2021-03-03 13:06:02 +01:00
Renaud Métrich d8e47e201a fix(dracut.sh): harden dracut against GZIP environment variable
When a GZIP environment variable is set, this leads to various breakage:

In case 'pigz' is installed and GZIP is defined as a path, e.g.
/usr/local/bin/gzip, then dracut will fail with the following message:

   "
   pigz: abort: cannot provide files in GZIP environment variable
   "

In case 'pigz' isn't installed and regular 'gzip' is used and GZIP is
defined as a path, e.g. /usr/local/bin/gzip, then the path will be
zipped and dracut will fail for no obvious reason.  Trying again, dracut
will then fail with following message:

   "
   gzip: /usr/local/bin/gzip.gz already exists;	not overwritten
   "

In any case, GZIP environment should be unset to avoid breakage or
unwanted behaviour. This variable is anyway obsolescent, from gzip(1)
manpage.

Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
2021-03-02 11:05:52 +01:00
Harald Hoyer c8ebb80590 fix(dracut.sh): remove unneeded variables
There is no `fstab_lines_l` variable used before.

The `--include` option was turned into `++include` and therefore the
switch option is not reachable anymore.
2021-02-23 16:03:44 +01:00
Sergei Iudin d87ae13721 fix(dracut.sh): unfreeze /boot on exit
If SIGWHATEVER will be processed after fsfreeze -f, but before fsfreeze
-u we will end up with /boot/ never unfrozen, let's try to minimize risk of this.
2021-02-23 09:25:08 +01:00
Harald Hoyer 41cfdfc4d3 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 510a22116b fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 2c10b29999 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 7b59d15d96 fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer dd8ff5311f fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 6dc1cd052b fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 7310a8484e fix: shellcheck for dracut.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer 1ebf454884 fix: correct the squash quirk
Previously with `no_kernel` the `for` loop errored on the modules
wildcard. By checking, if the file exists, this is mitigated.

"mv" asked interactively, if aliased in the user session, so a "--force"
was added.
2021-02-10 14:14:39 +01:00
Zoltán Böszörményi 18d36fabf5 feat(dracut.sh): allow overriding the systemctl command for sysroot
Allow overriding the systemctl command for sysroot with $SYSTEMCTL
Modified every modules' module-setup.sh to use the envvar instead
of the hardcoded command name.

Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-02-09 07:09:28 +00:00
Zoltán Böszörményi bbe1434fca fix(dracut.sh): don't override path with foreign sysroot
Don't override PATH with foreign sysroot and
trim the sysroot prefix from NPATH elements.

Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-02-09 07:09:28 +00:00
Alexander Tsoy 6eff0ebcf8 fix: move ldconfig after library workaround
Commit de3cb0e321 moved libpthread workaround after the code that runs
ldconfig. As a result, if installed in a non-default path, libgcc_s.so.1
could not be found by dynamic linker.
2021-02-08 22:44:32 +01:00
Matthew Thode 8a2edb1e4d fix: do not set cmdline for uefi images unless asked
The kernel does not allow the cmdline to be overridden if one is defined
in the uefi image.  This means that bootloaders like systemd-boot or
grub cannot manage boot options (editing at boot for debug being a use
case).  This patchset allows for no cmdline to be set (instead of force
setting one if none is provided).

Fixes: https://github.com/dracutdevs/dracut/issues/1012
Signed-off-by: Matthew Thode <mthode@mthode.org>
2021-02-08 10:37:22 +01:00
Jóhann B. Guðmundsson 939b7e11d5 feat(systemd-coredump): introducing systemd-coredump module
This pull request introduces systemd-coredump as a seperated
module and adds the systemdutilconfdir global variable.
2021-02-02 18:01:06 +00:00
Jóhann B. Guðmundsson a47c3f50b6 feat: add addional global variables 2021-01-20 12:40:04 +00:00
Jóhann B. Guðmundsson db36338053 feat: add addional global variables 2021-01-20 12:40:04 +00:00
Jóhann B. Guðmundsson 1acf52b60e feat: add addional global variables 2021-01-18 14:45:18 +00:00
Vladius25 f3cbff1113 feat(cli): add --no-uefi option
To be able to turn off UEFI mode, when it's enabled in config.
2021-01-18 08:30:00 +00:00
Daniel Molkentin 3a12309c0d Revert "Add --uefi-output for custom output filename"
This reverts commit f8f3b0f358.
2020-12-02 00:25:20 +01:00
leo-lb f8f3b0f358 Add --uefi-output for custom output filename
Closes #921
2020-11-24 19:38:30 +01:00
Kairui Song 1e92f7285d Add a --hostonly-nics option
Currently when network is enabled, dracut will install all network
drivers that are currently loaded, but some time only one NIC is needed
for the initramfs.

So for strict hostonly mode, add a --hostonly-nics option, user can
provide a list of NICs to be enabled, and only needed drivers for
specifed NICs will be installed so save space.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-26 14:16:19 +01:00
Kairui Song 83c65fd3db 99squash: Check require module earlier, and properly
Let 99squash fail earlier if required modules are not enabled or
missing, using the new added helper.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-10-21 17:04:00 +02:00
Daniel Molkentin ff2d8bdfb3 dracut.sh: Add --version 2020-08-28 23:28:25 +02:00
Érico Rolim 497916e13b dracut.sh: fix some indentation.
Command level inside conditional and tab/space usage.
2020-08-24 11:29:34 +02:00
Érico Rolim 3b92d8bf84 dracut.sh: fix errors pointed out by shellcheck.
- use [ ] instead of calling test manually, as most of the script is
doing.

- use quotes in hostonly_cmdline blocks, specially when dealing with the
conf files, whose names are set by users/system administrators

- uefi_splash_image was being assigned set to `${dracutsysroot}...`, which
is a variable that doesn't exist.

- we don't want the conditional to run the output of fsfreeze as
commands. Instead, we just need to know if any of the fsfreeze commands
failed.
2020-08-24 10:27:29 +02:00
mwberry fea53784ad UEFI Mode: only write kernel cmdline to UEFI binary
The kernel command line was being written both into
/etc/cmdline.d/01-default.conf and the UEFI executable.
During boot, getcmdline would concatenate these two
resulting in all arguments being duplicated. Some
args, such as ip=, are sensitive to the number of
times they are specified.
2020-08-05 18:30:44 +02:00
Kairui Song 4159819fbb 99squash: simplify the code
The new dracutsysrootdir could be used to replace the shell function
required_in_root, so drop it and also simplify the code.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-08-04 14:24:53 +02:00
q66 63b05a8e67 dracut.sh: fix ia32 detection for uefi executables 2020-08-03 18:51:49 +02:00
q66 d8d5cb839c dracut.sh: fix early microcode detection logic
This fixes two issues:

1) on non-x86 systems in non-hostonly config this would cause
   an annoying warning on every initramfs generation
2) on non-x86 systems in hostonly config this would result in
   early microcode not getting disabled
2020-07-26 10:25:42 +02:00
Kairui Song 5a4c346933 dracut.sh: FIPS workaround for openssl-libs on Fedora/RHEL
On Fedora/RHEL, libcryto will verify both itself and libssl on start, if
libssl is missing, FIPS self test will fail. However libssl is not a
dependency of libcryto so dracut will not install it, unless some other
binary or library pulls it in. Systemd requires libssl, so in most cases
it just worked, but could fail in some corner cases where systemd is not
used.

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-07-02 17:05:23 +02:00
Kairui Song de3cb0e321 dracut.sh: Move the library workaround after squash
Ensure the workaround is also valid when dracut-squash module is used

Signed-off-by: Kairui Song <kasong@redhat.com>
2020-07-02 17:05:23 +02:00
Harald Hoyer dfe2247a43 dracut.sh: add check for invalid configuration files
Emit a warning about possible misconfigured configuration files, where
the spaces around values are missing for +=""

Better report a possible source of problems. We can fix annoying false
positives later.
2020-03-18 16:34:35 +01:00
Dusty Mabe 97a931c7d9 don't prefer $TMPDIR over --tmpdir
Ability to use `$TMPDIR` was introduced in bc1e69b but
causes the `--tmpdir` option on the command line to be
ignored. Switch to only using `$TMPDIR` if `--tmpdir`
wasn't specified.
2020-03-16 14:45:01 +01:00
Topi Miettinen bc1e69b691 Use TMPDIR if available
Use environment variable TMPDIR (typically /run/user/$UID) as default
temporary directory, if available. This should be more private
location than /var/tmp. Path specified with --tmpdir is takes
precedence over TMPDIR and /var/tmp is still used as last resort if
neither TMPDIR is set nor --tmpdir is used.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-03-06 11:40:00 +01:00
Martin Wilck 0386e46277 dracut.sh: don't call fsfreeze on subvol of root file system
dracut.sh already doesn't call fsfreeze if the output file is on
the root file system. For btrfs, however, this is not sufficient.
Because fsfreeze is a superblock operation, and all btrfs subvolumes
share the same superblock, fsfreeze may freeze the entire system
if the subvolume on which the output file is written and / are
subvolumes of the same file system. Avoid this by comparing file
system UUIDs for btrfs.

Fixes: de576db3c2 ("call fsfreeze(8) on /boot to flush initramfs data & metadata to media")
2020-03-06 11:37:16 +01:00
Daniel Molkentin 5b1d8bcc58
Merge branch 'master' into regenerate_all 2020-03-03 19:25:16 +01:00
Topi Miettinen ecbdff68af Don't resolve libraries lazily if tmpdir is mounted with 'noexec'
If the temporary directory for images is mounted with 'noexec', dracut
would construct unbootable images because most dynamic libraries
aren't installed. Avoid this by not resolving library dependencies
lazily if the temporary directory is mounted with 'noexec'.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-03-02 09:56:26 +01:00
Donovan Tremura 4237aeb040 Support the EFI Stub loader's splash image feature.
Checks if `uefi_splash_image` exists in `dracutsysroot` if not unset
`uefi_splash_image`. Alternate Value parameter expansion adds section-vma
for splash image to EFI stub loader when the path to image is valid and
not an empty file.

I did not test on other distributions, but on Arch Linux the `systemd`
package includes a splash image at the path
`/usr/share/systemd/bootctl/splash-arch.bmp`. Perhaps, if this is a
common practice, a default image could be gathered from that directory.

It is required that the image be in bitmap (`.bmp`) format according to
`splash.c`.

The code for `stub.c` and `splash.c` can be found at:
https://github.com/systemd/systemd/blob/master/src/boot/efi/stub.c
https://github.com/systemd/systemd/blob/master/src/boot/efi/splash.c
2020-02-20 11:03:30 +01:00