@@ -20,11 +20,37 @@ _PKG_MANAGER_remove=
2020
2121# ###### endregion INTERNAL_VARS #######
2222
23+ #
24+ #
25+ #
26+
27+ # ###### region INTERNAL_FUNCTIONS #######
28+
29+ # Setup the initramfs in the current rootfs.
30+ # Is redeclared depending of the package manager, with a noop declaration as fallback.
31+ #
32+ # Arguments:
33+ # $1 - The path to the initramfs image file.
34+ #
35+ # Usage:
36+ # _pkg_setupinitramfs /path/to/initramfs.img
37+ _pkg_setupinitramfs () {
38+ echo >&2 " ERROR: To be implemented"
39+ return 1
40+ }
41+
42+ # ###### endregion INTERNAL_FUNCTIONS #######
43+
44+ #
45+ #
46+ #
47+
2348# ###### region Collect input #######
2449
2550# Possible values:
2651# install
2752# remove
53+ # setup-initramfs
2854_command=$1
2955shift 2> /dev/null || {
3056 echo >&2 " ERROR: missing args"
@@ -50,6 +76,17 @@ elif [ -x "$(command -v dnf)" ]; then
5076 echo >&2 " Package manager identified: dnf"
5177 _PKG_MANAGER_install=" dnf install -yq"
5278 _PKG_MANAGER_remove=" dnf remove -yq"
79+ _pkg_setupinitramfs () {
80+ _initramfs_path=" ${1:? } "
81+ $_PKG_MANAGER_install dracut-live
82+ _INSTALLED_KERNEL=$( rpm -q kernel-core --queryformat " %{evr}.%{arch}" | tail -n 1)
83+ mkdir -p " $( realpath /root) "
84+ export DRACUT_NO_XATTR=1
85+ dracut --zstd --reproducible --no-hostonly --kver " $_INSTALLED_KERNEL " \
86+ --add " dmsquash-live dmsquash-live-autooverlay" \
87+ --force " $_initramfs_path " 2>&1 | grep -v -e " Operation not supported"
88+ unset -v _INSTALLED_KERNEL
89+ }
5390
5491elif [ -x " $( command -v pacman) " ]; then
5592
74111
75112# shellcheck disable=SC2086
76113if [ " $_command " = " install" ]; then
114+
77115 $_PKG_MANAGER_install $_args
116+
78117elif [ " $_command " = " remove" ]; then
118+
79119 $_PKG_MANAGER_remove $_args
120+
121+ elif [ " $_command " = " setup-initramfs" ]; then
122+
123+ _pkg_setupinitramfs $_args
124+
80125else
81126 echo >&2 " ERROR: unknown command"
82127 exit 1
0 commit comments