2 # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
3 # Maintainer: Thomas Baechler <thomas@archlinux.org>
5 pkgbase=linux # Build stock -ARCH kernel
6 #pkgbase=linux-custom # Build kernel with a different name
10 arch=('i686' 'x86_64')
11 url="https://www.kernel.org/"
13 makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf')
15 source=("https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.xz"
16 "https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.sign"
17 "https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.xz"
18 "https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.sign"
19 # the main kernel config files
20 'config.i686' 'config.x86_64'
21 # pacman hook for initramfs regeneration
23 # standard config files for mkinitcpio ramdisk
26 sha256sums=('2db3d6066c3ad93eb25b973a3d2951e022a7e975ee2fa7cbe5bddf84d9a49a2c'
28 'f5fb017ee531dc35e3462ccb2d244d4fdc8ac6df9cd3337aa6df2ffc280b1bd6'
30 '9b1d9fcb55782e6149aca4dc2d3b250dd4cedf1bf4bd8c6f0968acab0e2e0ee4'
31 '9c6c4d27d59638d0569ea09a97138bfcfb219f17cdf1138be141380e6654f302'
32 '834bd254b56ab71d73f59b3221f056c72f559553c04718e350ab2a3e2991afe0'
33 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65')
35 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
36 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
39 _kernelname=${pkgbase#linux}
45 patch -p1 -i ../patch-${pkgver}
49 # add latest fixes from stable queue, if needed
50 # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
52 cp -Tf ../config.${CARCH} .config
54 if [ "${_kernelname}" != "" ]; then
55 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
56 sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
59 # set extraversion to pkgrel
60 sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
62 # don't run depmod on 'make install'. We'll do this ourselves in packaging
63 sed -i '2iexit 0' scripts/depmod.sh
69 # Configure the kernel. Replace the line below with one of your choice.
70 #make menuconfig # CLI menu for configuration
71 #make nconfig # new CLI menu for configuration
72 #make xconfig # X-based configuration
73 #make oldconfig # using old config from previous kernel version
74 # ... or manually edit .config
76 # rewrite configuration
77 yes "" | make config >/dev/null
83 make ${MAKEFLAGS} LOCALVERSION= bzImage modules
87 pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
88 [ "${pkgbase}" = "linux" ] && groups=('base')
89 depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
90 optdepends=('crda: to set the correct wireless channels of your country')
91 backup=("etc/mkinitcpio.d/${pkgbase}.preset")
99 _kernver="$(make LOCALVERSION= kernelrelease)"
100 _basekernel=${_kernver%%-*}
101 _basekernel=${_basekernel%.*}
103 mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
104 make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
105 cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
107 # set correct depmod command for install
108 sed -e "s|%PKGBASE%|${pkgbase}|g;s|%KERNVER%|${_kernver}|g" \
109 "${startdir}/${install}" > "${startdir}/${install}.pkg"
110 true && install=${install}.pkg
112 # install mkinitcpio preset file for kernel
113 sed "s|%PKGBASE%|${pkgbase}|g" ../linux.preset |
114 install -Dm644 /dev/stdin "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
116 # install pacman hook for initramfs regeneration
117 sed "s|%PKGBASE%|${pkgbase}|g" ../90-linux.hook |
118 install -Dm644 /dev/stdin "${pkgdir}/usr/share/libalpm/hooks/90-${pkgbase}.hook"
120 # remove build and source links
121 rm "${pkgdir}"/lib/modules/${_kernver}/{source,build}
123 # remove the firmware
124 rm -r "${pkgdir}/lib/firmware"
126 # make room for external modules
127 ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
129 # add real version for building modules and running depmod from post_install/upgrade
131 install -Dm644 /dev/stdin "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
133 # Now we call depmod...
134 depmod -b "${pkgdir}" -F System.map "${_kernver}"
136 # move module tree /lib -> /usr/lib
137 mv -t "${pkgdir}/usr" "${pkgdir}/lib"
140 install -Dm644 vmlinux "${pkgdir}/usr/lib/modules/${_kernver}/build/vmlinux"
144 pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
147 local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
149 install -Dt "${_builddir}" -m644 Makefile .config Module.symvers
150 install -Dt "${_builddir}/kernel" -m644 kernel/Makefile
152 mkdir "${_builddir}/.tmp_versions"
154 cp -t "${_builddir}" -a include scripts
156 install -Dt "${_builddir}/arch/${KARCH}" -m644 arch/${KARCH}/Makefile
157 install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 arch/${KARCH}/kernel/asm-offsets.s
159 if [[ ${CARCH} = i686 ]]; then
160 install -t "${_builddir}/arch/${KARCH}" -m644 arch/${KARCH}/Makefile_32.cpu
163 cp -t "${_builddir}/arch/${KARCH}" -a arch/${KARCH}/include
165 install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h
166 install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h
168 # http://bugs.archlinux.org/task/9912
169 install -Dt "${_builddir}/drivers/media/dvb-core" -m644 drivers/media/dvb-core/*.h
171 # http://bugs.archlinux.org/task/13146
172 install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/lgdt330x.h
173 install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
175 # http://bugs.archlinux.org/task/20402
176 install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
177 install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
178 install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h
180 # add xfs and shmem for aufs building
181 mkdir -p "${_builddir}"/{fs/xfs,mm}
183 # copy in Kconfig files
184 find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \;
186 # add objtool for external module building and enabled VALIDATION_STACK option
187 if [[ -e tools/objtool/objtool ]]; then
188 install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool
191 # remove unneeded architectures
193 for _arch in "${_builddir}"/arch/*/; do
194 if [[ ${_arch} != */${KARCH}/ ]]; then
199 # remove files already in linux-docs package
200 rm -r "${_builddir}/Documentation"
203 chmod -R u=rwX,go=rX "${_builddir}"
205 # strip scripts directory
207 while read -rd '' _binary; do
208 case "$(file -bi "${_binary}")" in
209 *application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so)
210 *application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a)
211 *application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries
214 /usr/bin/strip ${_strip} "${_binary}"
215 done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null)
219 pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase/linux/Linux} kernel"
222 local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build"
224 mkdir -p "${_builddir}"
225 cp -t "${_builddir}" -a Documentation
228 chmod -R u=rwX,go=rX "${_builddir}"
231 pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
232 for _p in ${pkgname[@]}; do
233 eval "package_${_p}() {
234 $(declare -f "_package${_p#${pkgbase}}")
235 _package${_p#${pkgbase}}
239 # vim:set ts=8 sts=2 sw=2 et: