summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2020-01-01 17:31:11 +0100
committerMichał Górny <mgorny@gentoo.org>2020-01-01 23:00:32 +0100
commit1fa40d404d2e4513bb6d2f41d7839742c063c8c9 (patch)
tree5754c7c9fb8ebd9760d7b77bc800a1c60b1b1e08
parentsys-kernel/vanilla-kernel-bin: Use 'mv' to optimize install (diff)
downloadgentoo-1fa40d40.tar.gz
gentoo-1fa40d40.tar.bz2
gentoo-1fa40d40.zip
sys-kernel/vanilla-kernel: Bump to 5.4.7
Strip installed files to the bare minimum while at it, following CentOS' kernel-devel packages. Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--sys-kernel/vanilla-kernel/Manifest2
-rw-r--r--sys-kernel/vanilla-kernel/vanilla-kernel-5.4.7.ebuild284
2 files changed, 286 insertions, 0 deletions
diff --git a/sys-kernel/vanilla-kernel/Manifest b/sys-kernel/vanilla-kernel/Manifest
index a3a71cc7a0de..b56d5ea70452 100644
--- a/sys-kernel/vanilla-kernel/Manifest
+++ b/sys-kernel/vanilla-kernel/Manifest
@@ -1,5 +1,7 @@
DIST linux-5.4.3-arch1.i686.config 241295 BLAKE2B 795b6286bd1e7dc6aa5c1428e7bf08c204ce6c8cbee57863e9f64f8990790cc4398a7d062b54c89b1b80640f02a40fce028d9397725db0f968e8028b0611a20f SHA512 8c7387ded21c02b9cffee0e6d61a7040c44deae21764f743f7719f0d1c7adf684f6b62a501fe31709787ba741859e55fc3b8a3d3d27e52c09f2d8604212bf0a7
DIST linux-5.4.4.arch1-1.amd64.config 241587 BLAKE2B 71db76bf30a8d7f4dc680399b9f9fbb4236d1938bb86e23eb1ab236a667a959fc1cff788f7e432c43a6173e1bac4e20f3a6c3391d84275d46f1f66bd338bf538 SHA512 34d66658963dbd72fa3e96f2c5d5bccafb781fa14f6ebafe7859953929ba2fbb112f1435ca68cec8389d789cf0efa81d5fc0f5ac6dfa23a704348ab83709e9db
DIST linux-5.4.6.tar.xz 109454640 BLAKE2B 8619492fedd4ae489a811561f72285b69deb827bb1db1f65be2a128d3bcbb69bdeec6b73650e1e8f72b18e5016c2df092bc77ee38be756d35f2903ecf0db1687 SHA512 9e1153e80303d6d5016856a25f3757259a3a428bad11208192315088d1f1a09957f5b8e966ab8cb5842ce1a740760f87474066294f8b410e9c44c810838bcdac
+DIST linux-5.4.7.arch1-1.amd64.config 241598 BLAKE2B 536cce5cc23cf20e71cba7468a125557f85d8ffc3cb194dced79bd489d39f2e4ed3960816d15d1491007d11b3af466e0a74267f983dfcc5f511f9f566f7e9821 SHA512 8658db603e180c75caf76972d85ecf8a4e9c9cf6e047b4f9fc7cba0fa426f434361528c1c29b5580f116cdd23091bf9afb6635d751f3b90c4e968d16db90eac1
+DIST linux-5.4.7.tar.xz 109448088 BLAKE2B 70197bb6955253710be5b56660dd6e224d3415f9074afeac9525d28089a6c1aa307408cf6bf460370093b8d079837850136a06dee2f3203370ed6cd8ab4d6e66 SHA512 b3b6c843bb8210acf04d294887b527c2da10507ac731fe9f6f04cd21486d519cda5767a2ba094f10886717720ca3bd3dee22a650c213b7f8f6c1f825396dbed4
DIST tinycorelinux-10.1-amd64.qcow2 16842752 BLAKE2B e013e76503c335739a9623c0901ca791937a0e6b177854535cadec1e2c2cd2df588283ed3128cf652595f32264fbfe5b3bd3a8c97665fd4da344e308535be366 SHA512 c3aeb20ff8769da9211694b7f701907cc7ae7582cdfad2c2fdc008d97ebcbd9dc08245b4e8f8450e1cb304bd705345a11fe79f901a47979fee91443841d55641
DIST tinycorelinux-10.1-x86.qcow2 14876672 BLAKE2B 3c760eb7438b13261e52ecfaa33a53649ced95f1ab40aae52134b8cdc31a16d7aa0d6a6dd716e268ed148e9d77a10b7c700b141b61d70c82d271ffe88e8e2a3c SHA512 9964538dc42f232a11949f74b61d46422ea5da3bdc253a217119bd0b8a750c40fd2da0b07157067be9ac0226472614f210a1248114df0d331df390979867a895
diff --git a/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.7.ebuild b/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.7.ebuild
new file mode 100644
index 000000000000..e4705ad05588
--- /dev/null
+++ b/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.7.ebuild
@@ -0,0 +1,284 @@
+# Copyright 2019-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit mount-boot savedconfig toolchain-funcs
+
+MY_P=linux-${PV}
+TCL_VER=10.1
+AMD64_CONFIG_VER=5.4.7.arch1-1
+AMD64_CONFIG_HASH=ff79453bc0451a9083bdaa02c3901372d61a9982
+I686_CONFIG_VER=5.4.3-arch1
+I686_CONFIG_HASH=076a52d43a08c4b3a3eacd1f2f9a855fb3b62f42
+
+DESCRIPTION="Linux kernel built from vanilla upstream sources"
+HOMEPAGE="https://www.kernel.org/"
+SRC_URI="https://cdn.kernel.org/pub/linux/kernel/v5.x/${MY_P}.tar.xz
+ amd64? (
+ https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux&id=${AMD64_CONFIG_HASH}
+ -> linux-${AMD64_CONFIG_VER}.amd64.config
+ test? (
+ https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-amd64.qcow2
+ )
+ )
+ x86? (
+ https://git.archlinux32.org/packages/plain/core/linux/config.i686?id=${I686_CONFIG_HASH}
+ -> linux-${I686_CONFIG_VER}.i686.config
+ test? (
+ https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-x86.qcow2
+ )
+ )"
+S=${WORKDIR}/${MY_P}
+
+LICENSE="GPL-2"
+SLOT="${PV}"
+KEYWORDS="~amd64 ~x86"
+IUSE="+initramfs test"
+RESTRICT="!test? ( test ) test? ( userpriv )"
+
+# install-DEPEND actually
+# note: we need installkernel with initramfs support!
+RDEPEND="
+ || (
+ sys-kernel/installkernel-gentoo
+ sys-kernel/installkernel-systemd-boot
+ )
+ initramfs? ( >=sys-kernel/dracut-049-r3 )"
+BDEPEND="
+ sys-devel/bc
+ virtual/libelf
+ test? (
+ dev-tcltk/expect
+ sys-kernel/dracut
+ amd64? ( app-emulation/qemu[qemu_softmmu_targets_x86_64] )
+ x86? ( app-emulation/qemu[qemu_softmmu_targets_i386] )
+ )"
+
+pkg_pretend() {
+ mount-boot_pkg_pretend
+
+ ewarn "This is an experimental package. The built kernel and/or initramfs"
+ ewarn "may not work at all or fail with your bootloader configuration. Please"
+ ewarn "make sure to keep a backup kernel available before testing it."
+}
+
+src_configure() {
+ # force ld.bfd if we can find it easily
+ local LD="$(tc-getLD)"
+ if type -P "${LD}.bfd" &>/dev/null; then
+ LD+=.bfd
+ fi
+
+ MAKEARGS=(
+ V=1
+
+ HOSTCC="$(tc-getCC)"
+ HOSTCXX="$(tc-getCXX)"
+ HOSTCFLAGS="${CFLAGS}"
+ HOSTLDFLAGS="${LDFLAGS}"
+
+ AS="$(tc-getAS)"
+ CC="$(tc-getCC)"
+ LD="${LD}"
+ AR="$(tc-getAR)"
+ NM="$(tc-getNM)"
+ STRIP=":"
+ OBJCOPY="$(tc-getOBJCOPY)"
+ OBJDUMP="$(tc-getOBJDUMP)"
+
+ # we need to pass it to override colliding Gentoo envvar
+ ARCH=x86
+ )
+
+ case ${ARCH} in
+ amd64)
+ cp "${DISTDIR}"/linux-${AMD64_CONFIG_VER}.amd64.config .config || die
+ ;;
+ x86)
+ cp "${DISTDIR}"/linux-${I686_CONFIG_VER}.i686.config .config || die
+ ;;
+ *)
+ die "Unsupported arch ${ARCH}"
+ ;;
+ esac
+
+ # while Arch config is cool, we don't want gcc plugins as they
+ # break distcc
+ sed -i -e '/GCC_PLUGIN/d' .config || die
+ # module compression prevents us from stripping them post-inst
+ sed -i -e '/MODULE_COMPRESS/d' .config || die
+ # shove our theft under the carpet!
+ sed -i -e '/HOSTNAME/s:archlinux:gentoo:' .config || die
+ # hey, we do support x32
+ sed -i -e '/CONFIG_X86_X32/s:.*:CONFIG_X86_X32=y:' .config || die
+ restore_config .config
+
+ mkdir -p "${WORKDIR}"/modprep || die
+ mv .config "${WORKDIR}"/modprep/ || die
+ emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" olddefconfig
+ emake O="${WORKDIR}"/modprep "${MAKEARGS[@]}" modules_prepare
+ cp -pR "${WORKDIR}"/modprep "${WORKDIR}"/build || die
+}
+
+src_compile() {
+ emake O="${WORKDIR}"/build "${MAKEARGS[@]}" all
+}
+
+get_kern_arch() {
+ echo x86
+}
+
+src_test() {
+ local image_arch=${ARCH}
+ local qemu_arch=$(usex amd64 x86_64 i386)
+
+ emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \
+ INSTALL_MOD_PATH="${T}" modules_install
+
+ dracut \
+ --conf /dev/null \
+ --confdir /dev/null \
+ --no-hostonly \
+ --kmoddir "${T}/lib/modules/${PV}" \
+ "${T}/initrd" "${PV}" || die
+ cp "${DISTDIR}/tinycorelinux-${TCL_VER}-${image_arch}.qcow2" \
+ "${T}/fs.qcow2" || die
+
+ cd "${T}" || die
+ cat > run.sh <<-EOF || die
+ #!/bin/sh
+ exec qemu-system-${qemu_arch} \
+ -m 256M \
+ -display none \
+ -no-reboot \
+ -kernel '${WORKDIR}/build/arch/$(get_kern_arch)/boot/bzImage' \
+ -initrd '${T}/initrd' \
+ -serial mon:stdio \
+ -hda '${T}/fs.qcow2' \
+ -append 'root=/dev/sda console=ttyS0,115200n8'
+ EOF
+ chmod +x run.sh || die
+ # TODO: initramfs does not let core finish starting on some systems,
+ # figure out how to make it better at that
+ expect - <<-EOF || die "Booting kernel failed"
+ set timeout 900
+ spawn ./run.sh
+ expect {
+ "Kernel panic" {
+ send_error "\n* Kernel panic"
+ exit 1
+ }
+ "Entering emergency mode" {
+ send_error "\n* Initramfs failed to start the system"
+ exit 1
+ }
+ "Core 10.1" {
+ send_error "\n* Booted to login"
+ exit 0
+ }
+ timeout {
+ send_error "\n* Kernel boot timed out"
+ exit 2
+ }
+ }
+ EOF
+}
+
+src_install() {
+ # do not use 'make install' as it behaves differently based
+ # on what kind of installkernel is installed
+ emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \
+ INSTALL_MOD_PATH="${ED}" modules_install
+
+ # note: we're using mv rather than doins to save space and time
+ # install main and arch-specific headers first, and scripts
+ local kern_arch=$(get_kern_arch)
+ dodir "/usr/src/linux-${PV}/arch/${kern_arch}"
+ mv include scripts "${ED}/usr/src/linux-${PV}/" || die
+ mv "arch/${kern_arch}/include" \
+ "${ED}/usr/src/linux-${PV}/arch/${kern_arch}/" || die
+
+ # remove everything but Makefile* and Kconfig*
+ find -type f '!' '(' -name 'Makefile*' -o -name 'Kconfig*' ')' \
+ -delete || die
+ find -type l -delete || die
+ cp -p -R * "${ED}/usr/src/linux-${PV}/" || die
+
+ cd "${WORKDIR}" || die
+ # strip out-of-source build stuffs from modprep
+ # and then copy built files as well
+ find modprep -type f '(' \
+ -name Makefile -o \
+ -name '*.[ao]' -o \
+ '(' -name '.*' -a -not -name '.config' ')' \
+ ')' -delete || die
+ rm modprep/source || die
+ cp -p -R modprep/. "${ED}/usr/src/linux-${PV}"/ || die
+
+ # install the kernel and files needed for module builds
+ cp build/{arch/x86/boot/bzImage,System.map,Module.symvers} \
+ "${ED}/usr/src/linux-${PV}"/ || die
+
+ # strip empty directories
+ find "${D}" -type d -empty -exec rmdir {} + || die
+
+ # fix source tree and build dir symlinks
+ dosym ../../../usr/src/linux-${PV} /lib/modules/${PV}/build
+ dosym ../../../usr/src/linux-${PV} /lib/modules/${PV}/source
+
+ save_config build/.config
+}
+
+pkg_preinst() {
+ :
+}
+
+pkg_postinst() {
+ if [[ -z ${ROOT} ]]; then
+ mount-boot_pkg_preinst
+
+ if use initramfs; then
+ ebegin "Building initramfs via dracut"
+ # putting it alongside kernel image as 'initrd' makes
+ # kernel-install happier
+ dracut --force "${EROOT}/usr/src/linux-${PV}/initrd" "${PV}"
+ eend ${?} || die "Building initramfs failed"
+ fi
+
+ ebegin "Installing the kernel via installkernel"
+ # note: .config is taken relatively to System.map;
+ # initrd relatively to bzImage
+ installkernel "${PV}" \
+ "${EROOT}/usr/src/linux-${PV}/bzImage" \
+ "${EROOT}/usr/src/linux-${PV}/System.map"
+ eend ${?} || die "Installing the kernel failed"
+ fi
+
+ local symlink_target=$(readlink "${EROOT}"/usr/src/linux)
+ local symlink_ver=${symlink_target#linux-}
+ if [[ ${symlink_target} == linux-* && -z ${symlink_ver//[0-9.]/} ]]
+ then
+ local symlink_pkg=${CATEGORY}/${PN}-${symlink_ver}
+ # if the current target is either being replaced, or still
+ # installed (probably depclean candidate), update the symlink
+ if has "${symlink_ver}" ${REPLACING_VERSIONS} ||
+ has_version -r "~${symlink_pkg}"
+ then
+ ebegin "Updating /usr/src/linux symlink"
+ ln -f -n -s linux-${PV} "${EROOT}"/usr/src/linux
+ eend ${?}
+ fi
+ fi
+
+ savedconfig_pkg_postinst
+}
+
+pkg_prerm() {
+ :
+}
+
+pkg_postrm() {
+ rm -f "${EROOT}/usr/src/linux-${PV}/initrd" &&
+ rmdir --ignore-fail-on-non-empty "${EROOT}/usr/src/linux-${PV}"
+}