summaryrefslogtreecommitdiff
path: root/eclass/linux-build.eclass
diff options
context:
space:
mode:
authorBertrand Jacquin <bertrand@jacquin.bzh>2016-09-02 01:36:17 +0100
committerBertrand Jacquin <bertrand@jacquin.bzh>2016-09-02 21:49:45 +0100
commit4c30eb4d9ed0c675e76ab471587783d654ae0ca3 (patch)
treebaf95aa6b5bea32d695fdfc5a6a9b00cdb8f95c3 /eclass/linux-build.eclass
parentnet-wireless/hostapd: Drop since hot vlan bridging is not needed anymore (diff)
downloadportage-4c30eb4d9ed0c675e76ab471587783d654ae0ca3.tar.xz
eclass/linux-build: Generate sys-boot/grub:0 config
Diffstat (limited to 'eclass/linux-build.eclass')
-rw-r--r--eclass/linux-build.eclass55
1 files changed, 55 insertions, 0 deletions
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"
}