Skip to content

Commit

Permalink
* openrc systemd hack added
Browse files Browse the repository at this point in the history
* initramfs update (remove shitty commits)
  • Loading branch information
sulincix committed Jun 8, 2024
1 parent ddffcbd commit 0cad3bb
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 6 deletions.
5 changes: 5 additions & 0 deletions sys/apps/openrc/ympbuild
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,10 @@ package(){
install ../disable-secondary-gpu.sh ${DESTDIR}/usr/libexec/disable-secondary-gpu
install ../disable-secondary-gpu.initd ${DESTDIR}/etc/init.d
install ../backlight-restore.initd ${DESTDIR}/etc/init.d
# systemd /proc/1/comm hack
# move openrc-run as systemd path and symlink
mkdir -p $DESTDIR/lib/systemd/
mv $DESTDIR/sbin/openrc-init $DESTDIR/lib/systemd/systemd
ln -s ../lib/systemd/systemd $DESTDIR/sbin/openrc-init
}

183 changes: 183 additions & 0 deletions sys/kernel/initramfs-tools/patches/no-dracut.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
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
21 changes: 15 additions & 6 deletions sys/kernel/initramfs-tools/ympbuild
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
name='initramfs-tools'
release='1'
version='0.142'
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'
Expand All @@ -10,11 +10,13 @@ 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=()
md5sums=('a3765010fe0fc6a71fe900a798b759ea'
sha256sums=('5d3091b0393c4246bcdae499cfd5ba490c78194d7eede01d951f4124ff2f9895'
'SKIP'
'SKIP'
'SKIP'
'SKIP'
Expand All @@ -26,9 +28,16 @@ arch=('x86_64')
cd $name-v$version

prepare(){
patch -Np1 < ../remove-zstd.patch
patch -Np1 < ../remove-logsave.patch
patch -Np1 < ../non-debian.patch
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&/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(){
Expand Down

0 comments on commit 0cad3bb

Please sign in to comment.