Commit Graph

76 Commits

Author SHA1 Message Date
Laszlo Gombos
0b81e8eb67 chore: remove unnecessary shellcheck disable for SC2154 2023-08-24 08:54:01 +02:00
Laszlo Gombos
699d51c5dc chore(dracut-init.sh): remove support for obsolete syntax
Old syntax dracut modules had its check install installkernel
scripts in dedicated shell files and did not support module
dependencies.
2023-08-01 06:48:55 -04:00
Antonio Alvarez Feijoo
6c9f403f1c fix(dracut-init.sh): module_check method ignores forced option
When the `module_check` method is called passing 3 arguments (all calls right
now), the `forced` option is ignored, so the `hostonly` variable is never unset
before the module's `check` method is called.
2023-07-24 11:22:42 -04:00
Frederick Grose
1b53bb6297 fix(dracut-init.sh): use the local _ret variable
Use the local _ret variable when declared.
2023-07-24 07:40:40 -04:00
Antonio Alvarez Feijoo
3e2f685ecb fix(dracut-init.sh): correct check in is_qemu_virtualized function
Do not redirect `systemd-detect-virt` to /dev/null, otherwise, the `vm` variable
is always empty. This function was working only thanks to the following /sys
check.

Reported-by: Raymund Will <rw@suse.com>
2023-06-22 17:08:06 +02:00
Henrik Gombos
aa20bbb5b1 feat(dracut-init.sh): do not print by default if an udev rule is skipped 2023-06-07 12:15:36 -04:00
Laszlo Gombos
16931f5236 chore(shfmt): update to pass with shfmt v3.5.1 2023-02-13 12:08:36 +00:00
Laszlo Gombos
c95075e2c7 chore(base): remove support for <udev-176
This reverts 579238a3ac.

Keep the support for prepare_udev_rules for out-of-tree
dracut modules and issue a deprecation warning.
2023-02-13 11:58:52 +00:00
Antonio Alvarez Feijoo
823de8fe53 refactor(dracut-init.sh): remove redundant "dracut" from "dracut module" prints
In a similar fashion than "Including module" prints.
2023-02-02 08:11:24 +01:00
Antonio Alvarez Feijoo
a10078a5c3 feat(dracut-init.sh): specify if a module cannot be found or cannot be installed
Do not print the same error message for both situations.
2023-02-02 08:11:24 +01:00
Antonio Alvarez Feijoo
1aafcab935 fix(dracut-init.sh): correct typo in comment 2023-01-27 08:03:54 +00:00
Laszlo Gombos
08b63a2529 fix: shellcheck 0.8.0 2022-12-30 09:10:00 -05:00
Kairui Song
d460941b51 fix(dracut-init): make require_kernel_modules ignore no kernel build
If --no-kernel is specified, kernel module checking won't work, just
skip it.

Signed-off-by: Kairui Song <kasong@tencent.com>
2022-12-21 17:07:46 +01:00
Kairui Song
d3a5e6312a feat(dracut-init.sh): introduce a new helper require_kernel_modules
Some dracut modules won't work without certain kernel modules,
this helper will be helpful for checking such kernel configs in
check() and error out early.

