# Maintainer: Evgeny Myandin # Manjaro credits: # Bernhard Landauer # Philip Müller # Arch credits: # Tobias Powalowski # Thomas Baechler # # This is original kernel of Manjaro Linux + ACS patch pkgbase=linux-vfio-manjaro pkgname=('linux-vfio-manjaro' 'linux-vfio-manjaro-headers') _kernelname=-VFIO-MANJARO _basekernel=5.17 _basever=517 pkgver=5.17.13 pkgrel=1 arch=('x86_64') url="https://www.kernel.org/" license=('GPL2') makedepends=('bc' 'docbook-xsl' 'libelf' 'pahole' 'git' 'inetutils' 'kmod' 'xmlto' 'cpio' 'perl' 'tar' 'xz') options=('!strip') source=("https://www.kernel.org/pub/linux/kernel/v5.x/linux-${_basekernel}.tar.xz" "https://www.kernel.org/pub/linux/kernel/v5.x/patch-${pkgver}.xz" 'config' # ARCH Patches '0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch' '0103-tick-Detect_and_fix_jiffies_update_stall.patch' '0104-tick-rcu-Remove_obsolete_parameters.patch' '0105-tick-rcu-Stop_allowing_RCU_SOFTIRQ_in_idle.patch' '0106-lib-irq_poll-Declare_IRQ_POLL_softirq_vector_as_ksoftirqd-parking_safe.patch' '0107-NFSv4.1_provide_mount_option_to_toggle_trunking_discovery.patch' # MANJARO Patches '0201-rtl_bt_fix_load_firmware.patch' # Bootsplash '0301-revert-fbcon-remove-now-unusued-softback_lines-cursor-argument.patch' '0302-revert-fbcon-remove-no-op-fbcon_set_origin.patch' '0303-revert-fbcon-remove-soft-scrollback-code.patch' '0401-bootsplash.patch' '0402-bootsplash.patch' '0403-bootsplash.patch' '0404-bootsplash.patch' '0405-bootsplash.patch' '0406-bootsplash.patch' '0407-bootsplash.patch' '0408-bootsplash.patch' '0409-bootsplash.patch' '0410-bootsplash.patch' '0411-bootsplash.patch' '0412-bootsplash.patch' '0413-bootsplash.gitpatch' # ACS override patch '0999-acs.gitpatch') sha256sums=('555fef61dddb591a83d62dd04e252792f9af4ba9ef14683f64840e46fa20b1b1' 'e021118c2c4307cf1e0df7bcec8484dc96c40a3fe3e2ae105f3b98001343967c' 'fd4881ab23e542cc84922ccc4219d400e88a165ab1edc7e4dac357f4ebfb18f4' 'f85b07d73b2f4ad8bb6b59ee6624b2dd06a03824fc7b00131a01df36c8d899fe' 'f7eb15d563cdbb2c5d780559a1c9564ca8d2dd1ea79fc73a5cc8545278605dad' 'e17f4175131fd5224b438be00b55ac6496ec6c25ac2c6fcc3ec6f9a94e6b3221' 'ca5bb1ba3cb70020d712fa7f684de7d20d2bd6ad2efe6d92b578ab3b12749b04' '6a7cd911548f2b6618ce667f8b88cf1159e6b455e64b74d802710b4fe83ef0a2' '305e5f1844c5f919f8de1873e11b88dec305dfa8cc2245e75e7c157e01bc1443' 'e96d2093539cc23824a6c0dc725332b9c626da14c1bec00dc5ca537ccafb0194' '2b11905b63b05b25807dd64757c779da74dd4c37e36d3f7a46485b1ee5a9d326' '94a8538251ad148f1025cc3de446ce64f73dc32b01815426fb159c722e8fa5bc' '1f18c5c10a3c63e41ecd05ad34cd9f6653ba96e9f1049ce2b7bb6da2578ae710' '59202940d4f12bad23c194a530edc900e066866c9945e39748484a6545af96de' 'e096b127a5208f56d368d2cb938933454d7200d70c86b763aa22c38e0ddb8717' '8c1c880f2caa9c7ae43281a35410203887ea8eae750fe8d360d0c8bf80fcc6e0' '1144d51e5eb980fceeec16004f3645ed04a60fac9e0c7cf88a15c5c1e7a4b89e' 'dd4b69def2efacf4a6c442202ad5cb93d492c03886d7c61de87696e5a83e2846' '028b07f0c954f70ca37237b62e04103e81f7c658bb8bd65d7d3c2ace301297dc' 'a0c548c5703d25ae34b57931f1162de8b18937e676e5791a0f039922090881e7' '8dbb5ab3cb99e48d97d4e2f2e3df5d0de66f3721b4f7fd94a708089f53245c77' 'a7aefeacf22c600fafd9e040a985a913643095db7272c296b77a0a651c6a140a' 'e9f22cbb542591087d2d66dc6dc912b1434330ba3cd13d2df741d869a2c31e89' '27471eee564ca3149dd271b0817719b5565a9594dc4d884fe3dc51a5f03832bc' '60e295601e4fb33d9bf65f198c54c7eb07c0d1e91e2ad1e0dd6cd6e142cb266d' '035ea4b2a7621054f4560471f45336b981538a40172d8f17285910d4e0e0b3ef' '2542b5cea79ab5817ce3d30c54acd045966b9c14587bfb0b2f50d473da48a1d5') prepare() { cd "linux-${_basekernel}" # add upstream patch msg "add upstream patch" patch -p1 -i "../patch-${pkgver}" local src for src in "${source[@]}"; do src="${src%%::*}" src="${src##*/}" [[ $src = *.patch ]] || continue msg2 "Applying patch: $src..." patch -Np1 < "../$src" done msg2 "0513-bootsplash" git apply -p1 < "../0413-bootsplash.gitpatch" msg2 "0999-acs" patch --ignore-whitespace --fuzz 3 -p1 < "../0999-acs.gitpatch" msg2 "add config" cat "../config" > ./.config if [ "${_kernelname}" != "" ]; then sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config fi msg "set extraversion to pkgrel" sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile msg "don't run depmod on 'make install'" # We'll do this ourselves in packaging sed -i '2iexit 0' scripts/depmod.sh msg "get kernel version" make prepare msg "rewrite configuration" yes "" | make config >/dev/null } build() { cd "linux-${_basekernel}" msg "build" make ${MAKEFLAGS} LOCALVERSION= bzImage modules } package_linux-vfio-manjaro() { pkgdesc="The Linux Manjaro standart kernel and modules with ACS patch" depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=27') optdepends=('wireless-regdb: to set the correct wireless channels of your country') provides=(VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE) replaces=(virtualbox-guest-modules wireguard) cd "linux-${_basekernel}" # get kernel version _kernver="$(make LOCALVERSION= kernelrelease)" mkdir -p "${pkgdir}"/{boot,usr/lib/modules} make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 modules_install # systemd expects to find the kernel here to allow hibernation # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344 cp arch/x86/boot/bzImage "${pkgdir}/usr/lib/modules/${_kernver}/vmlinuz" # Used by mkinitcpio to name the kernel echo "${pkgbase}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_kernver}/pkgbase" # add kernel version echo "${pkgver}-${pkgrel}${_kernelname} x64" > "${pkgdir}/boot/${pkgbase}-${CARCH}.kver" # make room for external modules local _extramodules="extramodules-${_basekernel}${_kernelname:--MANJARO}" ln -s "../${_extramodules}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules" # add real version for building modules and running depmod from hook echo "${_kernver}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_extramodules}/version" # remove build and source links rm "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build} # now we call depmod... depmod -b "${pkgdir}/usr" -F System.map "${_kernver}" } package_linux-vfio-manjaro-headers() { pkgdesc="Headers and scripts for building modules for the Linux Manjaro standart kernel with ACS patch" depends=('gawk' 'python' 'libelf' 'pahole') cd "linux-${_basekernel}" local _builddir="${pkgdir}/usr/lib/modules/${_kernver}/build" install -Dt "${_builddir}" -m644 Makefile .config Module.symvers install -Dt "${_builddir}/kernel" -m644 kernel/Makefile install -Dt "${_builddir}" -m644 vmlinux mkdir "${_builddir}/.tmp_versions" cp -t "${_builddir}" -a include scripts install -Dt "${_builddir}/arch/x86" -m644 "arch/x86/Makefile" install -Dt "${_builddir}/arch/x86/kernel" -m644 "arch/x86/kernel/asm-offsets.s" cp -t "${_builddir}/arch/x86" -a "arch/x86/include" install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h # https://bugs.archlinux.org/task/13146 install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h # https://bugs.archlinux.org/task/20402 install -Dt "${_builddir}/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h install -Dt "${_builddir}/drivers/media/tuners" -m644 drivers/media/tuners/*.h # https://bugs.archlinux.org/task/71392 install -Dt "${_builddir}/drivers/iio/common/hid-sensors" -m644 drivers/iio/common/hid-sensors/*.h # add xfs and shmem for aufs building mkdir -p "${_builddir}"/{fs/xfs,mm} # copy in Kconfig files find . -name Kconfig\* -exec install -Dm644 {} "${_builddir}/{}" \; # add objtool for external module building and enabled VALIDATION_STACK option install -Dt "${_builddir}/tools/objtool" tools/objtool/objtool # required when DEBUG_INFO_BTF_MODULES is enabled install -Dt "${_builddir}/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids # remove unneeded architectures local _arch for _arch in "${_builddir}"/arch/*/; do [[ ${_arch} == */x86/ ]] && continue rm -r "${_arch}" done # remove documentation files rm -r "${_builddir}/Documentation" # strip scripts directory local file while read -rd '' file; do case "$(file -bi "$file")" in application/x-sharedlib\;*) # Libraries (.so) strip $STRIP_SHARED "$file" ;; application/x-archive\;*) # Libraries (.a) strip $STRIP_STATIC "$file" ;; application/x-executable\;*) # Binaries strip $STRIP_BINARIES "$file" ;; application/x-pie-executable\;*) # Relocatable binaries strip $STRIP_SHARED "$file" ;; esac done < <(find "${_builddir}" -type f -perm -u+x ! -name vmlinux -print0 2>/dev/null) strip $STRIP_STATIC "${_builddir}/vmlinux" # remove unwanted files find ${_builddir} -name '*.orig' -delete }