123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- #!/usr/bin/env bash
- #
- # SPDX-License-Identifier: GPL-2.0
- #
- # Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
- #
- # This file is a part of the Armbian Build Framework
- # https://github.com/armbian/build/
- # This is a re-imagining of mkdebian and builddeb from the kernel tree.
- # We wanna produce Debian/Ubuntu compatible packages so we're able to use their standard tools, like
- # `flash-kernel`, `u-boot-menu`, `grub2`, and others, so we gotta stick to their conventions.
- # The main difference is that this is NOT invoked from KBUILD's Makefile, but instead
- # directly by Armbian, with references to the dirs where KBUILD's
- # `make install dtbs_install modules_install headers_install` have already successfully been run.
- # This will create a SET of packages. It should always create these:
- # image package: vmlinuz and such, config, modules, and dtbs (if exist) in /usr/lib/xxx
- # linux-headers package: "just" the kernel headers, for building out-of-tree modules, dkms, etc.
- # linux-dtbs package: only dtbs, if they exist. in /boot/
- # So this will handle
- # - Creating .deb package skeleton dir (mktemp)
- # - Moving/copying around of KBUILD installed stuff for Debian/Ubuntu/Armbian standard locations, in the correct packages
- # - Fixing the symlinks to stuff so they fit a target system.
- # - building the .debs.
- is_enabled() {
- grep -q "^$1=y" include/config/auto.conf
- }
- if_enabled_echo() {
- if is_enabled "$1"; then
- echo -n "$2"
- elif [ $# -ge 3 ]; then
- echo -n "$3"
- fi
- }
- function prepare_kernel_packaging_debs() {
- : "${artifact_version:?artifact_version is not set}"
- : "${kernel_debs_temp_dir:?kernel_debs_temp_dir is not set}"
- declare kernel_work_dir="${1}"
- declare kernel_dest_install_dir="${2}"
- declare kernel_version="${3}"
- declare -n tmp_kernel_install_dirs="${4}" # nameref to declare -n kernel_install_dirs dictionary
- declare debs_target_dir="${kernel_work_dir}/.."
- # Some variables and settings used throughout the script
- declare kernel_version_family="${kernel_version}-${LINUXFAMILY}"
- # Package version. Affects users upgrading from repo!
- display_alert "Kernel .deb package version" "${artifact_version}" "info"
- # show incoming tree
- #display_alert "Kernel install dir" "incoming from KBUILD make" "debug"
- #run_host_command_logged tree -C --du -h "${kernel_dest_install_dir}" "| grep --line-buffered -v -e '\.ko' -e '\.h' "
- # display_alert "tmp_kernel_install_dirs INSTALL_PATH:" "${tmp_kernel_install_dirs[INSTALL_PATH]}" "debug"
- # display_alert "tmp_kernel_install_dirs INSTALL_MOD_PATH:" "${tmp_kernel_install_dirs[INSTALL_MOD_PATH]}" "debug"
- # display_alert "tmp_kernel_install_dirs INSTALL_HDR_PATH:" "${tmp_kernel_install_dirs[INSTALL_HDR_PATH]}" "debug"
- # display_alert "tmp_kernel_install_dirs INSTALL_DTBS_PATH:" "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" "debug"
- # For armhf, kernel's "make install" gives us the wrong "vmlinuz-xx" file. We want the arch/arm/boot/zImage.
- if [[ "${ARCH}" == "armhf" ]]; then # @TODO: if you know a better way? some kbuild var? send PR.
- display_alert "armhf: using arch/arm/boot/zImage as vmlinuz" "armhf zImage" "info"
- run_host_command_logged ls -la "${kernel_work_dir}/arch/arm/boot/zImage" || true
- run_host_command_logged file "${kernel_work_dir}/arch/arm/boot/zImage" || true
- run_host_command_logged ls -la "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" || true
- run_host_command_logged file "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}" || true
- # Just overwrite it...
- run_host_command_logged cp -v "${kernel_work_dir}/arch/arm/boot/zImage" "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}"
- run_host_command_logged file "${tmp_kernel_install_dirs[INSTALL_PATH]}/vmlinuz-${kernel_version_family}"
- display_alert "armhf: using arch/arm/boot/zImage as vmlinuz" "done with armhf zImage" "debug"
- fi
- # package the linux-image (image, modules, dtbs (if present))
- display_alert "Packaging linux-image" "${LINUXFAMILY} ${LINUXCONFIG}" "info"
- create_kernel_deb "linux-image-${BRANCH}-${LINUXFAMILY}" "${debs_target_dir}" kernel_package_callback_linux_image
- # if dtbs present, package those too separately, for u-boot usage.
- if [[ -d "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" ]]; then
- display_alert "Packaging linux-dtb" "${LINUXFAMILY} ${LINUXCONFIG}" "info"
- create_kernel_deb "linux-dtb-${BRANCH}-${LINUXFAMILY}" "${debs_target_dir}" kernel_package_callback_linux_dtb
- fi
- if [[ "${KERNEL_HAS_WORKING_HEADERS}" == "yes" ]]; then
- display_alert "Packaging linux-headers" "${LINUXFAMILY} ${LINUXCONFIG}" "info"
- create_kernel_deb "linux-headers-${BRANCH}-${LINUXFAMILY}" "${debs_target_dir}" kernel_package_callback_linux_headers
- else
- display_alert "Skipping linux-headers package" "for ${KERNEL_MAJOR_MINOR} kernel version" "warn"
- fi
- }
- function create_kernel_deb() {
- : "${kernel_debs_temp_dir:?kernel_debs_temp_dir is not set}"
- declare package_name="${1}"
- declare deb_output_dir="${2}"
- declare callback_function="${3}"
- declare cleanup_id="" package_directory=""
- prepare_temp_dir_in_workdir_and_schedule_cleanup "deb-k-${package_name}" cleanup_id package_directory # namerefs
- declare package_DEBIAN_dir="${package_directory}/DEBIAN" # DEBIAN dir
- mkdir -p "${package_DEBIAN_dir}" # maintainer scripts et al
- # Generate copyright file
- mkdir -p "${package_directory}/usr/share/doc/${package_name}"
- cat <<- COPYRIGHT > "${package_directory}/usr/share/doc/${package_name}/copyright"
- This is a packaged Armbian patched version of the Linux kernel.
- The sources may be found at most Linux archive sites, including:
- https://www.kernel.org/pub/linux/kernel
- Copyright: 1991 - 2018 Linus Torvalds and others.
- The git repository for mainline kernel development is at:
- git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; version 2 dated June, 1991.
- On Debian GNU/Linux systems, the complete text of the GNU General Public
- License version 2 can be found in \`/usr/share/common-licenses/GPL-2'.
- COPYRIGHT
- # Run the callback.
- # display_alert "Running callback" "callback: ${callback_function}" "debug"
- "${callback_function}" "${@}"
- run_host_command_logged chown -R root:root "${package_directory}" # Fix ownership and permissions
- run_host_command_logged chmod -R go-w "${package_directory}" # Fix ownership and permissions
- run_host_command_logged chmod -R a+rX "${package_directory}" # in case we are in a restrictive umask environment like 0077
- run_host_command_logged chmod -R ug-s "${package_directory}" # in case we build in a setuid/setgid directory
- cd "${package_directory}" || exit_with_error "major failure 774 for ${package_name}"
- # create md5sums file
- # sh -c "cd '${package_directory}'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums"
- declare unpacked_size
- unpacked_size="$(du -h -s "${package_directory}" | awk '{print $1}')"
- display_alert "Unpacked ${package_name} tree" "${unpacked_size}" "debug"
- # Show it
- #display_alert "Package dir" "for package ${package_name}" "debug"
- #run_host_command_logged tree -C -h -d --du "${package_directory}"
- fakeroot_dpkg_deb_build "${package_directory}" "${kernel_debs_temp_dir}/"
- done_with_temp_dir "${cleanup_id}" # changes cwd to "${SRC}" and fires the cleanup function early
- }
- function kernel_package_hook_helper() {
- declare script="${1}"
- declare contents="${2}"
- cat >> "${package_DEBIAN_dir}/${script}" <<- EOT
- #!/bin/bash
- echo "Armbian '${package_name}' for '${kernel_version_family}': '${script}' starting."
- set -e # Error control
- set -x # Debugging
- $(cat "${contents}")
- set +x # Disable debugging
- echo "Armbian '${package_name}' for '${kernel_version_family}': '${script}' finishing."
- true
- EOT
- chmod 775 "${package_DEBIAN_dir}/${script}"
- # produce log asset for script
- LOG_ASSET="deb-${package_name}-${script}.sh" do_with_log_asset run_host_command_logged cat "${package_DEBIAN_dir}/${script}"
- }
- function kernel_package_callback_linux_image() {
- display_alert "linux-image deb packaging" "${package_directory}" "debug"
- declare installed_image_path="boot/vmlinuz-${kernel_version_family}" # using old mkdebian terminology here.
- declare image_name="Image" # "Image" for arm64. or, "zImage" for arm, or "vmlinuz" for others.
- # If NAME_KERNEL is set (usually in arch config file), warn and use that instead.
- if [[ -n "${NAME_KERNEL}" ]]; then
- display_alert "NAME_KERNEL is set" "using '${NAME_KERNEL}' instead of '${image_name}'" "debug"
- image_name="${NAME_KERNEL}"
- else
- display_alert "NAME_KERNEL is not set" "using default '${image_name}'" "debug"
- fi
- display_alert "Showing contents of Kbuild produced /boot" "linux-image" "debug"
- run_host_command_logged tree -C --du -h "${tmp_kernel_install_dirs[INSTALL_PATH]}"
- run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_PATH]}" "${package_directory}/" # /boot stuff
- run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_MOD_PATH]}/lib" "${package_directory}/" # so "lib" stuff sits at the root
- # Clean up symlinks in lib/modules/${kernel_version_family}/build and lib/modules/${kernel_version_family}/source; will be in the headers package
- run_host_command_logged rm -v -f "${package_directory}/lib/modules/${kernel_version_family}/build" "${package_directory}/lib/modules/${kernel_version_family}/source"
- display_alert "Showing contents of Kbuild produced modules" "linux-image" "debug"
- run_host_command_logged tree -C --du -h -d -L 1 "${package_directory}/lib/modules/${kernel_version_family}/kernel" "|| true" # do not fail
- if [[ -d "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" ]]; then
- # /usr/lib/linux-image-${kernel_version_family} is wanted by flash-kernel, u-boot-menu, and other standard Debian/Ubuntu utilities
- display_alert "DTBs present on kernel output" "DTBs ${package_name}: /usr/lib/linux-image-${kernel_version_family}" "debug"
- mkdir -p "${package_directory}/usr/lib"
- run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" "${package_directory}/usr/lib/linux-image-${kernel_version_family}"
- fi
- # Generate a control file
- cat <<- CONTROL_FILE > "${package_DEBIAN_dir}/control"
- Package: ${package_name}
- Version: ${artifact_version}
- Source: linux-${kernel_version}
- Architecture: ${ARCH}
- Maintainer: ${MAINTAINER} <${MAINTAINERMAIL}>
- Section: kernel
- Provides: linux-image, linux-image-armbian, armbian-$BRANCH
- Description: Armbian Linux $BRANCH kernel image ${artifact_version_reason:-"${kernel_version_family}"}
- This package contains the Linux kernel, modules and corresponding other
- files, kernel_version_family: $kernel_version_family.
- CONTROL_FILE
- # Install the maintainer scripts
- # Note: hook scripts under /etc/kernel are also executed by official Debian
- # kernel packages, as well as kernel packages built using make-kpkg.
- # make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and
- # so do we; recent versions of dracut and initramfs-tools will obey this.
- declare debian_kernel_hook_dir="/etc/kernel"
- for script in "postinst" "postrm" "preinst" "prerm"; do
- mkdir -p "${package_directory}${debian_kernel_hook_dir}/${script}.d" # create kernel hook dir, make sure.
- kernel_package_hook_helper "${script}" <(
- cat <<- KERNEL_HOOK_DELEGATION
- export DEB_MAINT_PARAMS="\$*" # Pass maintainer script parameters to hook scripts
- export INITRD=$(if_enabled_echo CONFIG_BLK_DEV_INITRD Yes No) # Tell initramfs builder whether it's wanted
- # Run the same hooks Debian/Ubuntu would for their kernel packages.
- test -d ${debian_kernel_hook_dir}/${script}.d && run-parts --arg="${kernel_version_family}" --arg="/${installed_image_path}" ${debian_kernel_hook_dir}/${script}.d
- KERNEL_HOOK_DELEGATION
- if [[ "${script}" == "preinst" ]]; then
- cat <<- HOOK_FOR_REMOVE_VFAT_BOOT_FILES
- check_boot_dev (){
- boot_partition=\$(findmnt -n -o SOURCE /boot)
- bootfstype=\$(blkid -s TYPE -o value \$boot_partition)
- if [ "\$bootfstype" = "vfat" ]; then
- rm -f /boot/System.map* /boot/config* /boot/vmlinuz* /boot/$image_name /boot/uImage
- fi
- }
- mountpoint -q /boot && check_boot_dev
- HOOK_FOR_REMOVE_VFAT_BOOT_FILES
- fi
- # @TODO: only if u-boot, only for postinst. Gotta find a hook scheme for these...
- if [[ "${script}" == "postinst" ]]; then
- cat <<- HOOK_FOR_LINK_TO_LAST_INSTALLED_KERNEL
- echo "Armbian: update last-installed kernel symlink to '$image_name'..."
- ln -sfv $(basename "${installed_image_path}") /boot/$image_name || mv -v /${installed_image_path} /boot/${image_name}
- touch /boot/.next
- HOOK_FOR_LINK_TO_LAST_INSTALLED_KERNEL
- fi
- )
- done
- }
- function kernel_package_callback_linux_dtb() {
- display_alert "linux-dtb packaging" "${package_directory}" "debug"
- display_alert "Showing tree of Kbuild produced DTBs" "linux-dtb" "debug"
- run_host_command_logged tree -C --du -h -L 2 "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}"
- mkdir -p "${package_directory}/boot/"
- run_host_command_logged cp -rp "${tmp_kernel_install_dirs[INSTALL_DTBS_PATH]}" "${package_directory}/boot/dtb-${kernel_version_family}"
- # Generate a control file
- cat <<- CONTROL_FILE > "${package_DEBIAN_dir}/control"
- Version: ${artifact_version}
- Maintainer: ${MAINTAINER} <${MAINTAINERMAIL}>
- Section: kernel
- Package: ${package_name}
- Architecture: ${ARCH}
- Provides: linux-dtb, linux-dtb-armbian, armbian-$BRANCH
- Description: Armbian Linux $BRANCH DTBs ${artifact_version_reason:-"${kernel_version_family}"}
- This package contains device blobs from the Linux kernel, version ${kernel_version_family}
- CONTROL_FILE
- kernel_package_hook_helper "preinst" <(
- cat <<- EOT
- rm -rf /boot/dtb
- rm -rf /boot/dtb-${kernel_version_family}
- EOT
- )
- kernel_package_hook_helper "postinst" <(
- cat <<- EOT
- cd /boot
- ln -sfT dtb-${kernel_version_family} dtb || mv dtb-${kernel_version_family} dtb
- EOT
- )
- }
- function kernel_package_callback_linux_headers() {
- display_alert "linux-headers packaging" "${package_directory}" "debug"
- # targets.
- local headers_target_dir="${package_directory}/usr/src/linux-headers-${kernel_version_family}" # headers/tools etc
- local modules_target_dir="${package_directory}/lib/modules/${kernel_version_family}" # symlink to above later
- mkdir -p "${headers_target_dir}" "${modules_target_dir}" # create both dirs
- run_host_command_logged ln -v -s "/usr/src/linux-headers-${kernel_version_family}" "${modules_target_dir}/build" # Symlink in modules so builds find the headers
- run_host_command_logged cp -vp "${kernel_work_dir}"/.config "${headers_target_dir}"/.config # copy .config manually to be where it's expected to be
- # gather stuff from the linux source tree: ${kernel_work_dir} (NOT the make install destination)
- # those can be source files or object (binary/compiled) stuff
- # how to get SRCARCH? only from the makefile itself. ARCH=amd64 then SRCARCH=x86. How to we know? @TODO
- local SRC_ARCH="${ARCH}"
- [[ "${SRC_ARCH}" == "amd64" ]] && SRC_ARCH="x86"
- [[ "${SRC_ARCH}" == "armhf" ]] && SRC_ARCH="arm"
- [[ "${SRC_ARCH}" == "riscv64" ]] && SRC_ARCH="riscv"
- # @TODO: added KERNEL_SRC_ARCH to each arch'es .config file; let's make sure they're sane. Just use KERNEL_SRC_ARCH after confirmed.
- # Lets check and warn if it isn't. If warns don't popup over time we remove and just use ARCHITECTURE later.
- if [[ "${SRC_ARCH}" != "${KERNEL_SRC_ARCH}" ]]; then
- display_alert "WARNING: KERNEL_SRC_ARCH and SRC_ARCH don't match during kernel build." "KERNEL_SRC_ARCH=${ARCHITECTURE} SRC_ARCH=${SRC_ARCH}" "wrn"
- fi
- # Create a list of files to include, path-relative to the kernel tree
- local temp_file_list="${WORKDIR}/tmp_file_list_${kernel_version_family}.kernel.headers"
- # Find the files we want to include in the package. Those will be later cleaned, etc.
- (
- cd "${kernel_work_dir}" || exit 2
- find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl
- find arch/*/include include scripts -type f -o -type l
- find security/*/include -type f
- [[ -d "arch/${SRC_ARCH}" ]] && {
- find "arch/${SRC_ARCH}" -name module.lds -o -name Kbuild.platforms -o -name Platform
- # shellcheck disable=SC2046 # I need to expand. Thanks.
- find $(find "arch/${SRC_ARCH}" -name include -o -name scripts -type d) -type f
- find arch/${SRC_ARCH}/include -type f
- }
- find Module.symvers include scripts -type f
- find . -name "bitsperlong.h" -type f
- # tools/include/tools has the byteshift utilities shared between kernel proper and the build scripts/tools.
- # This replaces 'headers-debian-byteshift.patch' which was used for years in Armbian.
- find tools -type f # all tools; will trim a bit later
- find arch/x86/lib/insn.c # required by objtool stuff...
- if is_enabled CONFIG_GCC_PLUGINS; then
- find scripts/gcc-plugins -name gcc-common.h # @TODO something else here too?
- fi
- ) > "${temp_file_list}"
- # Now include/copy those, using tar as intermediary. Just like builddeb does it.
- tar -c -f - -C "${kernel_work_dir}" -T "${temp_file_list}" | tar -xf - -C "${headers_target_dir}"
- # ${temp_file_list} is left at WORKDIR for later debugging, will be removed by WORKDIR cleanup trap
- # Now, make the script dirs clean.
- # This is run in our _target_ dir, NOT the source tree, so we're free to make clean as we wish without invalidating the next build's cache.
- # Understand: I'm sending the logs of this to the bitbucket ON PURPOSE: "clean" tries to use clang, ALSA, etc, which are not available.
- # The logs produced during this step throw off developers casually looking at the logs.
- # Important: if the steps _fail_ here, you'll have to enable DEBUG=yes to see what's going on.
- declare make_bitbucket="&> /dev/null"
- [[ "${DEBUG}" == "yes" ]] && make_bitbucket=""
- run_host_command_logged cd "${headers_target_dir}" "&&" make -s "ARCH=${SRC_ARCH}" "M=scripts" clean "${make_bitbucket}"
- run_host_command_logged cd "${headers_target_dir}/tools" "&&" make -s "ARCH=${SRC_ARCH}" clean "${make_bitbucket}"
- # Trim down on the tools dir a bit after cleaning.
- rm -rf "${headers_target_dir}/tools/perf" "${headers_target_dir}/tools/testing"
- # Hack: after cleaning, copy over the scripts/module.lds file from the source tree. It will only exist on 5.10+
- # See https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1906131
- [[ -f "${kernel_work_dir}/scripts/module.lds" ]] &&
- run_host_command_logged cp -v "${kernel_work_dir}/scripts/module.lds" "${headers_target_dir}/scripts/module.lds"
- if [[ "${DEBUG}" == "yes" ]]; then
- # Check that no binaries are included by now. Expensive... @TODO: remove after me make sure.
- display_alert "Checking for binaries in kernel headers" "${headers_target_dir}" "debug"
- (
- cd "${headers_target_dir}" || exit 33
- find . -type f | grep -v -e "include/config/" -e "\.h$" -e ".c$" -e "Makefile$" -e "Kconfig$" -e "Kbuild$" -e "\.cocci$" | xargs file | grep -v -e "ASCII" -e "script text" -e "empty" -e "Unicode text" -e "symbolic link" -e "CSV text" -e "SAS 7+" || true
- )
- fi
- # Generate a control file
- # TODO: libssl-dev is only required if we're signing modules, which is a kernel .config option.
- cat <<- CONTROL_FILE > "${package_DEBIAN_dir}/control"
- Version: ${artifact_version}
- Maintainer: ${MAINTAINER} <${MAINTAINERMAIL}>
- Section: devel
- Package: ${package_name}
- Architecture: ${ARCH}
- Provides: linux-headers, linux-headers-armbian, armbian-$BRANCH
- Depends: make, gcc, libc6-dev, bison, flex, libssl-dev, libelf-dev
- Description: Armbian Linux $BRANCH headers ${artifact_version_reason:-"${kernel_version_family}"}
- This package provides kernel header files for ${kernel_version_family}
- .
- This is useful for DKMS and building of external modules.
- CONTROL_FILE
- # Make sure the target dir is clean/not-existing before installing.
- kernel_package_hook_helper "preinst" <(
- cat <<- EOT_PREINST
- if [[ -d "/usr/src/linux-headers-${kernel_version_family}" ]]; then
- echo "Cleaning pre-existing directory /usr/src/linux-headers-${kernel_version_family} ..."
- rm -rf "/usr/src/linux-headers-${kernel_version_family}"
- fi
- EOT_PREINST
- )
- # Make sure the target dir is removed before removing the package; that way we don't leave eventual compilation artifacts over there.
- kernel_package_hook_helper "prerm" <(
- cat <<- EOT_PRERM
- if [[ -d "/usr/src/linux-headers-${kernel_version_family}" ]]; then
- echo "Cleaning directory /usr/src/linux-headers-${kernel_version_family} ..."
- rm -rf "/usr/src/linux-headers-${kernel_version_family}"
- fi
- EOT_PRERM
- )
- kernel_package_hook_helper "postinst" <(
- cat <<- EOT_POSTINST
- cd "/usr/src/linux-headers-${kernel_version_family}"
- NCPU=\$(grep -c 'processor' /proc/cpuinfo)
- echo "Compiling kernel-headers tools (${kernel_version_family}) using \$NCPU CPUs - please wait ..."
- yes "" | make ARCH="${SRC_ARCH}" oldconfig
- make ARCH="${SRC_ARCH}" -j\$NCPU scripts
- make ARCH="${SRC_ARCH}" -j\$NCPU M=scripts/mod/
- # make ARCH="${SRC_ARCH}" -j\$NCPU modules_prepare # depends on too much other stuff.
- make ARCH="${SRC_ARCH}" -j\$NCPU tools/objtool
- echo "Done compiling kernel-headers tools (${kernel_version_family})."
- EOT_POSTINST
- )
- }
|