Signed-off-by: Kairui Song <kasong@tencent.com>
2022-12-21 17:07:46 +01:00
Antonio Alvarez Feijoo
097dd367bb fix(dracut): shellcheck regression in DRACUT_INSTALL calls
If the DRACUT_INSTALL environment variable contains arguments (e.g.:
DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug"), its call cannot
be enclosed in double quotes. E.g.:

```
> export DRACUT_INSTALL="/usr/lib/dracut/dracut-install"
> "$DRACUT_INSTALL" > /dev/null
dracut-install: No SOURCE argument given
> export DRACUT_INSTALL="/usr/lib/dracut/dracut-install --debug"
> "$DRACUT_INSTALL" > /dev/null
-bash: /usr/lib/dracut/dracut-install --debug: No such file or directory
> $DRACUT_INSTALL > /dev/null
dracut-install: No SOURCE argument given

```
2022-12-21 12:10:01 +00:00
Marcos Mello
b12ee558f5 fix(dracut-init.sh): instmods: wrong variable name
It worked most of the time because `dracut-install -o` returns 0 in normal circumstances.
2022-11-07 09:36:21 +01:00
Antonio Alvarez Feijoo
cc669250af feat(dracut-init.sh): add inst_libdir_dir() helper
This helper function is similar to inst_libdir_file(), but it installs plain
directories located on a library directory instead of files.
2022-10-21 21:49:56 -04:00
Antonio Alvarez Feijoo
e2fdb30b56 fix(dracut-init.sh): add missing hostonly code in the inst_multiple function
It seems that commit https://github.com/dracutdevs/dracut/commit/4ef45f13 forgot
to add the code to handle the hostonly parameter in the inst_multiple function.
2022-09-29 05:41:17 +00:00
Hari Bathini
bc1b23c292 fix(squash): build ld cache for squash loader
Commit dc21638c3f fixes kdump kernel crash, due to non-conventional
library path in powerpc, by copying /etc/ld.so.cache under initdir.
While that works in general, it is vulnerable to failure because of
missing links, when the CPU is reconfigured to run in compatibility
mode of older CPU version. Avoid this by running ldconfig for squash
loader to create the necessary links & ld cache for it. Doing this
also saves a few kilobyes of space as the copied ld cache is bigger
in size than the one needed for squash loader environment.

Fixes: dc21638c3f ("fix(squash): keep ld cache under initdir")
Cc: Pingfan Liu <piliu@redhat.com>
Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
2022-09-29 04:57:14 +00:00
Antonio Alvarez Feijoo
da2a092894 chore: add execute permission to all scripts
This avoids most of the rpmlint non-executable-script warnings.
2022-08-26 07:44:16 +00:00
Antonio Alvarez Feijoo
72b700e3cb fix(dracut-init.sh): correct dracut-install source path 2022-08-12 10:30:15 +00:00
Antonio Alvarez Feijoo
d2f6f445ed fix(dracut-init.sh): propagate the result code returned by dracut-install
Currently only the inst_multiple function propagates the result code returned by
dracut-install.
This was missing since 043 (e.g.: https://github.com/dracutdevs/dracut/blob/043/dracut-functions.sh#L751)
2022-08-12 10:25:56 +00:00
наб
95aeed8975 fix(dracut): default to correct firmware search paths
1. /sys/module/firmware_class/parameters/path (fw_path_para), if any
2. /lib/firmware/updates/$(uname -r)
3. /lib/firmware/updates
4. /lib/firmware/$(uname -r)
5. /lib/firmware

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/firmware_loader/main.c?h=v5.17#n406
2022-06-09 23:46:52 +00:00
Lubomir Rintel
bc4f196f98 fix(dracut-init): unbreak a comment
A dreadful copy & paste or kill-ring-save & yank error, most surely.
2022-02-02 23:00:48 +00:00
Mikhail Novosyolov
ce9af251af feat: support ZSTD-compressed kernel modules
Modern Linux kernels support zstd-compressed modules, which was added
by commit 73f3d1b48f50 ("lib: Add zstd modules").

Commit c3d7ef377eb ("kbuild: add support for zstd compressed modules")
added support of compressing modules with zstd to kernel Makefiles.

libkmod >= 28 built with libzstd is also required.
2021-05-04 15:55:19 +00:00
Harald Hoyer
7f63374713 fix: include modules.builtin.alias in the initramfs
Let's also resolve the compiled in aliases to builtin modules.
2021-05-04 13:34:16 +02:00
Harald Hoyer
87c4c17850 fix: add modules.builtin.modinfo to the initramfs
This solves all issues, where builtin kernel modules are not recognized
as such.

Fixes: https://github.com/dracutdevs/dracut/issues/1146
Fixes: https://github.com/dracutdevs/dracut/issues/1099
2021-05-04 11:45:53 +02:00
Harald Hoyer
2b5ddc7722 fix: shellcheck for dracut*.sh 2021-03-29 09:54:52 +02:00
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
Andrew J. Hesford
d437970c01 fix: proper return code for inst_multiple in dracut-init.sh
A test of the form

    if ! command; then
        _ret=$?
        ...
        return _ret
    fi

does not capture the return code of `command`, but the negation of the
return code, leaving _ret == 0. The test of this form in inst_multiple
has been refactored to capture and return the right value.
2021-02-19 09:03:53 +01:00
Harald Hoyer
ad64c6864c fix: shellcheck for dracut-init.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer
cdb714c539 fix: shellcheck for dracut-init.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer
994d003540 fix: shellcheck for dracut-init.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer
63356d544b fix: shellcheck for dracut-init.sh 2021-02-15 11:00:37 +01:00
Harald Hoyer
2d4344bca9 fix: shellcheck for dracut-init.sh 2021-02-15 11:00:37 +01:00
Zoltán Böszörményi
b955dbf4a9 fix(dracut-init.sh): make inst_libdir_file work with dracutsysrootdir set
Signed-off-by: Zoltán Böszörményi <zboszor@pr.hu>
2021-01-21 16:33:18 +00:00
Colin Walters
6b8ee4fc37 Don't print when a module is explicitly omitted (by default)
dracut builds today are fairly verbose to start, but on top of
that many of the messages tend to liberally use the
exclamation point `!` which calls attention to them.

I see these a lot when looking at rpm-ostree build logs
and it'd be nicer if we were quiet when there wasn't
an actual problem.

In this specific case, if the builder is explicitly adding
`--omit=foo`, there's no reason for us to say:

`dracut: dracut module 'foo' will not be installed, because it's in the list to be omitted!`

We already print the command line to start, so the information
is there.

Demote this message to debug.
2020-11-14 19:38:29 +01:00
Mikhail Novosyolov
f84ad9e062 Allow $DRACUT_INSTALL to be not an absolute path
/usr/sbin/dracut-install is a symlink:
$ file /usr/sbin/dracut-install
/usr/sbin/dracut-install: symbolic link to ../lib/dracut/dracut-install

It resulted to "dracut-install not found" error:

+++ for p in $DRACUT_PATH
+++ [[ -L /sbin/dracut-install ]]
+++ [[ -x /sbin/dracut-install ]]
+++ for p in $DRACUT_PATH
+++ [[ -L /bin/dracut-install ]]
+++ [[ -x /bin/dracut-install ]]
+++ for p in $DRACUT_PATH
+++ [[ -L /usr/sbin/dracut-install ]]
+++ printf '%s\n' dracut-install
+++ return 0
++ DRACUT_INSTALL=dracut-install
++ [[ -n dracut-install ]]
++ [[ -n dracut-install ]]
++ DRINSTALLPARTS=0
++ for i in $DRACUT_INSTALL
++ DRINSTALLPARTS=1
++ [[ 1 = 1 ]]
++ [[ -x dracut-install ]]
++ dfatal 'dracut-install not found!'
++ set +x
dracut: dracut-install not found!

[ -x <not a path to file> ] is not correct and will always be false.
But actually it is available. Let's just allow it to be not an absolute path.
Maybe some other places can be improved to avoid DRACUT_INSTALL being not an absolute path.

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2020-08-05 17:46:30 +02:00
Harald Hoyer
93be2bc6ab add DRACUT_NO_XATTR global environment variable
Useful, if you know, that those can't be copied anyway.
2020-02-27 13:49:21 +01:00
Mikhail Novosyolov
718aefda13 Ensure that udevadm --version reported an integer
If it is not an integer, further script will fail unexepectedly.
2019-11-05 14:26:14 +01:00
Mikhail Novosyolov
6e761674ad Fail if udevadm could not be run
Fixes: #668
2019-11-05 14:26:14 +01:00
Böszörményi Zoltán
a01204202b Allow running on a cross-compiled rootfs
For the shell scripts, new environment variables were introduced.

dracutsysrootdir is the root directory, file existence checks use it.

DRACUT_LDCONFIG can override ldconfig with a different one that works
on the sysroot with foreign binaries.

DRACUT_LDD can override ldd with a different one that works
with foreign binaries.

DRACUT_TESTBIN can override /bin/sh. A cross-compiled sysroot
may use symlinks that are valid only when running on the target
so a real file must be provided that exist in the sysroot.

DRACUT_INSTALL now supports debugging dracut-install in itself
when run by dracut but without debugging the dracut scripts.
E.g. DRACUT_INSTALL="valgrind dracut-install or
DRACUT_INSTALL="dracut-install --debug".

DRACUT_COMPRESS_BZIP2, DRACUT_COMPRESS_LBZIP2, DRACUT_COMPRESS_LZMA,
DRACUT_COMPRESS_XZ, DRACUT_COMPRESS_GZIP, DRACUT_COMPRESS_PIGZ,
DRACUT_COMPRESS_LZOP, DRACUT_COMPRESS_ZSTD, DRACUT_COMPRESS_LZ4,
DRACUT_COMPRESS_CAT: All of the compression utilities may be
overridden, to support the native binaries in non-standard places.

DRACUT_ARCH overrides "uname -m".

SYSTEMD_VERSION overrides "systemd --version".

The dracut-install utility was overhauled to support sysroot via
a new option -r and fixes for clang-analyze. It supports
cross-compiler-ldd from
https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f

DRACUT_INSTALL_PATH was introduced so dracut-install can work with
a different PATH. In a cross-compiled environment (e.g. Yocto), PATH
points to natively built binaries that are not in the host's /bin,
/usr/bin, etc. dracut-install still needs plain /bin and /usr/bin
that are relative to the cross-compiled sysroot.

The hashmap pool allocate_tile/deallocate_tile code was removed
because clang-analyze showed errors in it. hashmap_copy was removed
because it wasn't used and clang-analyze showed errors in it.

DRACUT_INSTALL_LOG_TARGET and DRACUT_INSTALL_LOG_LEVEL were
introduced so dracut-install can use different settings from
DRACUT_LOG_TARGET and DRACUT_LOG_LEVEL.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
2019-10-25 11:58:58 +02:00
Daniel Molkentin
b4769b332d dracut-init.sh: remove obsolete for_each_kmod_dep() 2019-10-22 13:50:36 +02:00
Takashi Iwai
f4e38c0da8 dracut-init.sh: Nuke unused install_kmod_with_fw function
Kill the no longer used function, so that anyone won't be confused and
try to modify this function in future.

BugLink: https://bugzilla.suse.com/show_bug.cgi?id=1146769
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-08-26 14:57:37 +02:00
Daniel Molkentin
b6b1bf9202 Consollidate the qemu virtualization detection
Eventually, we could add a full virt detection routine.
This would be useful e.g. to determine inclusion of
ucode for hostonly setups.
2019-07-19 16:26:42 +02:00
Takashi Iwai
3e53195bce dracut-install: Add support for compressed kernel modules
When a module is compressed, uncompress it before packing into initrd.
Since initrd is already compressed, it makes no sense to put the
compressed module files.

The patch contains a slight refactoring and adds a helper function to
get the command for uncompressing a file per extension.
2019-07-19 16:17:35 +02:00
Harald Hoyer
86f4dd0273
Merge branch 'optimization' of https://github.com/ryncsn/dracut into ryncsn-optimization 2019-07-19 15:48:22 +02:00
Kairui Song
19e5758590 squash: also squash systemctl if switch-root is not needed
systemctl need to be accessible on switch-root, but we unmount the
squash image on switch-root, so it will fail. systemctl depends on a lot
of libraries, squash them can save more RAM. So allow modules
(eg. kdump) to tell dracut that switch-root will be intercepted,
then we don't need to take care of that.

Signed-off-by: Kairui Song <kasong@redhat.com>
2019-07-19 15:38:54 +02:00
Takashi Iwai
dc86c12c45 dracut-install: Add support for compressed firmware files
The upcoming kernel will have a support for loading compressed
firmware files, and this patch corresponds to that kernel change.
When a firmware file with the extra .xz extension is found, dracut
copies to initrd as fallback.  Since initrd itself is compressed, the
file is uncompressed in initrd beforehand.
2019-07-18 18:39:56 +02:00