2024-09-27 14:57:54 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-09-27 15:04:13 +03:00
|
|
|
# this file is installed by sys-kernel/booster
|
2024-09-27 14:57:54 +03:00
|
|
|
|
|
|
|
ver=${1}
|
|
|
|
img=${2}
|
|
|
|
initrd=$(dirname "${img}")/initrd
|
|
|
|
|
|
|
|
# familiar helpers, we intentionally don't use Gentoo functions.sh
|
|
|
|
die() {
|
|
|
|
echo -e " ${NOCOLOR-\e[1;31m*\e[0m }${*}" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
einfo() {
|
|
|
|
echo -e " ${NOCOLOR-\e[1;32m*\e[0m }${*}" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
ewarn() {
|
|
|
|
echo -e " ${NOCOLOR-\e[1;33m*\e[0m }${*}" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
# re-define for subst to work
|
|
|
|
[[ -n ${NOCOLOR+yes} ]] && NOCOLOR=
|
|
|
|
|
2024-09-27 15:04:13 +03:00
|
|
|
# Exit if booster is not the INSTALLKERNEL_INITRD_GENERATOR
|
2024-09-27 14:57:54 +03:00
|
|
|
[[ ${INSTALLKERNEL_INITRD_GENERATOR} == "booster" ]] || exit 0
|
|
|
|
|
2024-09-27 15:04:13 +03:00
|
|
|
# do nothing if somehow booster is not installed
|
2024-09-27 14:57:54 +03:00
|
|
|
[[ -x $(command -v booster) ]] || { ewarn "booster is not installed" && exit 0 ; }
|
|
|
|
|
|
|
|
[[ ${EUID} -eq 0 ]] || die "Please run this script as root"
|
|
|
|
|
|
|
|
booster build --kernel-version="${ver}" "${initrd}" || die "Failed to generate initramfs"
|
|
|
|
}
|
|
|
|
|
|
|
|
main
|