mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-11-07 18:07:08 -08:00
sys-kernel/linux-firmware: use copy-firmware.sh to install firmwares
copy-firmware.sh will honor WHENCE file and will take care of symlinked firmwares. Closes: https://bugs.gentoo.org/751760 Package-Manager: Portage-3.0.8, Repoman-3.0.2 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
This commit is contained in:
+73
-85
@@ -30,11 +30,11 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
|
||||
unknown-license? ( all-rights-reserved )"
|
||||
SLOT="0"
|
||||
IUSE="initramfs +redistributable savedconfig unknown-license"
|
||||
REQUIRED_USE="initramfs? ( redistributable )"
|
||||
|
||||
RESTRICT="binchecks strip
|
||||
unknown-license? ( bindist )"
|
||||
|
||||
REQUIRED_USE="initramfs? ( redistributable )"
|
||||
|
||||
BDEPEND="initramfs? ( app-arch/cpio )"
|
||||
|
||||
#add anything else that collides to this
|
||||
@@ -60,6 +60,8 @@ RDEPEND="!savedconfig? (
|
||||
)
|
||||
)"
|
||||
|
||||
QA_PREBUILT="*"
|
||||
|
||||
pkg_pretend() {
|
||||
use initramfs && mount-boot_pkg_pretend
|
||||
}
|
||||
@@ -77,31 +79,40 @@ src_unpack() {
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
# source and documentation files, not to be installed
|
||||
local source_files=(
|
||||
README
|
||||
WHENCE
|
||||
"LICEN[CS]E*"
|
||||
"GPL*"
|
||||
configure
|
||||
Makefile
|
||||
check_whence.py
|
||||
atusb/ChangeLog
|
||||
av7110/Boot.S
|
||||
av7110/Makefile
|
||||
carl9170fw/
|
||||
cis/Makefile
|
||||
cis/src/
|
||||
dsp56k/bootstrap.asm
|
||||
dsp56k/concat-bootstrap.pl
|
||||
dsp56k/Makefile
|
||||
"isci/*.[ch]"
|
||||
isci/Makefile
|
||||
isci/README
|
||||
"keyspan_pda/*.S"
|
||||
keyspan_pda/Makefile
|
||||
usbdux/
|
||||
)
|
||||
default
|
||||
|
||||
find . -type f -not -perm 0644 -print0 \
|
||||
| xargs --null --no-run-if-empty chmod 0644 \
|
||||
|| die
|
||||
|
||||
chmod +x copy-firmware.sh || die
|
||||
|
||||
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
|
||||
|
||||
# whitelist of images with a free software license
|
||||
local free_software=(
|
||||
@@ -217,90 +228,67 @@ src_prepare() {
|
||||
lgs8g75.fw
|
||||
)
|
||||
|
||||
default
|
||||
|
||||
# remove sources and documentation (wildcards are expanded)
|
||||
rm -r ${source_files[@]} || die
|
||||
rm -rf .git
|
||||
|
||||
if use !unknown-license; then
|
||||
# remove files in unknown_license
|
||||
rm "${unknown_license[@]}" || die
|
||||
einfo "Removing files with unknown license ..."
|
||||
rm -v "${unknown_license[@]}" || die
|
||||
fi
|
||||
|
||||
if use !redistributable; then
|
||||
# remove files _not_ in the free_software or unknown_license lists
|
||||
# everything else is confirmed (or assumed) to be redistributable
|
||||
# based on upstream acceptance policy
|
||||
local IFS=$'\n'
|
||||
find ! -type d -printf "%P\n" \
|
||||
einfo "Removing non-redistributable files ..."
|
||||
IFS=$'\n' find ! -type d -printf "%P\n" \
|
||||
| grep -Fvx -e "${free_software[*]}" -e "${unknown_license[*]}" \
|
||||
| xargs -d '\n' rm || die
|
||||
IFS=$' \t\n'
|
||||
| xargs -d '\n' rm -v || die
|
||||
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"
|
||||
restore_config ${PN}.conf
|
||||
}
|
||||
|
||||
local amd_ucode_file="${UCODEDIR}/AuthenticAMD.bin"
|
||||
cat "${S}"/amd-ucode/*.bin > "${amd_ucode_file}" || die "Failed to concat amd cpu ucode"
|
||||
src_install() {
|
||||
./copy-firmware.sh -v "${ED}/lib/firmware" || die
|
||||
|
||||
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 -o -name amd-uc.img \) >> ${PN}.conf
|
||||
pushd "${ED}/lib/firmware" &>/dev/null || die
|
||||
|
||||
if use savedconfig; then
|
||||
restore_config ${PN}.conf
|
||||
if [[ -s "${S}/${PN}.conf" ]]; then
|
||||
local files_to_keep="${T}/files_to_keep.lst"
|
||||
grep -v '^#' "${S}/${PN}.conf" 2>/dev/null > "${files_to_keep}" || die
|
||||
[[ -s "${files_to_keep}" ]] || die "grep failed, empty config file?"
|
||||
|
||||
ebegin "Removing all files not listed in config"
|
||||
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
|
||||
eend $? || die
|
||||
einfo "Applying USE=savedconfig; Removing all files not listed in config ..."
|
||||
set -o pipefail
|
||||
find ! -type d -printf "%P\n" \
|
||||
| grep -Fvx -f "${files_to_keep}" \
|
||||
| xargs -d '\n' --no-run-if-empty rm -v
|
||||
|
||||
[[ ${?} -ne 0 ]] && die "Failed to remove files not listed in config"
|
||||
fi
|
||||
fi
|
||||
|
||||
# remove empty directories, bug #396073
|
||||
find -type d -empty -delete || die
|
||||
}
|
||||
|
||||
src_install() {
|
||||
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
|
||||
|
||||
# sanity check
|
||||
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."
|
||||
die "Refusing to install an empty package"
|
||||
fi
|
||||
|
||||
insinto /lib/firmware/
|
||||
doins -r *
|
||||
if use savedconfig; then
|
||||
echo "# Remove files that shall not be installed from this list." > "${S}"/${PN}.conf || die
|
||||
find * ! -type d >> "${S}"/${PN}.conf || die
|
||||
save_config "${S}"/${PN}.conf
|
||||
fi
|
||||
|
||||
popd &>/dev/null || die
|
||||
|
||||
if use initramfs ; then
|
||||
insinto /boot
|
||||
doins "${S}"/amd-uc.img
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_preinst() {
|
||||
@@ -30,11 +30,11 @@ LICENSE="GPL-2 GPL-2+ GPL-3 BSD MIT || ( MPL-1.1 GPL-2 )
|
||||
unknown-license? ( all-rights-reserved )"
|
||||
SLOT="0"
|
||||
IUSE="initramfs +redistributable savedconfig unknown-license"
|
||||
REQUIRED_USE="initramfs? ( redistributable )"
|
||||
|
||||
RESTRICT="binchecks strip
|
||||
unknown-license? ( bindist )"
|
||||
|
||||
REQUIRED_USE="initramfs? ( redistributable )"
|
||||
|
||||
BDEPEND="initramfs? ( app-arch/cpio )"
|
||||
|
||||
#add anything else that collides to this
|
||||
@@ -60,6 +60,8 @@ RDEPEND="!savedconfig? (
|
||||
)
|
||||
)"
|
||||
|
||||
QA_PREBUILT="*"
|
||||
|
||||
pkg_pretend() {
|
||||
use initramfs && mount-boot_pkg_pretend
|
||||
}
|
||||
@@ -77,31 +79,40 @@ src_unpack() {
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
# source and documentation files, not to be installed
|
||||
local source_files=(
|
||||
README
|
||||
WHENCE
|
||||
"LICEN[CS]E*"
|
||||
"GPL*"
|
||||
configure
|
||||
Makefile
|
||||
check_whence.py
|
||||
atusb/ChangeLog
|
||||
av7110/Boot.S
|
||||
av7110/Makefile
|
||||
carl9170fw/
|
||||
cis/Makefile
|
||||
cis/src/
|
||||
dsp56k/bootstrap.asm
|
||||
dsp56k/concat-bootstrap.pl
|
||||
dsp56k/Makefile
|
||||
"isci/*.[ch]"
|
||||
isci/Makefile
|
||||
isci/README
|
||||
"keyspan_pda/*.S"
|
||||
keyspan_pda/Makefile
|
||||
usbdux/
|
||||
)
|
||||
default
|
||||
|
||||
find . -type f -not -perm 0644 -print0 \
|
||||
| xargs --null --no-run-if-empty chmod 0644 \
|
||||
|| die
|
||||
|
||||
chmod +x copy-firmware.sh || die
|
||||
|
||||
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
|
||||
|
||||
# whitelist of images with a free software license
|
||||
local free_software=(
|
||||
@@ -217,90 +228,67 @@ src_prepare() {
|
||||
lgs8g75.fw
|
||||
)
|
||||
|
||||
default
|
||||
|
||||
# remove sources and documentation (wildcards are expanded)
|
||||
rm -r ${source_files[@]} || die
|
||||
rm -rf .git
|
||||
|
||||
if use !unknown-license; then
|
||||
# remove files in unknown_license
|
||||
rm "${unknown_license[@]}" || die
|
||||
einfo "Removing files with unknown license ..."
|
||||
rm -v "${unknown_license[@]}" || die
|
||||
fi
|
||||
|
||||
if use !redistributable; then
|
||||
# remove files _not_ in the free_software or unknown_license lists
|
||||
# everything else is confirmed (or assumed) to be redistributable
|
||||
# based on upstream acceptance policy
|
||||
local IFS=$'\n'
|
||||
find ! -type d -printf "%P\n" \
|
||||
einfo "Removing non-redistributable files ..."
|
||||
IFS=$'\n' find ! -type d -printf "%P\n" \
|
||||
| grep -Fvx -e "${free_software[*]}" -e "${unknown_license[*]}" \
|
||||
| xargs -d '\n' rm || die
|
||||
IFS=$' \t\n'
|
||||
| xargs -d '\n' rm -v || die
|
||||
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"
|
||||
restore_config ${PN}.conf
|
||||
}
|
||||
|
||||
local amd_ucode_file="${UCODEDIR}/AuthenticAMD.bin"
|
||||
cat "${S}"/amd-ucode/*.bin > "${amd_ucode_file}" || die "Failed to concat amd cpu ucode"
|
||||
src_install() {
|
||||
./copy-firmware.sh -v "${ED}/lib/firmware" || die
|
||||
|
||||
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 -o -name amd-uc.img \) >> ${PN}.conf
|
||||
pushd "${ED}/lib/firmware" &>/dev/null || die
|
||||
|
||||
if use savedconfig; then
|
||||
restore_config ${PN}.conf
|
||||
if [[ -s "${S}/${PN}.conf" ]]; then
|
||||
local files_to_keep="${T}/files_to_keep.lst"
|
||||
grep -v '^#' "${S}/${PN}.conf" 2>/dev/null > "${files_to_keep}" || die
|
||||
[[ -s "${files_to_keep}" ]] || die "grep failed, empty config file?"
|
||||
|
||||
ebegin "Removing all files not listed in config"
|
||||
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
|
||||
eend $? || die
|
||||
einfo "Applying USE=savedconfig; Removing all files not listed in config ..."
|
||||
set -o pipefail
|
||||
find ! -type d -printf "%P\n" \
|
||||
| grep -Fvx -f "${files_to_keep}" \
|
||||
| xargs -d '\n' --no-run-if-empty rm -v
|
||||
|
||||
[[ ${?} -ne 0 ]] && die "Failed to remove files not listed in config"
|
||||
fi
|
||||
fi
|
||||
|
||||
# remove empty directories, bug #396073
|
||||
find -type d -empty -delete || die
|
||||
}
|
||||
|
||||
src_install() {
|
||||
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
|
||||
|
||||
# sanity check
|
||||
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."
|
||||
die "Refusing to install an empty package"
|
||||
fi
|
||||
|
||||
insinto /lib/firmware/
|
||||
doins -r *
|
||||
if use savedconfig; then
|
||||
echo "# Remove files that shall not be installed from this list." > "${S}"/${PN}.conf || die
|
||||
find * ! -type d >> "${S}"/${PN}.conf || die
|
||||
save_config "${S}"/${PN}.conf
|
||||
fi
|
||||
|
||||
popd &>/dev/null || die
|
||||
|
||||
if use initramfs ; then
|
||||
insinto /boot
|
||||
doins "${S}"/amd-uc.img
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_preinst() {
|
||||
|
||||
Reference in New Issue
Block a user