#!/bin/sh
# attempt to download kernel $KERNEL_VERSION from ibiblio
# and then copy it as vmlinuz/kernel-modules.sfs

### configuration
SRC_URL=http://distro.ibiblio.org/fatdog/kernels/900
KERNEL_VERSION=${KERNEL_VERSION-6.12.34} # update for new release
MICROCODE_DATE=${MICROCODE_DATE:-20250909} # overriden by build-iso.sh

### main
[ -z "$KERNEL_VERSION" ] && exit # do nothing if we don't have kernel version
mkdir -p kernels
if ! [ -e kernels/vmlinuz-$KERNEL_VERSION ]; then
	wget -P kernels -c $SRC_URL/vmlinuz-$KERNEL_VERSION
	wget -P kernels -c $SRC_URL/kernel-modules.sfs-$KERNEL_VERSION
fi
if ! [ -e kernels/microcode-update-${MICROCODE_DATE}.cpio ]; then
	wget -N -P kernels -c $SRC_URL/microcode-update-${MICROCODE_DATE}.cpio
fi

echo vmlinuz-$KERNEL_VERSION ready.
