So what I do is very much the trial and error approach.
I also use variables to eliminate the human error factor.
| Version | Timestamp | |
|---|---|---|
| Revision | 10 | 2026-01-23T07:40:00Z |
| 12 | 2026-01-23T10:17:00Z | |
| 13 | 2026-01-23T10:35:00Z | |
This script is valid as of 2026-01-22T23:00:00Z - anyone reading this months or years from now - please validate - make no assumptions about the state of the Manjaro kernel buildscripts.
#!/usr/bin/env bash
####---- version 13 ----####
# date=2026-01-23 time=11:35:00 timezone="Europe/Copenhagen"
# define custom kernel identifier
custom="custom"
# define custom build host
host="$(hostnamectl hostname)"
# define custom build user
user=$USER
# define builddir - default to user's home
builddir=$HOME
# define manjaro kernel name to work with
manjaro_kernel=linux618
# define the kernel configuration path
kernel_config=${builddir}/${manjaro_kernel}/config
# define the pkgbuild path
pkgrecipe=${builddir}/${manjaro_kernel}/PKGBUILD
# cd into builddir
cd ${builddir}
# remove ${manjaro_kernel} dir if it exist
[[ -d ${builddir}/${manjaro_kernel} ]] && rm -rf ${builddir}/${manjaro_kernel}
# clone Manjaro package build recipe
git clone https://gitlab.manjaro.org/packages/core/${manjaro_kernel}.git ${builddir}/${manjaro_kernel}
# change working folder
cd ${builddir}/${manjaro_kernel}
# --------------------------
# modify build recipe
# add '-CUSTOM' to kernel name
sed -i 's|^_kernelname=.*|_kernelname=\"-'${custom}'\"|g' ${pkgrecipe}
# add '-custom' to package base name
sed -i 's|^pkgbase=.*|pkgbase="linux\${_basever}-'${custom}'\"|g' ${pkgrecipe}
# add '-custom' to the kernel name
sed -i 's|\"\${_basekernel}-\${CARCH}\"|\"\${_basekernel}-'${custom}'-\${CARCH}\"|g' ${pkgrecipe}
# --------------------------
# modify kernel config
# set KBUILD_BUILD_HOST to current hostname
sed -i 's|^export KBUILD_BUILD_HOST=.*|export KBUILD_BUILD_HOST=\"'${host}'\"|g' ${pkgrecipe}
# set KBUILD_BUILD_USER to current user
sed -i 's|^export KBUILD_BUILD_USER=.*|export KBUILD_BUILD_USER=\"'${user}'\"|g' ${pkgrecipe}
# set kernel config CONFIG_LOCALVERSION to '-CUSTOM'
sed -i 's|^CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"-'${custom}'\"|g' ${kernel_config}
# set kernel config CONFIG_DEFAULT_HOSTNAME to current hostname
sed -i 's|^CONFIG_DEFAULT_HOSTNAME=.*|CONFIG_DEFAULT_HOSTNAME=\"'${host}'\"|g' ${kernel_config}
# update pkgsums
updpkgsums
# run makepkg
PKGDEST=${builddir}/${manjaro_kernel} makepkg -s