From fc637fb28da700da71ec2064d65ca5a7a31b9c6c Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 18 Aug 2019 18:16:17 +0100 Subject: gentoo resync : 18.08.2019 --- .../linux-firmware/linux-firmware-99999999.ebuild | 67 +++++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'sys-kernel/linux-firmware/linux-firmware-99999999.ebuild') diff --git a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild index f439b40eab43..c32364b9d6a2 100644 --- a/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild +++ b/sys-kernel/linux-firmware/linux-firmware-99999999.ebuild @@ -2,7 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 EAPI=7 -inherit savedconfig +inherit mount-boot savedconfig if [[ ${PV} == 99999999* ]]; then inherit git-r3 @@ -21,10 +21,13 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 ) linux-fw-redistributable ( BSD-2 BSD BSD-4 ISC MIT no-source-code ) ) unknown-license? ( all-rights-reserved )" SLOT="0" -IUSE="+redistributable savedconfig unknown-license" +IUSE="initramfs +redistributable savedconfig unknown-license" RESTRICT="binchecks strip unknown-license? ( bindist )" +BDEPEND="initramfs? ( app-arch/cpio )" + +#add anything else that collides to this RDEPEND="!savedconfig? ( redistributable? ( !sys-firmware/alsa-firmware[alsa_cards_ca0132] @@ -69,7 +72,9 @@ RDEPEND="!savedconfig? ( ) )" -#add anything else that collides to this +pkg_pretend() { + use initramfs && mount-boot_pkg_pretend +} src_unpack() { if [[ ${PV} == 99999999* ]]; then @@ -244,14 +249,41 @@ src_prepare() { IFS=$' \t\n' fi + if use initramfs; then + if [[ -d "${S}/amd-ucode" ]]; then + local UCODETMP="${T}/ucode_tmp" + local UCODEDIR="${UCODETMP}/kernel/x86/microcode" + mkdir -p "${UCODEDIR}" || die + echo 1 > "${UCODETMP}/early_cpio" + + local amd_ucode_file="${UCODEDIR}/AuthenticAMD.bin" + cat "${S}"/amd-ucode/*.bin > "${amd_ucode_file}" || die "Failed to concat amd cpu ucode" + + if [[ ! -s "${amd_ucode_file}" ]]; then + die "Sanity check failed: '${amd_ucode_file}' is empty!" + fi + + pushd "${UCODETMP}" &>/dev/null || die + find . -print0 | cpio --quiet --null -o -H newc -R 0:0 > "${S}"/amd-uc.img + popd &>/dev/null || die + if [[ ! -s "${S}/amd-uc.img" ]]; then + die "Failed to create '${S}/amd-uc.img'!" + fi + else + # If this will ever happen something has changed which + # must be reviewed + die "'${S}/amd-ucode' not found!" + fi + fi + echo "# Remove files that shall not be installed from this list." > ${PN}.conf - find * ! -type d ! -name ${PN}.conf >> ${PN}.conf + find * ! -type d ! \( -name ${PN}.conf -o -name amd-uc.img \) >> ${PN}.conf if use savedconfig; then restore_config ${PN}.conf ebegin "Removing all files not listed in config" - find ! -type d ! -name ${PN}.conf -printf "%P\n" \ + find ! -type d ! \( -name ${PN}.conf -o -name amd-uc.img \) -printf "%P\n" \ | grep -Fvx -f <(grep -v '^#' ${PN}.conf \ || die "grep failed, empty config file?") \ | xargs -d '\n' --no-run-if-empty rm @@ -263,11 +295,14 @@ src_prepare() { } src_install() { - if use !savedconfig; then - save_config ${PN}.conf - fi + save_config ${PN}.conf rm ${PN}.conf || die + if use initramfs ; then + mkdir "${ED}/boot" || die + mv "${S}"/amd-uc.img "${ED}/boot" || die + fi + if ! ( shopt -s failglob; : * ) 2>/dev/null; then eerror "No files to install. Check your USE flag settings" eerror "and the list of files in your saved configuration." @@ -282,6 +317,9 @@ pkg_preinst() { if use savedconfig; then ewarn "USE=savedconfig is active. You must handle file collisions manually." fi + + # Make sure /boot is available if needed. + use initramfs && mount-boot_pkg_preinst } pkg_postinst() { @@ -298,4 +336,17 @@ pkg_postinst() { break fi done + + # Don't forget to umount /boot if it was previously mounted by us. + use initramfs && mount-boot_pkg_postinst +} + +pkg_prerm() { + # Make sure /boot is mounted so that we can remove /boot/amd-uc.img! + use initramfs && mount-boot_pkg_prerm +} + +pkg_postrm() { + # Don't forget to umount /boot if it was previously mounted by us. + use initramfs && mount-boot_pkg_postrm } -- cgit v1.2.3