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}") 6 pkgname=("${pkgbase}") 7 7 8 _extrapackages=${PACMAN_EXTRAPACKAGES-headers 8 _extrapackages=${PACMAN_EXTRAPACKAGES-headers api-headers debug} 9 for pkg in $_extrapackages; do 9 for pkg in $_extrapackages; do 10 pkgname+=("${pkgbase}-${pkg}") 10 pkgname+=("${pkgbase}-${pkg}") 11 done 11 done 12 12 13 pkgver="${KERNELRELEASE//-/_}" 13 pkgver="${KERNELRELEASE//-/_}" 14 # The PKGBUILD is evaluated multiple times. 14 # The PKGBUILD is evaluated multiple times. 15 # Running scripts/build-version from here woul 15 # Running scripts/build-version from here would introduce inconsistencies. 16 pkgrel="${KBUILD_REVISION}" 16 pkgrel="${KBUILD_REVISION}" 17 pkgdesc='Upstream Linux' 17 pkgdesc='Upstream Linux' 18 url='https://www.kernel.org/' 18 url='https://www.kernel.org/' 19 # Enable flexible cross-compilation 19 # Enable flexible cross-compilation 20 arch=(${CARCH}) 20 arch=(${CARCH}) 21 license=(GPL-2.0-only) 21 license=(GPL-2.0-only) 22 makedepends=( 22 makedepends=( 23 bc 23 bc 24 bison 24 bison 25 cpio 25 cpio 26 flex 26 flex 27 gettext 27 gettext 28 kmod 28 kmod 29 libelf 29 libelf 30 openssl 30 openssl 31 pahole 31 pahole 32 perl 32 perl 33 python 33 python 34 rsync 34 rsync 35 tar 35 tar 36 ) 36 ) 37 options=(!debug !strip !buildflags !makeflags) 37 options=(!debug !strip !buildflags !makeflags) 38 38 39 _prologue() { 39 _prologue() { 40 # MAKEFLAGS from makepkg.conf override 40 # MAKEFLAGS from makepkg.conf override the ones inherited from kbuild. 41 # Bypass this override with a custom v 41 # Bypass this override with a custom variable. 42 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 42 export MAKEFLAGS="${KBUILD_MAKEFLAGS}" 43 43 44 # Kbuild works in the output directory 44 # Kbuild works in the output directory, where this PKGBUILD is located. 45 cd "$(dirname "${BASH_SOURCE[0]}")" 45 cd "$(dirname "${BASH_SOURCE[0]}")" 46 } 46 } 47 47 48 build() { 48 build() { 49 _prologue 49 _prologue 50 50 51 ${MAKE} KERNELRELEASE="${KERNELRELEASE 51 ${MAKE} KERNELRELEASE="${KERNELRELEASE}" KBUILD_BUILD_VERSION="${pkgrel}" 52 } 52 } 53 53 54 _package() { 54 _package() { 55 pkgdesc="The ${pkgdesc} kernel and mod 55 pkgdesc="The ${pkgdesc} kernel and modules" 56 56 57 local modulesdir="${pkgdir}/usr/${MODL 57 local modulesdir="${pkgdir}/usr/${MODLIB}" 58 58 59 _prologue 59 _prologue 60 60 61 echo "Installing boot image..." 61 echo "Installing boot image..." 62 # systemd expects to find the kernel h 62 # systemd expects to find the kernel here to allow hibernation 63 # https://github.com/systemd/systemd/c 63 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 64 install -Dm644 "$(${MAKE} -s image_nam 64 install -Dm644 "$(${MAKE} -s image_name)" "${modulesdir}/vmlinuz" 65 65 66 # Used by mkinitcpio to name the kerne 66 # Used by mkinitcpio to name the kernel 67 echo "${pkgbase}" > "${modulesdir}/pkg 67 echo "${pkgbase}" > "${modulesdir}/pkgbase" 68 68 69 echo "Installing modules..." 69 echo "Installing modules..." 70 ${MAKE} INSTALL_MOD_PATH="${pkgdir}/us 70 ${MAKE} INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 \ 71 DEPMOD=true modules_install 71 DEPMOD=true modules_install 72 72 73 if [ -d "${srctree}/arch/${SRCARCH}/bo 73 if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then 74 echo "Installing dtbs..." 74 echo "Installing dtbs..." 75 ${MAKE} INSTALL_DTBS_PATH="${m 75 ${MAKE} INSTALL_DTBS_PATH="${modulesdir}/dtb" dtbs_install 76 fi 76 fi 77 77 78 # remove build link, will be part of - 78 # remove build link, will be part of -headers package 79 rm -f "${modulesdir}/build" 79 rm -f "${modulesdir}/build" 80 } 80 } 81 81 82 _package-headers() { 82 _package-headers() { 83 pkgdesc="Headers and scripts for build 83 pkgdesc="Headers and scripts for building modules for the ${pkgdesc} kernel" 84 84 85 local builddir="${pkgdir}/usr/${MODLIB 85 local builddir="${pkgdir}/usr/${MODLIB}/build" 86 86 87 _prologue 87 _prologue 88 88 89 if grep -q CONFIG_MODULES=y include/co 89 if grep -q CONFIG_MODULES=y include/config/auto.conf; then 90 echo "Installing build files.. 90 echo "Installing build files..." 91 "${srctree}/scripts/package/in 91 "${srctree}/scripts/package/install-extmod-build" "${builddir}" 92 fi 92 fi 93 93 94 echo "Installing System.map and config 94 echo "Installing System.map and config..." 95 mkdir -p "${builddir}" 95 mkdir -p "${builddir}" 96 cp System.map "${builddir}/System.map" 96 cp System.map "${builddir}/System.map" 97 cp .config "${builddir}/.config" 97 cp .config "${builddir}/.config" 98 98 99 echo "Adding symlink..." 99 echo "Adding symlink..." 100 mkdir -p "${pkgdir}/usr/src" 100 mkdir -p "${pkgdir}/usr/src" 101 ln -sr "${builddir}" "${pkgdir}/usr/sr 101 ln -sr "${builddir}" "${pkgdir}/usr/src/${pkgbase}" 102 } 102 } 103 103 104 _package-api-headers() { 104 _package-api-headers() { 105 pkgdesc="Kernel headers sanitized for 105 pkgdesc="Kernel headers sanitized for use in userspace" 106 provides=(linux-api-headers) 106 provides=(linux-api-headers) 107 conflicts=(linux-api-headers) 107 conflicts=(linux-api-headers) 108 108 109 _prologue 109 _prologue 110 110 111 ${MAKE} headers_install INSTALL_HDR_PA 111 ${MAKE} headers_install INSTALL_HDR_PATH="${pkgdir}/usr" 112 } 112 } 113 113 114 _package-debug(){ 114 _package-debug(){ 115 pkgdesc="Non-stripped vmlinux file for 115 pkgdesc="Non-stripped vmlinux file for the ${pkgdesc} kernel" 116 116 117 local debugdir="${pkgdir}/usr/src/debu 117 local debugdir="${pkgdir}/usr/src/debug/${pkgbase}" 118 local builddir="${pkgdir}/usr/${MODLIB 118 local builddir="${pkgdir}/usr/${MODLIB}/build" 119 119 120 _prologue 120 _prologue 121 121 122 install -Dt "${debugdir}" -m644 vmlinu 122 install -Dt "${debugdir}" -m644 vmlinux 123 mkdir -p "${builddir}" 123 mkdir -p "${builddir}" 124 ln -sr "${debugdir}/vmlinux" "${buildd 124 ln -sr "${debugdir}/vmlinux" "${builddir}/vmlinux" 125 } 125 } 126 126 127 for _p in "${pkgname[@]}"; do 127 for _p in "${pkgname[@]}"; do 128 eval "package_$_p() { 128 eval "package_$_p() { 129 $(declare -f "_package${_p#$pk 129 $(declare -f "_package${_p#$pkgbase}") 130 _package${_p#$pkgbase} 130 _package${_p#$pkgbase} 131 }" 131 }" 132 done 132 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.