From 4c30eb4d9ed0c675e76ab471587783d654ae0ca3 Mon Sep 17 00:00:00 2001 From: Bertrand Jacquin Date: Fri, 2 Sep 2016 01:36:17 +0100 Subject: eclass/linux-build: Generate sys-boot/grub:0 config --- eclass/linux-build.eclass | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'eclass') diff --git a/eclass/linux-build.eclass b/eclass/linux-build.eclass index a2e5dfd1..80a8efe9 100644 --- a/eclass/linux-build.eclass +++ b/eclass/linux-build.eclass @@ -134,6 +134,8 @@ linux-build_pkg_setup() { } _linux-build_src_prepare_build() { + local i + mkdir "${BUILDDIR}" restore_config "${BUILDDIR}/.config" @@ -150,6 +152,51 @@ _linux-build_src_prepare_build() { echo "${CONFIG_CMDLINE}" > "${WORKDIR}/boot/kernel.arg" fi + local -a BOOTLOADERS=( + sys-boot/grub:0 /boot/grub/grub.conf + ) + + for (( i = 0 ; i < ${#BOOTLOADERS[@]} ; i+=2 )) ; do + if has_version "${BOOTLOADERS[i]}" && [[ -e "${EPREFIX}/${BOOTLOADERS[i+1]}" ]] ; then + BOOTLOADER=Yes + BOOTLOADER_DIR="${BOOTLOADERS[i+1]%/*}" + BOOTLOADER_FILE="${BOOTLOADERS[i+1]##*/}" + + break + fi + done + + if [[ "${BOOTLOADER}" == "Yes" ]] ; then + KV_INSTALLED="$(best_version ${CATEGORY}/${PN}:${SLOT})" + KV_INSTALLED="${KV_INSTALLED/#${CATEGORY}\/${PN}-}" + + if [[ -n "${KV_INSTALLED}" ]] ; then + mkdir -p "${WORKDIR}/bootloader/${BOOTLOADER_DIR}" + + # Handle collision protect + for (( i = 0 ; i < 9999 ; i++ )) ; do + printf -v BOOTLOADER_PROTECTED_FILE "._cfg%04d_${BOOTLOADER_FILE}" "${i}" + if [[ ! -e "${EPREFIX}/${BOOTLOADER_DIR}/${BOOTLOADER_PROTECTED_FILE}" ]] ; then + break + fi + done + + einfo "Generating ${BOOTLOADER_DIR}/${BOOTLOADER_FILE}" + sed -e "s@${KV_INSTALLED}${KV_EXTRA}@${KV_FULL}@g" \ + "${EPREFIX}/${BOOTLOADER_DIR}/${BOOTLOADER_FILE}" \ + > "${WORKDIR}/bootloader/${BOOTLOADER_DIR}/${BOOTLOADER_PROTECTED_FILE}" + + if diff -q \ + "${EPREFIX}/${BOOTLOADER_DIR}/${BOOTLOADER_FILE}" \ + "${WORKDIR}/bootloader/${BOOTLOADER_DIR}/${BOOTLOADER_PROTECTED_FILE}" > /dev/null ; then + + rm "${WORKDIR}/bootloader/${BOOTLOADER_DIR}/${BOOTLOADER_PROTECTED_FILE}" + fi + + echo "CONFIG_PROTECT=${BOOTLOADER_DIR}/${BOOTLOADER_FILE}" > "${WORKDIR}/env.d_42-${PN}" + fi + fi + _linux-build_configval MODULES || ewarn "CONFIG_MODULES is not set" _linux-build_configval UEVENT_HELPER_PATH \ && ewarn "CONFIG_UEVENT_HELPER_PATH should be empty" @@ -335,6 +382,14 @@ _linux-build_src_install_build() { fperms 0400 "/etc/ssl/private/${PF}.key" fi + if [[ -d "${WORKDIR}/bootloader/boot" ]] ; then + insinto /boot + doins -r "${WORKDIR}"/bootloader/boot/* + + insinto /etc/env.d + newins "${WORKDIR}/env.d_42-${PN}" "42-${PN}" + fi + use savedconfig && save_config "${BUILDDIR}/.config" } -- cgit v1.2.3