initramfs modules swapping
idea: portting initramfs to use another kernel, so /lib/modules should be changed.
unmkinitramfs is helpful to handle prepended parts. and snippet from mkinitramfs(debian):
[ "$(id -ru)" != 0 ] && cpio_owner_root="-R 0:0"
cd "${DESTDIR}" && find . | LC_ALL=C sort | cpio --quiet $cpio_owner_root $cpio_reproducible -o -H newc >>"${outfile}" || exit 1
Code: (you can gzip -9 -n /tmp/T1F later)
# use T1 as base and T2 as /lib/modules
T1=$(mktemp)
T2=$(mktemp)
T1D=$(mktemp -d)
T2D=$(mktemp -d)
outfile=/tmp/T1F
wget -o $T1 URI1
wget -o $T2 URI2
unmkinitramfs $T1 $T1D
unmkinitramfs $T2 $T2D
find $T1D/lib/modules -delete
cp -a $T2D/lib/modules $T1D/lib
[ "$(id -ru)" != 0 ] && cpio_owner_root="-R 0:0"
cd $T1D && find . | LC_ALL=C sort | cpio --quiet $cpio_owner_root $cpio_reproducible -o -H newc >>"${outfile}" || exit 1