Initial Commit
- initial default booting image
This commit is contained in:
11
package/dracut/Config.in.host
Normal file
11
package/dracut/Config.in.host
Normal file
@@ -0,0 +1,11 @@
|
||||
config BR2_PACKAGE_HOST_DRACUT
|
||||
bool
|
||||
select BR2_PACKAGE_HOST_KMOD
|
||||
help
|
||||
dracut-ng is used to create an initramfs image by
|
||||
copying tools and files from an installed system
|
||||
and combining it with the dracut framework.
|
||||
dracut-ng is a drop-in replacement for the legacy
|
||||
dracut project.
|
||||
|
||||
https://dracut-ng.github.io/dracut/
|
||||
59
package/dracut/busybox-init-module-setup.sh
Normal file
59
package/dracut/busybox-init-module-setup.sh
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
|
||||
check() {
|
||||
require_binaries busybox || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install_busybox_links() {
|
||||
dir="${1}"
|
||||
linkname="${2}"
|
||||
|
||||
(cd "${dracutsysrootdir?}${dir}" &&
|
||||
for x in *; do
|
||||
if [ "$(readlink "${x}")" = "${linkname}" ]; then
|
||||
ln -sf "${linkname}" "${initdir?}/${dir}/${x}"
|
||||
fi
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_multiple /bin/busybox
|
||||
|
||||
# wrapper script for early console; will launch /sbin/init
|
||||
# after having mounted devtmpfs
|
||||
inst_multiple /init
|
||||
|
||||
if [ -e "${dracutsysrootdir?}/lib64" ]; then
|
||||
ln -sf lib "${initdir?}/lib64"
|
||||
ln -sf lib "${initdir?}/usr/lib64"
|
||||
fi
|
||||
|
||||
if [ -e "${dracutsysrootdir?}/lib32" ]; then
|
||||
ln -sf lib "${initdir?}/lib32"
|
||||
ln -sf lib "${initdir?}/usr/lib32"
|
||||
fi
|
||||
|
||||
install_busybox_links "/bin" "busybox"
|
||||
install_busybox_links "/sbin" "../bin/busybox"
|
||||
if [ ! -L "${dracutsysrootdir?}/bin" ]; then
|
||||
install_busybox_links "/usr/bin" "../../bin/busybox"
|
||||
install_busybox_links "/usr/sbin" "../../bin/busybox"
|
||||
fi
|
||||
|
||||
inst_multiple \
|
||||
/etc/inittab \
|
||||
/etc/init.d/rcS \
|
||||
/etc/init.d/rcK \
|
||||
/etc/issue \
|
||||
/etc/fstab \
|
||||
/etc/group \
|
||||
/etc/passwd \
|
||||
/etc/shadow \
|
||||
/etc/hostname
|
||||
}
|
||||
3
package/dracut/dracut.hash
Normal file
3
package/dracut/dracut.hash
Normal file
@@ -0,0 +1,3 @@
|
||||
# Locally computed
|
||||
sha256 839d21eb4bd27bb0ee40d74c9da46df088c2e1425fcd8c3ea62b7e3a3dd28a91 dracut-112.tar.gz
|
||||
sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 COPYING
|
||||
63
package/dracut/dracut.mk
Normal file
63
package/dracut/dracut.mk
Normal file
@@ -0,0 +1,63 @@
|
||||
################################################################################
|
||||
#
|
||||
# dracut
|
||||
#
|
||||
################################################################################
|
||||
|
||||
DRACUT_VERSION = 112
|
||||
DRACUT_SITE = $(call github,dracut-ng,dracut,$(DRACUT_VERSION))
|
||||
DRACUT_LICENSE = GPL-2.0
|
||||
DRACUT_LICENSE_FILES = COPYING
|
||||
DRACUT_CPE_ID_VALID = YES
|
||||
|
||||
HOST_DRACUT_DEPENDENCIES = host-pkgconf host-kmod host-cross-ldd
|
||||
# Dracut is not a real autotools package, and the hand-written
|
||||
# ./configure script does not preserve LDFLAGS for make.
|
||||
HOST_DRACUT_MAKE_ENV = $(HOST_CONFIGURE_OPTS)
|
||||
HOST_DRACUT_INSTALL_OPTS = systemdsystemunitdir="" install
|
||||
|
||||
ifeq ($(BR2_PACKAGE_HOST_RUSTC),y)
|
||||
HOST_DRACUT_CONF_OPTS += --enable-dracut-cpio
|
||||
HOST_DRACUT_DEPENDENCIES += host-rustc
|
||||
else
|
||||
HOST_DRACUT_CONF_OPTS += --disable-dracut-cpio
|
||||
endif
|
||||
|
||||
define HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
|
||||
mv $(HOST_DIR)/bin/dracut $(HOST_DIR)/bin/dracut.real
|
||||
sed -e "s%@@TARGET_CROSS@@%$(TARGET_CROSS)%" \
|
||||
$(HOST_DRACUT_PKGDIR)/dracut_wrapper.in > \
|
||||
$(@D)/dracut_wrapper
|
||||
install -D -m 0755 $(@D)/dracut_wrapper $(HOST_DIR)/bin/dracut
|
||||
endef
|
||||
HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_WRAPPER_SCRIPT
|
||||
|
||||
# When using uClibc or musl, there must be "ld-uClibc.so.1" or
|
||||
# "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
|
||||
HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_LIBC_LINKS_MODULE
|
||||
|
||||
ifeq ($(BR2_INIT_BUSYBOX),y)
|
||||
# Dracut does not support busybox init (systemd init is assumed to work
|
||||
# out of the box, though). It provides a busybox module, that does not
|
||||
# use the same paths as buildroot, and is not meant to be used as an init
|
||||
# system.
|
||||
# So it is simpler for users to disable the standard 'busybox' module in
|
||||
# the configuration file, and enable the "busybox-init' module instead.
|
||||
# Note that setting the script as executable (0755) is not mandatory,
|
||||
# but this is what dracut does on all its modules, so lets just conform
|
||||
# to it.
|
||||
define HOST_DRACUT_POST_INSTALL_BUSYBOX_INIT_MODULE
|
||||
$(INSTALL) -D -m 0755 package/dracut/busybox-init-module-setup.sh \
|
||||
$(HOST_DIR)/lib/dracut/modules.d/05busybox-init/module-setup.sh
|
||||
endef
|
||||
HOST_DRACUT_POST_INSTALL_HOOKS += HOST_DRACUT_POST_INSTALL_BUSYBOX_INIT_MODULE
|
||||
endif
|
||||
|
||||
$(eval $(host-autotools-package))
|
||||
48
package/dracut/dracut_wrapper.in
Normal file
48
package/dracut/dracut_wrapper.in
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Find the --sysroot argument
|
||||
sysroot=
|
||||
next_arg=false
|
||||
for arg; do
|
||||
if ${next_arg}; then
|
||||
next_arg=false
|
||||
sysroot="${arg}"
|
||||
continue # not break, in case there are more than one
|
||||
fi
|
||||
case "${arg}" in
|
||||
(--sysroot|-r)
|
||||
next_arg=true
|
||||
continue
|
||||
;;
|
||||
(--sysroot=*)
|
||||
sysroot="${arg#*=}"
|
||||
continue # not break, in case there are more than one
|
||||
;;
|
||||
(-r?*)
|
||||
sysroot="${arg#-r}"
|
||||
continue # not break, in case there are more than one
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ -z "${sysroot}" ]; then
|
||||
echo "${0}: --sysroot argument must be given." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
topdir="$(dirname "$(realpath "$(dirname "${0}")")")"
|
||||
DRACUT_LDD="$(mktemp /tmp/dracut-ldd.XXXXXX)"
|
||||
cat >"${DRACUT_LDD}" <<EOL
|
||||
#!/bin/bash
|
||||
@@TARGET_CROSS@@xldd --root='${sysroot}' \${1}
|
||||
EOL
|
||||
chmod +x "${DRACUT_LDD}"
|
||||
export DRACUT_LDD
|
||||
export DRACUT_INSTALL="${topdir}/lib/dracut/dracut-install"
|
||||
export DRACUT_LDCONFIG=/bin/true
|
||||
export dracutbasedir="${topdir}/lib/dracut"
|
||||
(exec "${topdir}/bin/dracut.real" "${@}")
|
||||
|
||||
if [ -n "${DRACUT_LDD}" ]; then
|
||||
rm -f "${DRACUT_LDD}"
|
||||
fi
|
||||
27
package/dracut/libc-links-module-setup.sh
Executable file
27
package/dracut/libc-links-module-setup.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Adds the missing links for uClibc or musl, if needed
|
||||
|
||||
check() {
|
||||
return 0
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
# Despite of the fact that the listed dependency (reported by readelf -d)
|
||||
# is purely /lib/libc.so, the musl symlink is needed anyway.
|
||||
musl_link="$(find "${dracutsysrootdir?}/lib/" -name "ld-musl-*.so*")"
|
||||
if [ -n "${musl_link}" ] ; then
|
||||
ln -s libc.so "${initdir?}/lib/${musl_link##*/}"
|
||||
fi
|
||||
|
||||
# Same for uClibc, the listed dependency
|
||||
# is ld-uClibc.so.1, the loader needs the ld-uClibc.so.0, too
|
||||
uclibc_link="$(find "${dracutsysrootdir?}/lib/" -name "ld-uClibc-*.so*")"
|
||||
if [ -n "$uclibc_link" ] ; then
|
||||
ln -s ld-uClibc.so.1 "${initdir?}/lib/ld-uClibc.so.0"
|
||||
fi
|
||||
}
|
||||
26
package/dracut/merged-usr-module-setup.sh
Normal file
26
package/dracut/merged-usr-module-setup.sh
Normal file
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user