mkinitrd replaced with initramfs-tools

This commit is contained in:
sulincix committed 2024-11-24 08:33:08 +00:00
1 parent b812c15233
commit 49b2dcd518
9 files changed
+46 -413

No files matched your search

@@ -1,10 +0,0 @@
#!/bin/sh
if [ ! -f /var/lib/ymp/sysconf/initramfs-tools/postinstall.done ] ; then
touch /etc/initramfs-tools/modules
mkdir -p /etc/initramfs-tools/scripts
fi
for kernel in $(ls /lib/modules) ; do
if [ ! -f /boot/initrd.img-$kernel ] ; then
update-initramfs -c -u -k $kernel
fi
done
@@ -1,183 +0,0 @@
diff --git a/debian/control b/debian/control
index 76a5627..70b8ff4 100644
--- a/debian/control
+++ b/debian/control
@@ -29,7 +29,6 @@ Multi-Arch: foreign
Recommends: zstd, ${busybox:Recommends}
Depends: coreutils (>= 8.24),
cpio (>= 2.12),
- dracut-install,
klibc-utils (>= 2.0.4-8~),
kmod,
logsave | e2fsprogs (<< 1.45.3-1~),
diff --git a/hook-functions b/hook-functions
index 7fccf0e..1ad074c 100644
--- a/hook-functions
+++ b/hook-functions
@@ -93,35 +93,47 @@ add_firmware()
# Call apply_add_modules to copy the kernel modules.
manual_add_modules()
{
- for module in "$@"; do
- echo "$module" >> "$__MODULES_TO_ADD"
- done
-}
-
-# Copy the kernel modules that were marked in manual_add_modules
-apply_add_modules()
-{
- # shellcheck disable=SC2046
- _call_dracut_install $(sort -u "$__MODULES_TO_ADD")
- true > "$__MODULES_TO_ADD"
-}
-
-_call_dracut_install()
-{
- local dracut_verbose fw_path_para
+ local prefix kmod options firmware
if [ $# -eq 0 ]; then
return
fi
- if [ "${verbose?}" = "y" ]; then
- dracut_verbose=-v
- fi
+ # modprobe --ignore-install inhibits processing of 'install'
+ # configuration lines, so that instead we will see 'insmod
+ # module.ko' as we want. However it also means that 'softdep'
+ # configuration lines and embedded softdep information is not
+ # processed. So we run twice, with and without this option.
+ # shellcheck disable=SC2034
+ { /sbin/modprobe --all --set-version="${version?}" --ignore-install --quiet --show-depends "$@";
+ /sbin/modprobe --all --set-version="${version}" --quiet --show-depends "$@"; } |
+ while read -r prefix kmod options ; do
+ if [ "${prefix}" != "insmod" ]; then
+ continue
+ fi
- read -r fw_path_para < /sys/module/firmware_class/parameters/path
- /usr/lib/dracut/dracut-install -D "$DESTDIR" --kerneldir "/lib/modules/${version?}" \
- --firmwaredirs "${fw_path_para:+${fw_path_para}:}/lib/firmware/updates/${version?}:/lib/firmware/updates:/lib/firmware/${version?}:/lib/firmware" \
- ${dracut_verbose-} -o -m "$@"
+ copy_file module "${kmod}" || continue
+
+ # Add required firmware
+ for firmware in $(modinfo -k "${version}" -F firmware "${kmod}"); do
+ # Only print warning for missing fw of loaded module
+ # or forced loaded module
+ if ! add_firmware "$firmware"; then
+ # Only warn about missing firmware if
+ # /proc/modules exists
+ if [ ! -e /proc/modules ] ; then
+ continue
+ fi
+
+ kmod_modname="${kmod##*/}"
+ kmod_modname="${kmod_modname%%.*}"
+ if grep -q "^$kmod_modname\\>" /proc/modules "${CONFDIR}/modules"; then
+ echo "W: Possible missing firmware /lib/firmware/${firmware} for module ${kmod_modname}" >&2
+ fi
+ continue
+ fi
+ done
+ done
}
# manual_add_modules() takes care of adding firmware for things that were built
@@ -795,72 +807,6 @@ auto_add_modules()
manual_add_modules $modules
}
-# 'depmod' only looks at symbol dependencies and the 'softdep' module
-# information field; there is no way for modules to declare weaker
-# dependencies (modules that *might* be needed at run-time) through
-# module information, Until this is fixed, we need to handle those
-# hidden dependencies.
-hidden_dep_add_modules()
-{
- # shellcheck disable=SC2046
- _call_dracut_install $(
- {
- cat "${DESTDIR}/lib/modules/${version}/modules.builtin"
- if [ -d "${DESTDIR}/lib/modules/${version}/kernel" ]; then
- find "${DESTDIR}/lib/modules/${version}/kernel" -name '*.ko*'
- fi
- } |
- while read -r module; do
- module="${module##*/}"
- module="${module%%.*}"
- case "$module" in
- libcrc32c)
- echo crc32c
- ;;
- ubifs)
- echo deflate zlib lzo
- ;;
- btrfs)
- echo crc32c
- ;;
- f2fs)
- echo crc32
- ;;
- mlx4_core)
- echo mlx4_ib
- ;;
- mlx5_core)
- echo mlx5_ib
- ;;
- i8042)
- echo psmouse
- ;;
- nvme)
- echo vmd
- ;;
- spi-rockchip)
- echo pl330
- ;;
- dw_mmc-rockchip)
- echo rockchip-io-domain io-domain
- ;;
- mediatek-drm)
- echo mediatek-drm-hdmi mtk_iommu mtk-smi
- ;;
- mtk_iommu)
- echo mtk-smi
- ;;
- phy-mtk-mipi-dsi-drv)
- echo nvmem_mtk-efuse
- ;;
- mt6397)
- echo mtk-pmic-wrap
- ;;
- esac
- done
- )
-}
-
# Find the source for a script file. This is needed to work around
# temporary directories mounted with the noexec option. The source
# will be on / or /usr which must be executable.
diff --git a/mkinitramfs b/mkinitramfs
index 40e0fd1..bc90423 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -424,7 +424,6 @@ for file in /etc/modprobe.d/*.conf /lib/modprobe.d/*.conf ; do
done
# Copy kernel modules here, because some hooks rely on them being copied
-apply_add_modules
run_scripts /usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks
@@ -433,10 +432,6 @@ for b in $(cd "${DESTDIR}/scripts" && find . -mindepth 1 -type d); do
cache_run_scripts "${DESTDIR}" "/scripts/${b#./}"
done
-apply_add_modules
-# Resolve hidden dependencies
-hidden_dep_add_modules
-
# decompress modules for boot speed, if possible
find "${DESTDIR}/${MODULESDIR}" -name '*.ko.*' | while read -r ko; do
case "$ko" in
@@ -1,53 +0,0 @@
diff --git a/hooks/resume b/hooks/resume
index 8ff84dd..439fe18 100755
--- a/hooks/resume
+++ b/hooks/resume
@@ -50,7 +50,7 @@ report_verbose "Configuration sets RESUME=$RESUME"
# Try to autodetect the RESUME partition, using biggest swap device that
# is not ephemeral. We need to be able to read the listed swap partitions.
resume_auto=
-if ! ischroot && [ -r /proc/swaps ]; then
+if ! [ `stat -c %d:%i /proc/$$/root/` == `stat -c %d:%i /` ] && [ -r /proc/swaps ]; then
# shellcheck disable=SC2013
for resume_auto in $(grep ^/dev/ /proc/swaps | sort -rnk3 | cut -d " " -f 1); do
report_verbose "Checking swap device $resume_auto"
diff --git a/mkinitramfs b/mkinitramfs
index df1b940..bdd71e4 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -284,7 +284,21 @@ __TMPCPIOGZ="$(mktemp "${TMPDIR:-/var/tmp}/mkinitramfs-OL_XXXXXX")" || exit 1
__TMPMAINCPIO="$(mktemp "${TMPDIR:-/var/tmp}/mkinitramfs-MAIN_XXXXXX")" || exit 1
__TMPEARLYCPIO="$(mktemp "${TMPDIR:-/var/tmp}/mkinitramfs-FW_XXXXXX")" || exit 1
-DPKG_ARCH=$(dpkg --print-architecture)
+get_dpkg_arch(){
+ case `uname -m` in
+ x86_64)
+ echo amd64
+ ;;
+ i686)
+ echo i386
+ ;;
+ aarch64)
+ echo arm64
+ ;;
+ esac
+}
+
+DPKG_ARCH=$(get_dpkg_arch)
# Export environment for hook scripts.
#
diff --git a/update-initramfs b/update-initramfs
index 746a6c1..0047670 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -167,7 +167,7 @@ run_bootloader()
ro_boot_check()
{
# check irrelevant inside of a chroot
- if [ ! -r /proc/mounts ] || ischroot; then
+ if [ ! -r /proc/mounts ] || [ `stat -c %d:%i /proc/$$/root/` == `stat -c %d:%i /` ]; then
return 0
fi
@@ -1,20 +0,0 @@
diff --git a/scripts/functions b/scripts/functions
index ae11b96..ec4e793 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -496,13 +496,13 @@ _checkfs_once()
then
log_begin_msg "Will now check $NAME file system"
# shellcheck disable=SC2086
- logsave -a -s $FSCK_LOGFILE fsck $spinner $force $fix -V -t "$TYPE" "$DEV"
+ fsck $spinner $force $fix -V -t "$TYPE" "$DEV" >> $FSCK_LOGFILE
FSCKCODE=$?
log_end_msg
else
log_begin_msg "Checking $NAME file system"
# shellcheck disable=SC2086
- logsave -a -s $FSCK_LOGFILE fsck $spinner $force $fix -T -t "$TYPE" "$DEV"
+ fsck $spinner $force $fix -T -t "$TYPE" "$DEV" >> $FSCK_LOGFILE
FSCKCODE=$?
log_end_msg
fi
@@ -1,82 +0,0 @@
diff --git a/conf/initramfs.conf b/conf/initramfs.conf
index aa561bd..bf80786 100644
--- a/conf/initramfs.conf
+++ b/conf/initramfs.conf
@@ -38,10 +38,10 @@ BUSYBOX=auto
KEYMAP=n
#
-# COMPRESS: [ gzip | bzip2 | lz4 | lzma | lzop | xz | zstd ]
+# COMPRESS: [ gzip | bzip2 | lz4 | lzma | lzop | xz ]
#
-COMPRESS=zstd
+COMPRESS=gzip
#
# COMPRESSLEVEL: ...
@@ -52,7 +52,6 @@ COMPRESS=zstd
# Valid values are:
# 1 - 9 for gzip|bzip2|lzma|lzop
# 0 - 9 for lz4|xz
-# 0 - 19 for zstd
#
# COMPRESSLEVEL=3
diff --git a/mkinitramfs b/mkinitramfs
index df1b940..166bffb 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -188,7 +188,6 @@ lzma) kconfig_sym=CONFIG_RD_LZMA ;;
xz) kconfig_sym=CONFIG_RD_XZ ;;
lzop) kconfig_sym=CONFIG_RD_LZO ;;
lz4) kconfig_sym=CONFIG_RD_LZ4 ;;
-zstd) kconfig_sym=CONFIG_RD_ZSTD ;;
esac
while ! grep -q "^$kconfig_sym=y" "/boot/config-${version}"; do
if [ "${compress}" = gzip ]; then
@@ -205,7 +204,6 @@ if [ -z "${compresslevel:-}" ]; then
fi
case "${compress}" in
lz4) compresslevel="-${compresslevel:-9}" ;;
-zstd) compresslevel="-${compresslevel:-9}" ;;
#gzip|xz|bzip2|lzma|lzop included
*)
# We're not using a compression level by default
@@ -227,10 +225,6 @@ gzip) # If we're doing a reproducible build, use gzip -n
fi
;;
lz4) compress="lz4 ${compresslevel} -l" ;;
-zstd) compress="zstd -q ${compresslevel}"
- # If we're not doing a reproducible build, enable multithreading
- test -z "${SOURCE_DATE_EPOCH}" && compress="$compress -T0"
- ;;
xz) compress="xz ${compresslevel} --check=crc32"
# If we're not doing a reproducible build, enable multithreading
test -z "${SOURCE_DATE_EPOCH}" && compress="$compress --threads=0"
@@ -426,12 +420,6 @@ find "${DESTDIR}/${MODULESDIR}" -name '*.ko.*' | while read -r ko; do
fi
xz -d "${ko}"
;;
- *.zst)
- if ! command -v zstd >/dev/null 2>&1; then
- break
- fi
- zstd -q -d --rm "${ko}"
- ;;
esac
done
diff --git a/unmkinitramfs b/unmkinitramfs
index d1226c3..3f8c75d 100755
--- a/unmkinitramfs
+++ b/unmkinitramfs
@@ -31,8 +31,6 @@ xcpio()
if gzip -t "$archive" >/dev/null 2>&1 ; then
gzip -c -d "$archive"
- elif zstd -q -c -t "$archive" >/dev/null 2>&1 ; then
- zstd -q -c -d "$archive"
elif xzcat -t "$archive" >/dev/null 2>&1 ; then
xzcat "$archive"
elif lz4cat -t < "$archive" >/dev/null 2>&1 ; then
-60
View File
@@ -1,60 +0,0 @@
#!/usr/bin/env bash
name='initramfs-tools'
release='2'
version='0.143'
url='https://salsa.debian.org/kernel-team/initramfs-tools'
description='Initial ramdisk system from debian'
email='aliriza.keskin@pardus.org.tr'
maintainer='aliriza'
license=('GPLv3')
source=("https://salsa.debian.org/kernel-team/initramfs-tools/-/archive/v$version/initramfs-tools-v$version.tar.gz"
"patches/remove-zstd.patch"
"patches/non-debian.patch"
"patches/no-dracut.patch"
"patches/remove-logsave.patch"
"initramfs-tools.sysconf")
depends=(eudev findutils coreutils)
makedepends=()
sha256sums=('5d3091b0393c4246bcdae499cfd5ba490c78194d7eede01d951f4124ff2f9895'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
'SKIP')
uses=()
group=(sys.kernel)
arch=('x86_64')
cd $name-v$version
prepare(){
patch -Np1 -i ../remove-zstd.patch
patch -Np1 -i ../remove-logsave.patch
patch -Np1 -i ../non-debian.patch
patch -Np1 -i ../no-dracut.patch
# hidepid=2 default
sed -i "s/ proc \/proc/,hidepid=2,gid=31&/g" init
# replace linux-version command
sed -i "s/linux-version/false/g" hook-functions
sed -i "s/linux-version list/ls \/lib\/modules\//g" update-initramfs
sed -i "s/linux-version sort --reverse/cat/g" update-initramfs
}
package(){
cat debian/*.install | sed "s/\t/ /g" | tr -s " " | while read line ; do
file=$(echo $line | cut -f1 -d" ")
target=$(echo $line | cut -f2 -d" ")
mkdir -p ${DESTDIR}/$target
cp -prvf $file ${DESTDIR}/$target/
done
# install mkinitramfs
cp -pvf mkinitramfs ${DESTDIR}/usr/sbin/mkinitramfs
sed -i "s/@BUSYBOX_PACKAGES@/busybox/g" ${DESTDIR}/usr/sbin/mkinitramfs
sed -i "s/@BUSYBOX_MIN_VERSION@/1.22.0/g" ${DESTDIR}/usr/sbin/mkinitramfs
# Remove debian stuff
rm -rvf ${DESTDIR}/etc/kernel
# install sysconf
mkdir -p ${DESTDIR}/etc/sysconf.d
install ../initramfs-tools.sysconf ${DESTDIR}/etc/sysconf.d/initramfs-tools
}
+5 -5
View File
@@ -1,16 +1,16 @@
#!/usr/bin/env bash
name='live-boot'
release='3'
version='1.1'
url='https://gitlab.com/turkman'
release='4'
version='2.0'
url='https://gitlab.com/turkman/devel/sources/live-boot'
description='initramfs tools live hooks'
email='aliriza.keskin@pardus.org.tr'
maintainer='aliriza'
license=('GPLv3')
source=("https://gitlab.com/turkman/devel/sources/live-boot/-/archive/$version/live-boot-$version.tar.gz")
depends=(initramfs-tools)
depends=(mkinitrd)
makedepends=()
sha256sums=('d4ede85d23ede6f5e82c95170936900b0801d5ac4c136f34c81f1f6dec73b2f2')
sha256sums=('f356639410bc9d2a097266da13b85d111369c97cf8aa6dc6f7dea03e77ced5de')
group=(sys.kernel)
uses=()
arch=('x86_64')
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
if grep "boot=live" /proc/cmdline >/dev/null ; then
exit 0
fi
for kernel in $(ls /lib/modules) ; do
if [ ! -f /boot/initrd.img-$kernel ] ; then
mkinitrd -u -k $kernel
fi
done
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
name='mkinitrd'
release='1'
version='0.0.1'
url='https://gitlab.com/turkman/devel/sources/mkinitrd'
description='Initial ramdisk system from turkman linux'
email='aliriza.keskin@pardus.org.tr'
maintainer='aliriza'
license=('GPLv3')
source=("https://gitlab.com/turkman/devel/sources/mkinitrd/-/archive/$version/mkinitrd-$version.tar.gz"
"mkinitrd.sysconf")
depends=(eudev findutils coreutils)
makedepends=()
sha256sums=('21811112b57f69439240d9658ebdf2c078b52d7762d4c50b718cd3693b5d5c16'
'SKIP')
uses=()
group=(sys.kernel)
arch=('x86_64')
cd $name-$version
setup(){
meson setup build \
--bindir=/bin
}
package(){
ninja -C build install
# sysconf trigger
mkdir -p $DESTDIR/etc/sysconf.d
install ../mkinitrd.sysconf $DESTDIR/etc/sysconf.d/mkinitrd
}