From 430cd51d222a4754a170603fc9a5d88c2bd04144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D0=B8=D1=80=D0=B5=D1=86=D0=BA=D0=B8=D0=B9=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 9 Jun 2020 13:19:15 +0300 Subject: [PATCH] =?UTF-8?q?calculate-kernel-8.eclass:=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=D0=BE=20=D1=81=D0=B6=D0=B0=D1=82=D0=B8?= =?UTF-8?q?=D0=B5=20initramfs=20=D0=BF=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B0=D0=BD=D0=B8=D1=8E=20(zstd,gzip,xz)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eclass/calculate-kernel-8.eclass | 236 ++++++++++++++++++ .../calculate-sources-5.6.17.ebuild | 6 +- 2 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 eclass/calculate-kernel-8.eclass diff --git a/eclass/calculate-kernel-8.eclass b/eclass/calculate-kernel-8.eclass new file mode 100644 index 000000000..8fdcd1ee4 --- /dev/null +++ b/eclass/calculate-kernel-8.eclass @@ -0,0 +1,236 @@ +# Copyright 1999-2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# +# Original Author: © 2007-2009 Mir Calculate, Ltd. +# Purpose: Installing linux-desktop, linux-server. +# Build the kernel from source. +# @ECLASS: calculate-kernel-8.eclass +# @MAINTAINER: +# support@calculate.ru +# @AUTHOR: +# Author: Mir Calculate +# @BLURB: Functions for calculate-sources +# @DESCRIPTION: +# This eclass use for calculate-sources ebuild + +inherit calculate eutils kernel-2 +EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postinst + + +REQUIRED_USE="minimal? ( vmlinuz )" + +CDEPEND="vmlinuz? ( || ( app-arch/xz-utils app-arch/lzma-utils ) + grub? ( sys-boot/grub ) + ) + firmware? ( || ( sys-kernel/linux-firmware + sys-firmware/eth-firmware ) )" + +DEPEND="${CDEPEND} + >=sys-devel/bison-1.875 + >=sys-devel/flex-2.5.4 + themes? ( || ( media-gfx/splash-themes-calculate + sys-boot/plymouth-calculate-plugin ) ) + !minimal? ( virtual/pkgconfig ) + " + +RDEPEND="${CDEPEND} vmlinuz? ( sys-kernel/dracut )" + +detect_version +detect_arch + +IUSE="+vmlinuz desktop pae minimal themes firmware +grub" + +if [[ ${KV_MAJOR} -lt 3 ]] +then + die "Eclass is used only for kernel-3" +fi + +SLOT=${PV} +EXTRAVERSION="-${KERNELNAME:-calculate}" +KV_FULL="${PV}${EXTRAVERSION}" + +S="${WORKDIR}/linux-${KV_FULL}" + +calculate-kernel-8_pkg_setup() { + kernel-2_pkg_setup + eqawarn "!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!" + eqawarn "After the kernel assemble perform command to update modules:" + eqawarn " emerge @modules-rebuild" +} + +calculate-kernel-8_src_unpack() { + kernel-2_src_unpack + cd ${S} + local GENTOOARCH="${ARCH}" + unset ARCH + emake defconfig || die "kernel configure failed" + ARCH="${GENTOOARCH}" +} + +vmlinuz_clean_localversion() { + sed -ri 's/^(CONFIG_LOCALVERSION=")[^"]+"/\1"/' .config + sed -ri 's/^(CONFIG_LOCALVERSION_AUTO)=.*$/# \1 is not set/' .config + rm -f localversion* +} + +vmlinuz_src_compile() { + # disable sandbox + local GENTOOARCH="${ARCH}" + unset ARCH + cd ${S} + vmlinuz_clean_localversion + emake olddefconfig || die "kernel configure failed" + emake && emake modules || die "kernel build failed" + [ -f .config ] && cp .config .config.save + ARCH="${GENTOOARCH}" +} + +calculate-kernel-8_src_compile() { + use vmlinuz && vmlinuz_src_compile +} + +vmlinuz_src_install() { + # dracut change this files in chroot of ramdisk + SANDBOX_WRITE="${SANDBOX_WRITE}:/run/blkid:/etc/ld.so.cache~:/etc/ld.so.cache:/etc/mtab" + cd ${S} + dodir /usr/share/${PN}/${PV}/boot + INSTALL_PATH=${D}/usr/share/${PN}/${PV}/boot emake install + INSTALL_MOD_PATH=${D} emake modules_install + /sbin/depmod -b ${D} ${KV_FULL} + + if use themes + then + PLYMOUTH="-a plymouth" + else + PLYMOUTH="-o plymouth" + fi + + if grep -q CONFIG_RD_ZSTD=y .config &>/dev/null + then + RDARCH="--zstd" + elif grep -q CONFIG_RD_GZIP=y .config &>/dev/null + then + RDARCH="--gzip" + elif grep -q CONFIG_RD_XZ=y .config &>/dev/null + then + RDARCH="--xz" + else + RDARCH="" + fi + /usr/bin/dracut $RDARCH -a calculate $PLYMOUTH -a video -k ${D}/lib/modules/${KV_FULL} \ + --kver ${KV_FULL} \ + ${D}/usr/share/${PN}/${PV}/boot/initramfs-${KV_FULL} + # move firmware to share, because /lib/firmware installation does collisions + mv ${D}/lib/firmware ${D}/usr/share/${PN}/${PV} + insinto /usr/share/${PN}/${PV}/boot/ + newins .config config-${KV_FULL} + + # recreate symlink in /lib/modules because symlink point to tmp/portage after make install + rm ${D}/lib/modules/${KV_FULL}/build + rm ${D}/lib/modules/${KV_FULL}/source + dosym /usr/src/linux-${KV_FULL} \ + "/lib/modules/${KV_FULL}/source" || + die "cannot install source symlink" + dosym /usr/src/linux-${KV_FULL} \ + "/lib/modules/${KV_FULL}/build" || + die "cannot install build symlink" +} + +# FUNCTION: clean_for_minimal +# DESCRIPTION: +# Clear kernel sources, keeping only need for custom modules compilation +clean_for_minimal() { + local GENTOOARCH="${ARCH}" + unset ARCH + ARCH="${GENTOOARCH}" + + mkdir backup + cp Module.symvers backup + emake distclean &>/dev/null || die "cannot perform distclean" + mv .config.save .config + ebegin "kernel: >> Running modules_prepare..." + emake modules_prepare &>/dev/null + eend $? "Failed modules prepare" + einfo "Cleaning sources" + for rmpath in $(ls arch | grep -v x86) + do + rm -r arch/$rmpath + done + mv backup/Module.symvers . + rmdir backup + KEEPLIST="scripts/Makefile.lib scripts/module-common.lds \ + scripts/gcc-version.sh scripts/Makefile.help \ + scripts/Makefile.modinst scripts/Makefile.asm-generic \ + scripts/Makefile.modbuiltin scripts/Makefile.fwinst \ + scripts/Makefile.modfinal \ + scripts/Makefile.extrawarn scripts/Makefile.kasan \ + scripts/depmod.sh scripts/Makefile.host \ + scripts/Makefile.gcc-plugins \ + Module.symvers \ + scripts/Makefile.ubsan \ + scripts/Makefile.kcov \ + scripts/subarch.include \ + scripts/Kbuild.include scripts/Makefile.modpost \ + scripts/gcc-goto.sh scripts/Makefile.headersinst \ + scripts/Makefile.build scripts/basic/fixdep \ + scripts/Makefile.clean scripts/mod/modpost \ + tools/objtool/objtool \ + include/config/kernel.release include/config/auto.conf \ + arch/x86/Makefile_32.cpu arch/x86/Makefile \ + System.map Kconfig Makefile Kbuild" + find . -type f -a \! -wholename ./.config \ + $(echo $KEEPLIST | sed -r 's/(\S+)(\s|$)/-a \! -wholename .\/\1 /g') \ + -a \! -name "*.h" -delete + find . -type l -delete + rm -r drivers + rm -r Documentation +} + +calculate-kernel-8_src_install() { + use vmlinuz && vmlinuz_src_install + use minimal && clean_for_minimal + kernel-2_src_install + if ! use vmlinuz + then + dodir /usr/share/${PN}/${PV}/boot + insinto /usr/share/${PN}/${PV}/boot + newins .config config-${KV_FULL} + fi + use vmlinuz && touch ${D}/usr/src/linux-${KV_FULL}/.calculate +} + +vmlinuz_pkg_postinst() { + # install kernel into /boot + calculate_update_ver /boot vmlinuz ${KV_FULL} /usr/share/${PN}/${PV}/boot/vmlinuz-${KV_FULL} + calculate_update_ver /boot config ${KV_FULL} /usr/share/${PN}/${PV}/boot/config-${KV_FULL} + calculate_update_ver /boot initramfs ${KV_FULL} /usr/share/${PN}/${PV}/boot/initramfs-${KV_FULL} .img + calculate_update_ver /boot System.map ${KV_FULL} /usr/share/${PN}/${PV}/boot/System.map-${KV_FULL} + # install firmware into / + mkdir -p ${ROOT}/lib/firmware + cp -a ${ROOT}/usr/share/${PN}/${PV}/firmware/* ${ROOT}/lib/firmware/ + calculate_update_depmod + calculate_update_modules +} + +calculate-kernel-8_pkg_postinst() { + kernel-2_pkg_postinst + + KV_OUT_DIR=${ROOT}/usr/src/linux-${KV_FULL} + use vmlinuz && cp -p /usr/share/${PN}/${PV}/boot/System.map* ${KV_OUT_DIR}/System.map + + if ! use minimal + then + cd ${KV_OUT_DIR} + local GENTOOARCH="${ARCH}" + unset ARCH + ebegin "kernel: >> Running modules_prepare..." + (emake oldconfig && emake modules_prepare) &>/dev/null + eend $? "Failed modules prepare" + ARCH="${GENTOOARCH}" + fi + + use vmlinuz && vmlinuz_pkg_postinst + use vmlinuz && calculate_fix_lib_modules_contents +} diff --git a/sys-kernel/calculate-sources/calculate-sources-5.6.17.ebuild b/sys-kernel/calculate-sources/calculate-sources-5.6.17.ebuild index 65781ca76..1210fed76 100644 --- a/sys-kernel/calculate-sources/calculate-sources-5.6.17.ebuild +++ b/sys-kernel/calculate-sources/calculate-sources-5.6.17.ebuild @@ -5,7 +5,7 @@ EAPI=5 ETYPE="sources" -inherit calculate-kernel-7 eutils +inherit calculate-kernel-8 eutils DESCRIPTION="Calculate Linux kernel image" KEYWORDS="~amd64" @@ -16,9 +16,9 @@ SRC_URI="${KERNEL_URI} ${ARCH_URI}" IUSE="fsync muqss uksm" src_unpack() { - calculate-kernel-7_src_unpack + calculate-kernel-8_src_unpack } pkg_postinst() { - calculate-kernel-7_pkg_postinst + calculate-kernel-8_pkg_postinst }