37 lines
987 B
Bash
37 lines
987 B
Bash
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
destdir="$(readlink -e "$1")"
|
|
|
|
kver=$(rpm --root "${destdir}" -q --qf '%{VERSION}-%{RELEASE}.%{ARCH}' kernel)
|
|
printf 'Building initramfs image for kernel %s\n' "${kver}"
|
|
|
|
cd "${destdir}"
|
|
mkdir -p boot dev proc sys tmp
|
|
mountpoint -q dev || mount -o bind /dev dev
|
|
mountpoint -q proc || mount -t proc proc proc
|
|
mountpoint -q sys || mount -t sysfs sysfs sys
|
|
mountpoint -q tmp || mount -t tmpfs tmpfs tmp
|
|
|
|
echo 'Copying kernel image to /boot/ ...' >&2
|
|
cp -a "${destdir}"/lib/modules/"${kver}"/vmlinuz \
|
|
"${destdir}"/boot/
|
|
echo 'Running depmod ...' >&2
|
|
chroot "${destdir}" depmod -a "${kver}"
|
|
echo 'Building initramfs image ...' 2>&1
|
|
chroot "${destdir}" dracut \
|
|
--no-hostonly \
|
|
--add 'nbd' \
|
|
--add-drivers 'genet nbd squashfs' \
|
|
--force \
|
|
/boot/initramfs.img \
|
|
"${kver}"
|
|
echo 'Fixing boot file pemissions ...' 2>&1
|
|
find "${destdir}"/boot \
|
|
-type d -exec chmod a+rx {} + \
|
|
-or \
|
|
-type f -exec chmod a+r {} +
|
|
|
|
umount tmp sys proc dev
|