diff --git a/package/dracut/dracut.mk b/package/dracut/dracut.mk index 742a073a36..597492bc5e 100644 --- a/package/dracut/dracut.mk +++ b/package/dracut/dracut.mk @@ -22,6 +22,8 @@ HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT # "ld-musl-x.so" symlinks, respectively - else the init process cannot # start define HOST_DRACUT_POST_INSTALL_LIBC_LINKS_MODULE + $(INSTALL) -D -m 0755 package/dracut/merged-usr-module-setup.sh \ + $(HOST_DIR)/lib/dracut/modules.d/0000-merged-usr/module-setup.sh $(INSTALL) -D -m 0755 package/dracut/libc-links-module-setup.sh \ $(HOST_DIR)/lib/dracut/modules.d/05libc-links/module-setup.sh endef diff --git a/package/dracut/merged-usr-module-setup.sh b/package/dracut/merged-usr-module-setup.sh new file mode 100644 index 0000000000..6dc0e7ca7b --- /dev/null +++ b/package/dracut/merged-usr-module-setup.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +check() { + [ -L "${dracutsysrootdir?}/lib" ] +} + +depends() { + return 0 +} + +install() { + # dracut pre-installs a set of files before calling any of + # the modules, and dracut also messes up host vs. target + # system, so on a non-merged-usr host, it will prepare a + # non-merged-usr initramfs, even though the current config + # is for a merged-usr system. + # So undo its borkage. + for dir in lib bin sbin; do + mkdir -p "${initdir?}/usr/${dir}" + if [ -d "${initdir?}/${dir}" ]; then + mv "${initdir?}/${dir}/"* "${initdir?}/usr/${dir}" + rm -rf "${initdir?}/${dir}" + ln -s "usr/${dir}" "${initdir?}/${dir}" + fi + done +}