1 # SPDX-License-Identifier: GPL-2.0-only 1 # SPDX-License-Identifier: GPL-2.0-only 2 # Maintainer: Thomas Weißschuh <linux@weisssch 2 # Maintainer: Thomas Weißschuh <linux@weissschuh.net> 3 # Contributor: Jan Alexander Steffens (heftig)< 3 # Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org> 4 4 5 pkgbase=${PACMAN_PKGBASE:-linux-upstream} 5 pkgbase=${PACMAN_PKGBASE:-linux-upstream} 6 pkgname=("${pkgbase}" "${pkgbase}-api-headers" 6 pkgname=("${pkgbase}" "${pkgbase}-api-headers") 7 if grep -q CONFIG_MODULES=y include/config/aut 7 if grep -q CONFIG_MODULES=y include/config/auto.conf; then 8 pkgname+=("${pkgbase}-headers") 8 pkgname+=("${pkgbase}-headers") 9 fi 9 fi 10 pkgver="${KERNELRELEASE//-/_}" 10 pkgver="${KERNELRELEASE//-/_}" 11 # The PKGBUILD is evaluated multiple times. 11 # The PKGBUILD is evaluated multiple times. 12 # Running scripts/build-version from here woul 12 # Running scripts/build-version from here would introduce inconsistencies. 13 pkgrel="${KBUILD_REVISION}" 13 pkgrel="${KBUILD_REVISION}" 14 pkgdesc='Upstream Linux' 14 pkgdesc='Upstream Linux' 15 url='https://www.kernel.org/' 15 url='https://www.kernel.org/' 16 # Enable flexible cross-compilation 16 # Enable flexible cross-compilation 17 arch=(${CARCH}) 17 arch=(${CARCH}) 18 license=(GPL-2.0-only) 18 license=(GPL-2.0-only) 19 makedepends=( 19 makedepends=( 20 bc 20 bc 21 bison 21 bison 22 cpio 22 cpio 23 flex 23 flex 24 gettext 24 gettext 25 kmod 25 kmod 26 libelf 26 libelf 27 openssl 27 openssl 28 pahole 28 pahole 29 perl 29 perl 30 python 30 python 31 rsync 31 rsync 32 tar 32 tar 33 ) 33 ) 34 options=(!debug !strip !buildflags !makeflags) 34 options=(!debug !strip !buildflags !makeflags) 35 35 36 build() { 36 build() { 37 # MAKEFLAGS from makepkg.conf override 37 # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. 38 # Bypass this override with a custom v 38 # Bypass this override with a custom variable. 39 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 39 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 40 cd "${objtree}" 40 cd "${objtree}" 41 41 42 ${MAKE} KERNELRELEASE="${KERNELRELEASE 42 ${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}" 43 } 43 } 44 44 45 _package() { 45 _package() { 46 pkgdesc="The ${pkgdesc} kernel and mod 46 pkgdesc="The ${pkgdesc} kernel and modules" 47 47 48 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 48 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 49 cd "${objtree}" 49 cd "${objtree}" 50 local modulesdir="${pkgdir}/usr/${MODL 50 local modulesdir="${pkgdir}/usr/${MODLIB}" 51 51 52 echo "Installing boot image..." 52 echo "Installing boot image..." 53 # systemd expects to find the kernel h 53 # systemd expects to find the kernel here to allow hibernation 54 # https://github.com/systemd/systemd/c 54 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 55 install -Dm644 "$(${MAKE} -s image_nam 55 install -Dm644 "$(${MAKE} -s image_name)" "${modulesdir}/vmlinuz" 56 56 57 # Used by mkinitcpio to name the kerne 57 # Used by mkinitcpio to name the kernel 58 echo "${pkgbase}" > "${modulesdir}/pkg 58 echo "${pkgbase}" > "${modulesdir}/pkgbase" 59 59 60 echo "Installing modules..." 60 echo "Installing modules..." 61 ${MAKE} INSTALL_MOD_PATH="${pkgdir}/us 61 ${MAKE} INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 \ 62 DEPMOD=true modules_install 62 DEPMOD=true modules_install 63 63 64 if [ -d "${srctree}/arch/${SRCARCH}/bo 64 if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then 65 echo "Installing dtbs..." 65 echo "Installing dtbs..." 66 ${MAKE} INSTALL_DTBS_PATH="${m 66 ${MAKE} INSTALL_DTBS_PATH="${modulesdir}/dtb" dtbs_install 67 fi 67 fi 68 68 69 # remove build link, will be part of - 69 # remove build link, will be part of -headers package 70 rm -f "${modulesdir}/build" 70 rm -f "${modulesdir}/build" 71 } 71 } 72 72 73 _package-headers() { 73 _package-headers() { 74 pkgdesc="Headers and scripts for build 74 pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel" 75 75 76 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 76 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 77 cd "${objtree}" 77 cd "${objtree}" 78 local builddir="${pkgdir}/usr/${MODLIB 78 local builddir="${pkgdir}/usr/${MODLIB}/build" 79 79 80 echo "Installing build files..." 80 echo "Installing build files..." 81 "${srctree}/scripts/package/install-ex 81 "${srctree}/scripts/package/install-extmod-build" "${builddir}" 82 82 83 echo "Installing System.map and config 83 echo "Installing System.map and config..." 84 cp System.map "${builddir}/System.map" 84 cp System.map "${builddir}/System.map" 85 cp .config "${builddir}/.config" 85 cp .config "${builddir}/.config" 86 86 87 echo "Adding symlink..." 87 echo "Adding symlink..." 88 mkdir -p "${pkgdir}/usr/src" 88 mkdir -p "${pkgdir}/usr/src" 89 ln -sr "${builddir}" "${pkgdir}/usr/sr 89 ln -sr "${builddir}" "${pkgdir}/usr/src/${pkgbase}" 90 } 90 } 91 91 92 _package-api-headers() { 92 _package-api-headers() { 93 pkgdesc="Kernel headers sanitized for 93 pkgdesc="Kernel headers sanitized for use in userspace" 94 provides=(linux-api-headers) 94 provides=(linux-api-headers) 95 conflicts=(linux-api-headers) 95 conflicts=(linux-api-headers) 96 96 97 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 97 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 98 cd "${objtree}" 98 cd "${objtree}" 99 99 100 ${MAKE} headers_install INSTALL_HDR_PA 100 ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr" 101 } 101 } 102 102 103 for _p in "${pkgname[@]}"; do 103 for _p in "${pkgname[@]}"; do 104 eval "package_$_p() { 104 eval "package_$_p() { 105 $(declare -f "_package${_p#$pk 105 $(declare -f "_package${_p#$pkgbase}") 106 _package${_p#$pkgbase} 106 _package${_p#$pkgbase} 107 }" 107 }" 108 done 108 done
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.