1 # Maintainer: Piotr Gorski <lucjan.lucjanov@gmail.com> PGP-Key: BDB26C5A
2 # Contributor: shivik <> PGP-Key: 761E423C
3 # Contributor: Michael Duell <mail@akurei.me> PGP-Key: 6EE23EBE
4 # A special thanks to Steven Barrett for very important suggestions
5 # Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
6 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
7 # Contributor: Thomas Baechler <thomas@archlinux.org>
10 # Set these variables to ANYTHING that is not null to enable them
12 ### Tweak kernel options prior to a build via nconfig
15 ### Tweak kernel options prior to a build via menuconfig
18 ### Tweak kernel options prior to a build via xconfig
21 ### Tweak kernel options prior to a build via gconfig
24 # NUMA is optimized for multi-socket motherboards.
25 # A single multi-core CPU actually runs slower with NUMA enabled.
26 # See, https://bugs.archlinux.org/task/31187
29 # Compile ONLY used modules to VASTLYreduce the number of modules built
32 # To keep track of which modules are needed for your specific system/hardware,
33 # give module_db script a try: https://aur.archlinux.org/packages/modprobed-db
34 # This PKGBUILD read the database kept if it exists
36 # More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
39 # Use the current kernel's .config file
40 # Enabling this option will use the .config of the RUNNING kernel rather than
41 # the ARCH defaults. Useful when the package gets updated and you already went
42 # through the trouble of customizing your config options. NOT recommended when
43 # a new kernel is released, but again, convenient for package bumps.
49 ### Enable htmldocs (increases compile time)
52 ### Do not edit below this line unless you know what you're doing
54 # pkgname=('linux-lqx' 'linux-lqx-headers' 'linux-lqx-docs')
56 _srcname=linux-${_major}
57 _lqxpatchname=liquorix-package
59 _lqxpatchver=${_lqxpatchname}-${_major}-${_lqxpatchrel}
63 pkgdesc='Linux Liquorix'
64 url='https://liquorix.net/'
67 makedepends=(bc kmod libelf cpio)
68 if [ -n "$_htmldocs_enable" ]; then
69 makedepends+=(xmlto python-sphinx python-sphinx_rtd_theme graphviz imagemagick)
72 #_lucjanpath="https://raw.githubusercontent.com/sirlucjan/kernel-patches/master/${_major}"
73 _lucjanpath="https://gitlab.com/sirlucjan/kernel-patches/raw/master/${_major}"
75 source=("https://cdn.kernel.org/pub/linux/kernel/v5.x/${_srcname}.tar.xz"
76 "https://cdn.kernel.org/pub/linux/kernel/v5.x/${_srcname}.tar.sign"
77 "https://github.com/damentz/${_lqxpatchname}/archive/${_major}-${_lqxpatchrel}.tar.gz"
78 "${_lucjanpath}/docs-patches/0001-Documentation-Fix-sphinx-3.0-causes-compilation-erro.patch")
80 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
81 '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
83 sha512sums=('d3d92ce4246bad74c9a784212f160d98449b1e8793970c2c308276568d852b8effe0528686bdb87d55d691f09a826abf7938d69bdd4759ce65ddd5c05ffe4eca'
85 '0bdd1249e3aed6a6e8e3ba3f016594cd7a2aebd035fed7e21a396d356be709c7b3d83523719fc6549e66de5b6d3359475f82c15a96d4e57fcd71c57a30d5ac59'
86 'b1abc4b21191c841326db341aeea6eac9918a4628f38e32f616a8eeeb9919395656fc4b805110dce93aa38188172fb672831fd76e848b3711fcd6ea9115118c6')
90 export KBUILD_BUILD_HOST=archlinux
91 export KBUILD_BUILD_USER=$pkgbase
92 export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
97 ### Set package version variables
98 _abiname="$(cat ${srcdir}/${_lqxpatchver}/linux-liquorix/debian/config/defines | grep 'abiname:' | sed -r 's/abiname:\s*//')"
99 _minor="$(echo "$_abiname" | cut -f1 -d .)"
100 _patchrel="$(echo "$_abiname" | cut -f2 -d .)"
102 ### Add Liquorix patches
103 local _patchrx='^zen/v\d+\.\d+\.\d+-lqx\d+.patch$'
104 local _patchfolder="${srcdir}/${_lqxpatchver}/linux-liquorix/debian/patches"
105 local _patchpath="$(grep -P "$_patchrx" "$_patchfolder/series")"
106 echo "Patching sources with ${_patchpath#*/}"
107 patch -Np1 -i "$_patchfolder/$_patchpath"
110 echo "Setting version..."
111 scripts/setlocalversion --save-scmversion
112 echo "-$pkgrel" > localversion.10-pkgrel
113 echo "${pkgbase#linux}" > localversion.20-pkgname
117 for src in "${source[@]}"; do
120 [[ $src = *.patch ]] || continue
121 echo "Applying patch $src..."
122 patch -Np1 < "../$src"
126 echo "Setting config..."
127 cat ${srcdir}/${_lqxpatchver}/linux-liquorix/debian/config/kernelarch-x86/config-arch-64 >./.config
131 make -s kernelrelease > version
132 echo "Prepared $pkgbase version $(<version)"
134 ### Optionally use running kernel's config
135 # code originally by nous; http://aur.archlinux.org/packages.php?ID=40191
136 if [ -n "$_use_current" ]; then
137 if [[ -s /proc/config.gz ]]; then
138 echo "Extracting config from /proc/config.gz..."
140 zcat /proc/config.gz > ./.config
142 warning "Your kernel was not compiled with IKCONFIG_PROC!"
143 warning "You cannot read the current config!"
150 if [ -n "$_muqss_disable" ]; then
151 echo "Disabling MUQSS..."
152 scripts/config --disable CONFIG_SCHED_MUQSS
153 scripts/config --disable CONFIG_RQ_NONE
154 scripts/config --disable CONFIG_RQ_SMT
155 scripts/config --disable CONFIG_RQ_MC
156 scripts/config --disable CONFIG_RQ_MC_LLC
157 scripts/config --disable CONFIG_RQ_SMP
158 scripts/config --disable CONFIG_RQ_ALL
159 scripts/config --undefine CONFIG_SHARERQ
162 ### Optionally disable NUMA for 64-bit kernels only
163 # (x86 kernels do not support NUMA)
164 if [ -n "$_NUMAdisable" ]; then
165 echo "Disabling NUMA from kernel config..."
166 scripts/config --disable CONFIG_NUMA
169 ### Optionally load needed modules for the make localmodconfig
170 # See https://aur.archlinux.org/packages/modprobed-db
171 if [ -n "$_localmodcfg" ]; then
172 if [ -f $HOME/.config/modprobed.db ]; then
173 echo "Running Steven Rostedt's make localmodconfig now"
174 make LSMOD=$HOME/.config/modprobed.db localmodconfig
176 echo "No modprobed.db data found"
181 ### Running make nconfig
182 [[ -z "$_makenconfig" ]] || make nconfig
184 ### Running make menuconfig
185 [[ -z "$_makemenuconfig" ]] || make menuconfig
187 ### Running make xconfig
188 [[ -z "$_makexconfig" ]] || make xconfig
190 ### Running make gconfig
191 [[ -z "$_makegconfig" ]] || make gconfig
193 ### Save configuration for later reuse
194 cat .config > "${startdir}/config.last"
201 if [ -n "$_htmldocs_enable" ]; then
207 pkgdesc="The $pkgdesc kernel and modules"
208 depends=(coreutils kmod initramfs)
209 optdepends=('crda: to set the correct wireless channels of your country'
210 'linux-firmware: firmware images needed for some devices'
211 'sof-firmware: firmware images needed for Sound Open Firmware capable devices')
212 provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
215 local kernver="$(<version)"
216 local modulesdir="$pkgdir/usr/lib/modules/$kernver"
218 echo "Installing boot image..."
219 # systemd expects to find the kernel here to allow hibernation
220 # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
221 install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
223 # Used by mkinitcpio to name the kernel
224 echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
226 echo "Installing modules..."
227 make INSTALL_MOD_PATH="$pkgdir/usr" modules_install
229 # remove build and source links
230 rm "$modulesdir"/{source,build}
234 pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
235 depends=('linux-lqx')
238 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
240 echo "Installing build files..."
241 install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
242 localversion.* version vmlinux
243 install -Dt "$builddir/kernel" -m644 kernel/Makefile
244 install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
245 cp -t "$builddir" -a scripts
247 # add objtool for external module building and enabled VALIDATION_STACK option
248 install -Dt "$builddir/tools/objtool" tools/objtool/objtool
250 # add xfs and shmem for aufs building
251 mkdir -p "$builddir"/{fs/xfs,mm}
253 echo "Installing headers..."
254 cp -t "$builddir" -a include
255 cp -t "$builddir/arch/x86" -a arch/x86/include
256 install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
258 install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
259 install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
261 # http://bugs.archlinux.org/task/13146
262 install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
264 # http://bugs.archlinux.org/task/20402
265 install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
266 install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
267 install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
269 echo "Installing KConfig files..."
270 find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
272 echo "Removing unneeded architectures..."
274 for arch in "$builddir"/arch/*/; do
275 [[ $arch = */x86/ ]] && continue
276 echo "Removing $(basename "$arch")"
280 echo "Removing documentation..."
281 rm -r "$builddir/Documentation"
283 echo "Removing broken symlinks..."
284 find -L "$builddir" -type l -printf 'Removing %P\n' -delete
286 echo "Removing loose objects..."
287 find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
289 echo "Stripping build tools..."
291 while read -rd '' file; do
292 case "$(file -bi "$file")" in
293 application/x-sharedlib\;*) # Libraries (.so)
294 strip -v $STRIP_SHARED "$file" ;;
295 application/x-archive\;*) # Libraries (.a)
296 strip -v $STRIP_STATIC "$file" ;;
297 application/x-executable\;*) # Binaries
298 strip -v $STRIP_BINARIES "$file" ;;
299 application/x-pie-executable\;*) # Relocatable binaries
300 strip -v $STRIP_SHARED "$file" ;;
302 done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
304 echo "Adding symlink..."
305 mkdir -p "$pkgdir/usr/src"
306 ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
310 pkgdesc="Documentation for the $pkgdesc kernel"
311 depends=('linux-lqx')
314 local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
316 echo "Installing documentation..."
318 while read -rd '' src; do
319 dst="${src#Documentation/}"
320 dst="$builddir/Documentation/${dst#output/}"
321 install -Dm644 "$src" "$dst"
322 done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
324 echo "Adding symlink..."
325 mkdir -p "$pkgdir/usr/share/doc"
326 ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
329 pkgname=("$pkgbase" "$pkgbase-headers" "$pkgbase-docs")
330 for _p in "${pkgname[@]}"; do
331 eval "package_$_p() {
332 $(declare -f "_package${_p#$pkgbase}")
333 _package${_p#$pkgbase}