It's bullshit to use /lib/modules for kernel version
detection. If a module is still present but the according
linux-image has been removed the config/scripts will fail
since they run depmod for non-existing kernel versions.
So use /boot/vmlinuz-* instead.