sys-kernel/booster: update ebuild

This commit is contained in:
2024-09-27 14:57:54 +03:00
parent 47c9bd3ebc
commit 9b71c7e3b7
5 changed files with 97 additions and 4 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# this file is installed by sys-kernel/ugrd
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=
# Exit if ugrd is not the INSTALLKERNEL_INITRD_GENERATOR
[[ ${INSTALLKERNEL_INITRD_GENERATOR} == "booster" ]] || exit 0
# do nothing if somehow ugrd is not installed
[[ -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

View File

@@ -0,0 +1,15 @@
#!/bin/sh
COMMAND="${1:?}"
KERNEL_VERSION="${2:?}"
# Do not attempt to create initramfs if the supplied image is already a UKI
[ "${KERNEL_INSTALL_IMAGE_TYPE}" = "uki" ] && exit 0
# Only run if the initrd generator is ugrd
[ "${KERNEL_INSTALL_INITRD_GENERATOR}" = "booster" ] || exit 0
# only run when the COMMAND is add, and fewer than 5 arguments are passed
[ "${COMMAND}" = "add" ] && [ "${#}" -lt 5 ] || exit 0
booster "$([ "${KERNEL_INSTALL_VERBOSE}" = 1 ] && echo --verbose)" --kernel-version="${KERNEL_VERSION}" "${KERNEL_INSTALL_STAGING_AREA}/initrd" || exit 1