Summary: Is there anything I need to be careful about if I’m installing a kernel outside of the package manager?
Longer version:
Hi all,
5.12 merge window is closing soon-ish, and I’m thinking about compiling it myself. It’s supposed to deliver some important changes for Lenovo laptops which I want to try ASAP, also my town is still under lockdown and I’m looking for something fun to do
I’m not going to ask for help on how to compile it, there is plenty of documentation online and I think I got it covered. What I’m worried about is breaking my Manjaro setup when the same kernel arrives in the package manager. Is this something I need to be concerned about?
can you have a look with
sudo mhw-kernel -l
sudo mhw-kernel -li
Something to be concerned about is recent news on data loss due to buggy code slipped into the aforementioned merge window. Allow it to settle down a bit, maybe rc2 or 3 will be more mature and safe.
I heard about this issue on Phoronix , looks serious. I expect that minds smarter than I are already on it
My concern is more about breaking any logic in Manjaro or package manager by installing a new kernel manually.
merlock
February 27, 2021, 10:23pm
5
So don’t. Grab a PKGBUILD for a recent Manjaro kernel, and adapt it for the 5.12 version.
So don’t. Grab a PKGBUILD for a recent Manjaro kernel, and adapt it for the 5.12 version.
I have no idea how to do that. Never packaged for Manjaro before. Any links you can send my way?
This is mine:
PKGBUILD
# Based on the file created for Arch Linux by:
# Tobias Powalowski <tpowa@archlinux.org>
# Thomas Baechler <thomas@archlinux.org>
# Maintainer: Philip Müller (x86_64) <philm@manjaro.org>
# Maintainer: Jonathon Fernyhough (i686) <jonathon@manjaro.org>
# Contributor: Helmut Stult <helmut[at]manjaro[dot]org>
# Contributor: Vladimir Yerilov <openmindead[at]gmail[dot]com>
pkgbase=linux512
pkgname=('linux512' 'linux512-headers')
_kernelname=-MANJARO
_basekernel=5.12
_basever=512
_sub=0
_rc=rc0
_commit=5695e51619745d4fe3ec2506a2f0cd982c5e27a4
_shortcommit=${_rc}.d0227.g${_commit:0:7}
_pkgver=${_basekernel}.${_shortcommit}
#pkgver=${_basekernel}.${_sub}
pkgver=5.12.rc0.d0226.g2c87f7a
pkgrel=1
arch=('x86_64')
url="http://www.kernel.org/"
license=('GPL2')
makedepends=('bc'
'docbook-xsl'
'elfutils'
'git'
'inetutils'
'kmod'
'xmlto'
'cpio'
'perl'
'tar'
'xz')
options=('!strip')
validpgpkeys=('ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
'8218F88849AAC522E94CF470A5E9288C4FA415FA' # Jan Alexander Steffens (heftig)
)
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"
#https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/snapshot/linux-stable-rc-$_commit.tar.gz
#"linux-${pkgver}.tar.gz::https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-$_commit.tar.gz"
#"linux-${pkgver}.zip::https://codeload.github.com/torvalds/linux/zip/$_commit"
# the main kernel config files
#"git+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git#commit=${_commit}"
"git+file://$HOME/Git/linux"
'config' 'config.anbox'
# ARCH Patches
'0001-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-CLONE_NEWUSER.patch'
'0002-HID-quirks-Add-Apple-Magic-Trackpad-2-to-hid_have_special_driver-list.patch'
# MANJARO Patches
'0101-i2c-nuvoton-nc677x-hwmon-driver.patch'
'0102-iomap-iomap_bmap-should-accept-unwritten-maps.patch'
'0103-futex.patch'
'0104-revert-xhci-Add-support-for-Renesas-controller-with-memory.patch'
'0107-quirk-kernel-org-bug-210681-firmware_rome_error.patch'
# Lenovo + AMD
'0302-lenovo-wmi2.patch'
)
sha256sums=('SKIP'
'fbe5080f64c8b1b99a5f310fdf63d3807b28e2bd206010f7abb46bf4f353018e'
'fc896e5b00fad732d937bfb7b0db41922ecdb3a488bc1c1b91b201e028eed866'
'986f8d802f37b72a54256f0ab84da83cb229388d58c0b6750f7c770818a18421'
'df5843818f1571841e1a8bdbe38d7f853d841f38de46d6a6a5765de089495578'
'7823d7488f42bc4ed7dfae6d1014dbde679d8b862c9a3697a39ba0dae5918978'
'95745075edd597caa92b369cfbcd11a04c9e3c88c0c987c70114924e1e01df5c'
'b302ba6c5bbe8ed19b20207505d513208fae1e678cf4d8e7ac0b154e5fe3f456'
'83b5684223309809393bdffc5122924cb9940403d682a887b0aa6524015df973'
'5e804e1f241ce542f3f0e83d274ede6aa4b0539e510fb9376f8106e8732ce69b'
'1d58ef2991c625f6f0eb33b4cb8303932f53f1c4694e42bae24c9cd36d2ad013')
pkgver() {
printf '%s' "${_pkgver}"
}
prepare() {
#mv "${srcdir}/linux-${_commit}" "${srcdir}/linux-${_basekernel}"
mv "${srcdir}/linux" "${srcdir}/linux-${_basekernel}"
cd "${srcdir}/linux-${_basekernel}"
#git pull
#git checkout ${_commit}
# add upstream patch
#patch -p1 -i "${srcdir}/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 "add config.anbox to config"
cat "${srcdir}/config" > ./.config
cat "${srcdir}/config.anbox" >> ./.config
#msg2 "Rebuilding local signing key..."
#cd ../../certs-local
#./genkeys.sh
#msg2 "Updating kernel config with new key..."
#./fix_config.sh "${srcdir}/linux-${_basekernel}/.config"
#cd "${srcdir}/linux-${_basekernel}"
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
# set patchlevel to 12
sed -ri "s|^(PATCHLEVEL =).*|\1 12|" 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
# load configuration
# Configure the kernel. Replace the line below with one of your choice.
#make menuconfig # CLI menu for configuration
#make nconfig # new CLI menu for configuration
#make xconfig # X-based configuration
#make oldconfig # using old config from previous kernel version
# ... or manually edit .config
msg "rewrite configuration"
yes "" | make LSMOD=$HOME/.config/modprobed.db localmodconfig >/dev/null
#yes "" | make config >/dev/null
}
build() {
cd "${srcdir}/linux-${_basekernel}"
msg "build!"
make ${MAKEFLAGS} LOCALVERSION= bzImage modules
#make ${MAKEFLAGS} CC=clang HOSTCC=clang LOCALVERSION= bzImage modules
}
package_linux512() {
pkgdesc="The ${pkgbase/linux/Linux} kernel and modules"
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=27')
optdepends=('crda: to set the correct wireless channels of your country')
provides=("linux=${pkgver}" VIRTUALBOX-GUEST-MODULES WIREGUARD-MODULE)
cd "${srcdir}/linux-${_basekernel}"
KARCH=x86
# 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/$KARCH/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"
echo "${_basekernel}-${CARCH}" | install -Dm644 /dev/stdin "${pkgdir}/usr/lib/modules/${_kernver}/kernelbase"
# add kernel version
echo "${pkgver}-${pkgrel}-MANJARO 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}"
# add vmlinux
install -Dt "${pkgdir}/usr/lib/modules/${_kernver}/build" -m644 vmlinux
}
package_linux512-headers() {
pkgdesc="Header files and scripts for building modules for ${pkgbase/linux/Linux} kernel"
depends=('gawk' 'python' 'libelf')
provides=("linux-headers=$pkgver")
cd "${srcdir}/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
mkdir "${_builddir}/.tmp_versions"
cp -t "${_builddir}" -a include scripts
install -Dt "${_builddir}/arch/${KARCH}" -m644 "arch/${KARCH}/Makefile"
install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 "arch/${KARCH}/kernel/asm-offsets.s"
#install -Dt "${_builddir}/arch/${KARCH}/kernel" -m644 "arch/${KARCH}/kernel/macros.s"
cp -t "${_builddir}/arch/${KARCH}" -a "arch/${KARCH}/include"
install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h
install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h
# http://bugs.archlinux.org/task/13146
install -Dt "${_builddir}/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
# http://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
# 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
# remove unneeded architectures
local _arch
for _arch in "${_builddir}"/arch/*/; do
[[ ${_arch} == */x86/ ]] && continue
rm -r "${_arch}"
done
# remove files already in linux-docs package
rm -r "${_builddir}/Documentation"
# Fix permissions
chmod -R u=rwX,go=rX "${_builddir}"
# strip scripts directory
local _binary _strip
while read -rd '' _binary; do
case "$(file -bi "${_binary}")" in
*application/x-sharedlib*) _strip="${STRIP_SHARED}" ;; # Libraries (.so)
*application/x-archive*) _strip="${STRIP_STATIC}" ;; # Libraries (.a)
*application/x-executable*) _strip="${STRIP_BINARIES}" ;; # Binaries
*) continue ;;
esac
/usr/bin/strip ${_strip} "${_binary}"
done < <(find "${_builddir}/scripts" -type f -perm -u+w -print0 2>/dev/null)
#
# Out-of-tree module signing
# This is run in the kernel source / build directory
#
#msg2 "Local Signing certs for out-of-tree modules..."
#certs_local_src="../../certs-local"
#key_dir=$(<${certs_local_src}/current_key_dir)
#certs_local_dst="${_builddir}/certs-local"
#signer="sign_manual.sh"
#mkdir -p ${certs_local_dst}
#rsync -a $certs_local_src/{current,$key_dir,$signer} $certs_local_dst/
# DKMS tools
#dkms_src="$certs_local_src/dkms"
#dkms_dst="${pkgdir}/etc/dkms"
#mkdir -p $dkms_dst
#rsync -a $dkms_src/{kernel-sign.conf,kernel-sign.sh} $dkms_dst/
}
Linux git repo files should be in /home/%username/Git/linux.
What you need to do is:
mkdir ~/Git && cd ~/Git
git clone https://gitlab.manjaro.org/packages/core/linux511.git && cd linux511
nano PKGBUILD_512
and then paste the contents of the above, press Ctrl+S and then Ctrl+X
cd .. && git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git && cd linux511
updpkgsums PKGBUILD_512
makepkg -Ccf -p PKGBUILD_512
2 Likes