You are not logged in.
Yesterday, I compiled an rc linux kernel for testing. Linux Arch2024p8 6.13.5-rc2 #1 SMP PREEMPT_DYNAMIC Tue Feb 25 20:25:29 PST 2025 x86_64 GNU/Linux
This kernel seems to have the patches applied that fix the AMD Raven series APU's. https://git.kernel.org/pub/scm/linux/ke … nux-6.13.y
15 hours Linux 6.13.5-rc2linux-6.13.y Greg Kroah-Hartman 1 -2/+2
15 hours drm/amdgpu: bump version for RV/PCO compute fix Alex Deucher 1 -1/+2
15 hours drm/amdgpu/gfx9: manually control gfxoff for CS on RV Alex Deucher 1 -2/+30
I used this as a guide: https://wiki.archlinux.org/title/Kernel … ompilation
And installed the kernel and modules manually, outside pacman, all seems well and it's stayed running overnight without freezing...
However, I thought a cleaner approach would be to have it installed via a pacman package, and what better opportunity to familiarize myself more with PKGBUILD's.
I'd also consider rolling with this kernel through the rc stage and making the process easier would be key to keeping up.
I found a 'linux-rc' AUR package, however it seemed to be on a static version of an old kernel.
I edited the PKGBUILD to build the version I'm currently running, however there's one small issue that required manual intervention.
Edit: TLDR: The kernel source is comprised of a directory with all the required contents. Problem is the directory is named: linux-stable-rc-linux-6.13.y
I need it to be named: linux-6.13.5-rc2
So makepkg stopped on an error pointing out the missing directory, I renamed it in the src directory, and currently in process building.
What would be the best way to fix this?
I know the kernel config can be set to manually name the kernel, and I used the config of the latest Arch 'linux' package, which is set to auto name it.
I think from going through a kernel build manually, that I can either rename the dir, or possibly leave it as is and set the config to rename it.
If the PKGBUILD was a script, I wouldn't be here asking, but AFAIK, the PKGBUILD is processed by pacman makepkg, so I couldn't script the changes in the PKGBUILD.
Here's the edited PKGBUILD:
#Maintainer: archdevlab <https://github.com/archdevlab>
#Credits: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
#Credits: Andreas Radke <andyrtr@archlinux.org>
#Credits: graysky <therealgraysky AT protonmail DOT com>
################################# Arch ################################
ARCH=x86
################################# Grep GCC version ################################
_gccversion=$(gcc -dumpversion)
################################# CC/CXX/HOSTCC/HOSTCXX ################################
#Set compiler to build the kernel
#Set '1' to build with GCC
#Set '2' to build with CLANG and LLVM
#Default is empty. It will build with GCC. To build with different compiler just use : env _compiler=(1 or 2) makepkg -s
if [ -z ${_compiler+x} ]; then
_compiler=
fi
if [[ "$_compiler" = "1" ]]; then
_compiler=1
BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++)
elif [[ "$_compiler" = "2" ]]; then
_compiler=2
BUILD_FLAGS=(CC=clang CXX=clang++ HOSTCC=clang HOSTCXX=clang++ LD=ld.lld LLVM=1 LLVM_IAS=1)
else
_compiler=1
BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++)
fi
###################################################################################
pkgbase=linux-rc
pkgver=6.13.5rc2
_pkgver=6.13.5-rc2
pkgrel=1
#commit=01de38aa212df7075dc8f4af3f0fa79e1fec2f7b
commit=47b21fa68c21f25fde5c3f43637531afccfd830e
arch=(x86_64)
url='https://www.kernel.org/'
license=(GPL-2.0-only)
makedepends=(
bc
cpio
gettext
libelf
pahole
perl
python
rust
rust-bindgen
rust-src
tar
xz
kmod
xmlto
# htmldocs
graphviz
imagemagick
python-sphinx
python-yaml
texlive-latexextra
)
makedepends+=(
bison
flex
zstd
make
patch
gcc
gcc-libs
glibc
binutils
git
)
if [[ "$_compiler" = "2" ]]; then
makedepends+=(
clang
llvm
llvm-libs
lld
clang
python
)
fi
options=(
!debug
!strip
)
# https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/01de38aa212df7075dc8f4af3f0fa79e1fec2f7b
# https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/47b21fa68c21f25fde5c3f43637531afccfd830e
archlinuxpath=https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/$commit
source=(#https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-${_pkgver}.tar.gz
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/snapshot/linux-stable-rc-linux-6.13.y.tar.gz
${archlinuxpath}/config)
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
prepare(){
cd ${srcdir}/linux-$_pkgver
local src
for src in "${source[@]}"; do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
msg "Applying patch $src..."
patch -Np1 < "../$src"
done
plain ""
# Copy the config file first
msg "Copy the config file first..."
cp "${srcdir}"/config .config
sleep 2s
plain ""
# # Remove gcc-plugin if gcc version = 13.0.0
# if [[ "$_gccversion" = "13.0.0" ]]; then
#
# msg "Remove GCC_PLUGINS"
# scripts/config --disable CONFIG_HAVE_GCC_PLUGINS
# scripts/config --disable CONFIG_GCC_PLUGINS
#
# sleep 2s
# plain ""
# fi
# Set LTO with CLANG/LLVM
if [[ "$_compiler" = "2" ]]; then
msg "Enable THIN LTO"
scripts/config --enable CONFIG_LTO
scripts/config --enable CONFIG_LTO_CLANG
scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG
scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN
scripts/config --disable CONFIG_LTO_NONE
scripts/config --enable CONFIG_HAS_LTO_CLANG
scripts/config --disable CONFIG_LTO_CLANG_FULL
scripts/config --enable CONFIG_LTO_CLANG_THIN
scripts/config --enable CONFIG_HAVE_GCC_PLUGINS
#msg "Enable FULL LTO"
#scripts/config --enable CONFIG_LTO
#scripts/config --enable CONFIG_LTO_CLANG
#scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG
#scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN
#scripts/config --disable CONFIG_LTO_NONE
#scripts/config --enable CONFIG_HAS_LTO_CLANG
#scripts/config --enable CONFIG_LTO_CLANG_FULL
#scripts/config --disable CONFIG_LTO_CLANG_THIN
#scripts/config --enable CONFIG_HAVE_GCC_PLUGINS
#msg "Disable LTO"
#scripts/config --enable CONFIG_LTO_NONE
sleep 2s
plain ""
fi
msg "Set Font"
scripts/config --disable CONFIG_FONTS
scripts/config --enable CONFIG_FONT_8x8
scripts/config --enable CONFIG_FONT_8x16
sleep 2s
# Supress depmod
msg "Supress depmod..."
sed -i '2iexit 0' scripts/depmod.sh
sleep 2s
plain ""
# Setting localversion
msg "Setting localversion..."
# --save-scmversion as been removed in upstream
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/scripts/setlocalversion?h=v6.3-rc1&id=f6e09b07cc12a4d104bb19fe7566b0636f60c413
# scripts/setlocalversion --save-scmversion
echo "-${pkgbase}" > localversion
plain ""
# Config
msg "make olddefconfig..."
make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig
plain ""
make -s kernelrelease > version
msg "Prepared $pkgbase version $(<version)"
plain ""
}
build(){
cd ${srcdir}/linux-$_pkgver
msg "make all"
make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) all
msg "make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1"
make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
}
_package(){
pkgdesc='The Linux kernel and modules - Release Candidate version'
depends=(
coreutils
initramfs
kmod
)
optdepends=(
'wireless-regdb: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices'
)
provides=(
KSMBD-MODULE
VIRTUALBOX-GUEST-MODULES
WIREGUARD-MODULE
)
replaces=(
virtualbox-guest-modules-arch
wireguard-arch
)
cd ${srcdir}/linux-$_pkgver
local kernver="$(<version)"
local modulesdir="${pkgdir}"/usr/lib/modules/${kernver}
msg "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
msg "Installing modules..."
ZSTD_CLEVEL=19 make ARCH=${ARCH} ${BUILD_FLAGS[*]} INSTALL_MOD_PATH="${pkgdir}"/usr INSTALL_MOD_STRIP=1 -j$(nproc) modules_install
# remove build and source links
msg "Remove build dir and source dir..."
rm -rf "$modulesdir"/{source,build}
}
_package-headers(){
pkgdesc="Headers and scripts for building modules for the $pkgbase package"
depends=("${pkgbase}" pahole)
cd ${srcdir}/linux-$_pkgver
local builddir="$pkgdir"/usr/lib/modules/"$(<version)"/build
msg "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map *localversion* version vmlinux tools/bpf/bpftool/vmlinux.h
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
ln -srt "$builddir" "$builddir/scripts/gdb/vmlinux-gdb.py"
# required when STACK_VALIDATION is enabled
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
# required when DEBUG_INFO_BTF_MODULES is enabled
if [ -f tools/bpf/resolve_btfids/resolve_btfids ]; then
install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
fi
msg "Installing headers..."
cp -t "$builddir" -a include
cp -t "$builddir/arch/x86" -a arch/x86/include
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
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
msg "Installing Kconfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
msg "Removing unneeded architectures..."
local arch
for arch in "$builddir"/arch/*/; do
[[ $arch = */x86/ ]] && continue
msg2 "Removing $(basename "$arch")"
rm -r "$arch"
done
msg "Removing documentation..."
rm -r "$builddir/Documentation"
msg "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
msg "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
msg "Stripping build tools..."
local file
while read -rd '' file; do
case "$(file -Sib "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
msg "Stripping vmlinux..."
strip -v $STRIP_STATIC "$builddir/vmlinux"
msg "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}
# sha256sums=('36efbb865ead39771f63ecad7a26adf3dc7de93e27932e59dda81a0bda556b91'
# '6c4d63503c77465232fe4ed42671261b476bb0bfd1223b1a3da4afcc1cd615fb'
# '0cfc1a7b378ae17d932645d00333b9198b7bf24bf8e029ce738f23c71ed8b899')
sha256sums=('fbd2ceac243c13af6a25489933976fb0754aab0a975a7a81d9d2455bc5cecd96'
'9a195bc4d8b492b0f44da392689746f605ca946e4f396bbc25fdbffb383899c1')
pkgname=($pkgbase $pkgbase-headers)
for _p in "${pkgname[@]}"; do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done
# vim:set ts=8 sts=2 sw=2 et:
Edit: Fix link to 'Linux 6.13.5-rc2' (Baby Opossum Posse) commit messages.
Edit: Finished building and installed.
pacman -Q linux-rc : linux-rc 6.13.5rc2-1
uname -r : 6.13.5-rc2-linux-rc
Edit:
If the PKGBUILD was a script, I wouldn't be here asking, but AFAIK, the PKGBUILD is processed by pacman makepkg, so I couldn't script the changes in the PKGBUILD.
This was an incorrect assumption on my part. After a bit of tinkering, seems it's (executed/sourced?) as bash script after all.
Last edited by NuSkool (2025-02-26 23:22:43)
Scripts I use: https://github.com/Cody-Learner
$ glxinfo | grep Device Device: AMD Radeon Vega 11 Graphics (radeonsi, raven, LLVM 19.1.7, DRM 3.60, 6.13.3-arch1-1.1) (0x15dd)
$ sudo dmesg | awk '/drm/ && /gfx/' [ 6.427009] [drm] add ip block number 6 <gfx_v9_0>
Offline
https://aur.archlinux.org/packages/linux-mainline
Edit: wait, what is 'rc' here?
Last edited by Scimmia (2025-02-26 17:45:51)
Offline
@scimmia these are the release candidates for the stable series (see for example https://lore.kernel.org/all/20250225064 … ation.org) and contain the not-yet-released changes for the stable series https://kernel.googlesource.com/pub/scm … ueue-6.13/
I have a PKGBUILD that I use to built these, I could publish it somewhere if that helps, but I also publish prebuilt versions of the kernels to my public html:
sudo pacman -U https://pkgbuild.com/\~gromit/linux-bisection-kernels/linux-6.13.5rc1-1-x86_64.pkg.tar.zst
Offline
Very cool gromit!
Do you keep up with the rc bumps as well?
What about the bisect, is it modified from the stable-rc's?
Maybe a link to the PKGBUILD?
Are you re-building on patches or from scratch for each rc release?
Also, I'd still like to know how to fix the issue for potential future usage....
Last edited by NuSkool (2025-02-26 18:01:50)
Scripts I use: https://github.com/Cody-Learner
$ glxinfo | grep Device Device: AMD Radeon Vega 11 Graphics (radeonsi, raven, LLVM 19.1.7, DRM 3.60, 6.13.3-arch1-1.1) (0x15dd)
$ sudo dmesg | awk '/drm/ && /gfx/' [ 6.427009] [drm] add ip block number 6 <gfx_v9_0>
Offline
No the bisect PKGBUILD is a modified version of the "linux" package that has docs removed and is switched to git sources (pinned to a specific commit) and has a pkgver() so that I can use images that I have already built
Offline
I ended up putting this in the beginning of the 'prepare()' function to rename the root directory.
dirname=$(find "${srcdir}"/ -maxdepth 1 -type d -name 'linux-stable*' -printf "%f\n")
cd "${srcdir}"
mv "${dirname}" "${pkgbase}"
After cleaning up this PKGBUILD a bit, I think may have possibly been better off starting with the repo 'linux' PKGBUILD. Seems this one is setup for some easy to edit options that I'll likely never use or investigate. I probably should go through the depends and makedepends arrays as well, to see if any packages are being pulled in for CLANG LLVM builds that aren't needed for GCC.
Interested in any constructive feedback on the renaming base directory and the latest changes:
#Modified by: NuSkool
#Credits: archdevlab <https://github.com/archdevlab>
#Credits: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
#Credits: Andreas Radke <andyrtr@archlinux.org>
#Credits: graysky <therealgraysky AT protonmail DOT com>
#==============================================================================================
ARCH=x86
_gccversion=$(gcc -dumpversion) # Get GCC version
# Set compiler to build the kernel
# Set '1' to build with GCC
# Set '2' to build with CLANG and LLVM
# Default is empty. It will build with GCC.
# To build with different compiler use:
# env _compiler=(1 or 2) makepkg -s
if [ -z ${_compiler+x} ]; then
_compiler=
fi
if [[ "$_compiler" = "1" ]]; then
_compiler=1
BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++)
elif [[ "$_compiler" = "2" ]]; then
_compiler=2
BUILD_FLAGS=(CC=clang CXX=clang++ HOSTCC=clang HOSTCXX=clang++ LD=ld.lld LLVM=1 LLVM_IAS=1)
else
_compiler=1
BUILD_FLAGS=(CC=gcc CXX=g++ HOSTCC=gcc HOSTCXX=g++)
fi
#==============================================================================================
pkgbase=linux-rc
pkgver=6.13.5rc2
pkgrel=1
arch=(x86_64)
url='https://www.kernel.org/'
license=(GPL-2.0-only)
commit=47b21fa68c21f25fde5c3f43637531afccfd830e
makedepends=(bc
cpio
gettext
libelf
pahole
perl
python
rust
rust-bindgen
rust-src
tar
xz
kmod
xmlto
# htmldocs
graphviz
imagemagick
python-sphinx
python-yaml
texlive-latexextra)
makedepends+=(bison
flex
zstd
make
patch
gcc
gcc-libs
glibc
binutils
git)
if [[ "$_compiler" = "2" ]]; then
makedepends+=(clang
llvm
llvm-libs
lld
clang
python)
fi
options=(!debug
!strip)
# https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/47b21fa68c21f25fde5c3f43637531afccfd830e
archlinuxpath=https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/$commit
source=(https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/snapshot/linux-stable-rc-linux-6.13.y.tar.gz
${archlinuxpath}/config)
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
#=========================================================================================================
prepare(){
dirname=$(find "${srcdir}"/ -maxdepth 1 -type d -name 'linux-stable*' -printf "%f\n")
cd ${srcdir}
mv "${dirname}" "${pkgbase}"
cd "${srcdir}/${pkgbase}"
local src
for src in "${source[@]}"
do
src="${src%%::*}"
src="${src##*/}"
[[ $src = *.patch ]] || continue
msg "Applying patch $src..."
patch -Np1 < "../$src"
done
plain ""
# Copy the config file first
msg "Copy the config file first..."
cp "${srcdir}"/config .config
sleep 2s
plain ""
# # Remove gcc-plugin if gcc version = 13.0.0
# if [[ "$_gccversion" = "13.0.0" ]]; then
#
# msg "Remove GCC_PLUGINS"
# scripts/config --disable CONFIG_HAVE_GCC_PLUGINS
# scripts/config --disable CONFIG_GCC_PLUGINS
#
# sleep 2s
# plain ""
# fi
# Set LTO with CLANG/LLVM
if [[ "$_compiler" = "2" ]]; then
msg "Enable THIN LTO"
scripts/config --enable CONFIG_LTO
scripts/config --enable CONFIG_LTO_CLANG
scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG
scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN
scripts/config --disable CONFIG_LTO_NONE
scripts/config --enable CONFIG_HAS_LTO_CLANG
scripts/config --disable CONFIG_LTO_CLANG_FULL
scripts/config --enable CONFIG_LTO_CLANG_THIN
scripts/config --enable CONFIG_HAVE_GCC_PLUGINS
#msg "Enable FULL LTO"
#scripts/config --enable CONFIG_LTO
#scripts/config --enable CONFIG_LTO_CLANG
#scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG
#scripts/config --enable CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN
#scripts/config --disable CONFIG_LTO_NONE
#scripts/config --enable CONFIG_HAS_LTO_CLANG
#scripts/config --enable CONFIG_LTO_CLANG_FULL
#scripts/config --disable CONFIG_LTO_CLANG_THIN
#scripts/config --enable CONFIG_HAVE_GCC_PLUGINS
#msg "Disable LTO"
#scripts/config --enable CONFIG_LTO_NONE
sleep 2s
plain ""
fi
msg "Set Font"
scripts/config --disable CONFIG_FONTS
scripts/config --enable CONFIG_FONT_8x8
scripts/config --enable CONFIG_FONT_8x16
sleep 2s
# Supress depmod
msg "Supress depmod..."
sed -i '2iexit 0' scripts/depmod.sh
sleep 2s
plain ""
# Setting localversion
msg "Setting localversion..."
# --save-scmversion as been removed in upstream
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git \remove\>>
# /commit/scripts/setlocalversion?h=v6.3-rc1&id=f6e09b07cc12a4d104bb19fe7566b0636f60c413
# scripts/setlocalversion --save-scmversion
echo "-${pkgbase}" > localversion
plain ""
# Config
msg "make olddefconfig..."
make ARCH=${ARCH} ${BUILD_FLAGS[*]} olddefconfig
plain ""
make -s kernelrelease > version
msg "Prepared $pkgbase version $(<version)"
plain ""
}
#=========================================================================================================
build(){
cd "${srcdir}/${pkgbase}"
msg "make all"
make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) all
msg "make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1"
make ARCH=${ARCH} ${BUILD_FLAGS[*]} -j$(nproc) -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
}
#=========================================================================================================
_package(){
pkgdesc='The Linux kernel and modules - Release Candidate version'
depends=(coreutils
initramfs
kmod)
optdepends=('wireless-regdb: to set the correct wireless channels of your country'
'linux-firmware: firmware images needed for some devices')
provides=(KSMBD-MODULE
VIRTUALBOX-GUEST-MODULES
WIREGUARD-MODULE)
replaces=(virtualbox-guest-modules-arch
wireguard-arch)
cd "${srcdir}/${pkgbase}"
local kernver="$(<version)"
local modulesdir="${pkgdir}"/usr/lib/modules/${kernver}
msg "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
msg "Installing modules..."
ZSTD_CLEVEL=19 make ARCH=${ARCH} ${BUILD_FLAGS[*]} INSTALL_MOD_PATH="${pkgdir}"/usr INSTALL_MOD_STRIP=1 -j$(nproc) modules_install
# remove build and source links
msg "Remove build dir and source dir..."
rm -rf "$modulesdir"/{source,build}
}
#=========================================================================================================
_package-headers(){
pkgdesc="Headers and scripts for building modules for the $pkgbase package"
depends=("${pkgbase}" pahole)
cd "${srcdir}/${pkgbase}"
local builddir="$pkgdir"/usr/lib/modules/"$(<version)"/build
msg "Installing build files..."
install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map *localversion* version vmlinux tools/bpf/bpftool/vmlinux.h
install -Dt "$builddir/kernel" -m644 kernel/Makefile
install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
cp -t "$builddir" -a scripts
ln -srt "$builddir" "$builddir/scripts/gdb/vmlinux-gdb.py"
# required when STACK_VALIDATION is enabled
install -Dt "$builddir/tools/objtool" tools/objtool/objtool
# required when DEBUG_INFO_BTF_MODULES is enabled
if [ -f tools/bpf/resolve_btfids/resolve_btfids ]; then
install -Dt "$builddir/tools/bpf/resolve_btfids" tools/bpf/resolve_btfids/resolve_btfids
fi
msg "Installing headers..."
cp -t "$builddir" -a include
cp -t "$builddir/arch/x86" -a arch/x86/include
install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
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
msg "Installing Kconfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
msg "Removing unneeded architectures..."
local arch
for arch in "$builddir"/arch/*/
do
[[ $arch = */x86/ ]] && continue
msg2 "Removing $(basename "$arch")"
rm -r "$arch"
done
msg "Removing documentation..."
rm -r "$builddir/Documentation"
msg "Removing broken symlinks..."
find -L "$builddir" -type l -printf 'Removing %P\n' -delete
msg "Removing loose objects..."
find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
msg "Stripping build tools..."
local file
while read -rd '' file
do
case "$(file -Sib "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
msg "Stripping vmlinux..."
strip -v $STRIP_STATIC "$builddir/vmlinux"
msg "Adding symlink..."
mkdir -p "$pkgdir/usr/src"
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
}
#=========================================================================================================
sha256sums=('fbd2ceac243c13af6a25489933976fb0754aab0a975a7a81d9d2455bc5cecd96'
'9a195bc4d8b492b0f44da392689746f605ca946e4f396bbc25fdbffb383899c1')
pkgname=("$pkgbase" "$pkgbase-headers")
for _p in "${pkgname[@]}"
do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done
# vim:set ts=8 sts=2 sw=2 et:
I'll take a look and do a test build on the repo linux package next to see whats different from this, the naming conventions, etc...
Last edited by NuSkool (2025-02-27 04:40:32)
Scripts I use: https://github.com/Cody-Learner
$ glxinfo | grep Device Device: AMD Radeon Vega 11 Graphics (radeonsi, raven, LLVM 19.1.7, DRM 3.60, 6.13.3-arch1-1.1) (0x15dd)
$ sudo dmesg | awk '/drm/ && /gfx/' [ 6.427009] [drm] add ip block number 6 <gfx_v9_0>
Offline
I ended up putting this in the beginning of the 'prepare()' function to rename the root directory.
Did you try renaming the download through source array ?
source (array)
....
It is also possible to change the name of the downloaded file, which is helpful with weird URLs and for handling multiple source files with the same name. The syntax is: source=('filename::url').
(It does work with VCS urls.)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Online
man PKGBUILD wrote:
Thanks for the reminder... Not sure why I skipped that but maybe because I was more in the 'bash scripting' mindset.
I don't see why 'filename::url' wouldn't work, although have not tested it yet.
I got sidetracked into trying to automate fetching the latest 'linux-stable-rc' version number in the PKGBUILD, without taking a very long time with git.
Still haven't figured out a good way to do this, and without it I don't see any point in moving forward on this.
That and our core testing repo moved 6.13.5 in yesterday, which is the one I've been waiting for.
I thought it would have been nice to have an AUR package with the latest 'linux-stable-rc' kernel + our patches applied.
Scripts I use: https://github.com/Cody-Learner
$ glxinfo | grep Device Device: AMD Radeon Vega 11 Graphics (radeonsi, raven, LLVM 19.1.7, DRM 3.60, 6.13.3-arch1-1.1) (0x15dd)
$ sudo dmesg | awk '/drm/ && /gfx/' [ 6.427009] [drm] add ip block number 6 <gfx_v9_0>
Offline
man PKGBUILD wrote:
I got sidetracked into trying to automate fetching the latest 'linux-stable-rc' version number in the PKGBUILD
You may be overthinking this. No need to 'automate' anything. And you can name it anything you'd like.
For a given kernel branch (currently linux-6.13.y), the tip/head will always point to the latest RC (currently Linux 6.13.5-rc2).
Whether you choose to pull via git or source the archive locally with filename::url is up to you.
The typical use-cases for running an RC kernel are to see if changes might fix an issue you're facing or to be a guinea pig for upstream testing in general.
In either case, the Arch patches are largely unnecessary unless they address something specifically affecting you.
It's easy enough to selectively apply any desired Arch patches on top of either method of sourcing. You may need to rebase them tho if you're ahead of the next tagged Arch release.
Offline
OK, I've learned quite a bit going through this process so far. Unfortunately I'm still not getting along at all with the PKGBUILD 'pkeger()' function. No matter what I tried, it would auto detect a version somewhere in the source code? And exit on error complaining of how the 'pkgver' cannot have these characters, which it did not have.
I believe the issue is, makepkg doesn't like the version string upstream uses for this kernel, so I make the following change to it with a wrapper script. It seemed to make no difference what the 'pkgver' and 'pkgrel' were when I was trying to use the pkeger()' function.
Linux version : 6.13.5-rc2
PKGBUILD version : 6.13.5rc-2
I was going into the source and temp editing files (Makefile and others) directly before and after the 'pkeger()' function ran, and still luck. I guess if an upstream project doesn't follow makepkg's versioning rules, you either can't use it on arch or I'm just too dumb to figure it out how to do it properly... lol
That said I'm pretty sure it's the latter, so I'm here to learn. . .
I also have a working PKGBUILD that runs normally, but it's 100% reliant on filtering the kernel.org 'web.git' for the version, and I just couldn't bring myself to post it on the forums and ask for help.
So I guess this is an improvement? The wrapper script I made takes a peek inside the source archive to get the version info, and then applies it to the PKGBUILD reformatted to it's liking. How might I use this in the PKGBUILD?
Here's what I have at this point.
The wrapper:
#!/bin/bash
_version=$(curl -s "https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/" |
awk '/[0-9]-rc[0-9].*Greg/{match($0, /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/); if (RLENGTH) print substr($0, RSTART, RLENGTH)}' |
sort -V |
tail -n 1)
if [[ ! -e linux-stable-rc-linux-6.13.y.tar.gz ]]; then
wget https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/snapshot/linux-stable-rc-linux-"${_version%.*}".y.tar.gz
# wget https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/snapshot/linux-stable-rc-linux-6.13.y.tar.gz
fi
_verst=$(_vdata='linux-stable-rc-linux-6.13.y.tar.gz'
tar -xzOf "${_vdata}" "${_vdata%.tar*}"/Makefile | awk -F'= *' '
/^VERS/ {v1 = $2}
/^PATC/ {v2 = $2}
/^SUBL/ {v3 = $2}
/^EXTR/ {v4 = $2}
END {print v1 "." v2 "." v3 v4}
')
pkgver="${_verst%-rc*}rc" # 6.13.5rc
pkgrel="${_verst#*-rc*}" # 2
echo "Linux version: ${_verst}"
echo "Arch version : ${_verst%-rc*}rc-${_verst#*-rc*}"
if grep -q pkgver=TBD PKGBUILD; then
sed -i s/pkgver=TBD/pkgver="${pkgver}"/g PKGBUILD
fi
if grep -q pkgrel=0 PKGBUILD; then
sed -i s/pkgrel=0/pkgrel="${pkgrel}"/g PKGBUILD
fi
makepkg -sr
The PKGBUILD:
# Edited: NuSkool
# Credits: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
#
# Depends on AUR package 'modprobed-db' being setup and installed to eliminate unneeded module compile time.
#
# Search and comment out line containing 'HOME' in 'prepare' function to build all modules.
# This PKGBUILD builds latest 'stable:' version '-rc' currently listed here: https://www.kernel.org/
# Not to be confused with 'mainline' and 'LTS' -rc kernels. ie: They can all be referred to as '-rc'. Pay attention to version.
# Linux 'kernel.org' listing the kernel download this uses: https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/
# This PKGBUILD started out for/as Arch's official 'linux' package.
# Noteable mods:
# Eliminate compiling documents.
# Build only essential modules via graysky's modprobed-db.
#-------------------------------------------------------------------------------------------------------------------------------------
# '_version' variable grabs the latest version of the actual 'stable' release, release canidate.
#
#_version=$(curl -s "https://web.git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/" |
# awk '/[0-9]-rc[0-9].*Greg/{match($0, /[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+/); if (RLENGTH) print substr($0, RSTART, RLENGTH)}' |
# sort -V |
# tail -n 1)
#
#_rcver="${_version#*-rc}" >short-v
#
# Note: makepkg will not allow the version string as assigned upstream.
# Changed below from ie: '6.13.5-rc2' to '6.13.5rc-2'.
#-------------------------------------------------------------------------------------------------------------------------------------
pkgbase=linux-stable-rc
pkgver=TBD
pkgrel=0
pkgdesc='Linux'
arch=(x86_64)
license=(GPL-2.0-only)
# printf '\n%s\n' " Building linux-stable-rc ${_version%-rc*}rc-${_rcver}"
printf '\n%s\n' " Building linux-stable-rc ${pkgver}-${pkgrel}"
printf '\n%s\n\n' " Press [Ctrl]+[C] to exit within 3 seconds."
sleep 3
makedepends=(
bc
cpio
gettext
graphviz
imagemagick
libelf
pahole
perl
python
python-sphinx
python-yaml
rust
rust-bindgen
rust-src
tar
texlive-latexextra
xz
)
options=(
!debug
!strip
)
##-------------------------------------------------------------------------------------------------------------------------------------
# '_commit' variable used to pull kernel config.
_commit="47b21fa68c21f25fde5c3f43637531afccfd830e" # Kernel config from Arch gitlab commit dated: Feb 17, 2025. Link below.
# https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/commits/main/config
_srcv=$(find . -type f -name "linux-stable-rc-linux-*.y.tar.gz")
source=(
"${_srcv}"
https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/raw/"${_commit}"/config
)
#-------------------------------------------------------------------------------------------------------------------------------------
validpgpkeys=(
ABAF11C65A2970B130ABE3C479BE3E4300411886 # Linus Torvalds
647F28654894E3BD457199BE38DBBDC86092693E # Greg Kroah-Hartman
83BC8889351B5DEBBB68416EB8AC08600F108CDF # Jan Alexander Steffens (heftig)
)
#-------------------------------------------------------------------------------------------------------------------------------------
# There are a few options to update checksums. I prefer 'makepkg -g', copy paste.
sha256sums=(
'fbd2ceac243c13af6a25489933976fb0754aab0a975a7a81d9d2455bc5cecd96'
'9a195bc4d8b492b0f44da392689746f605ca946e4f396bbc25fdbffb383899c1'
)
b2sums=(
'050418fffc056dbbcc1c094e482e469de28233760c03ff7e25f57510fb59f623e54a0b8d13ef2e8a3cec058ac457ccd99c5833f3a1d522447f7e398629f56750'
'eedd98ed226561af9b279b931d5251974ed98cf21fa0974a855dd0365a16d6702f190dc60eca9bb337534110d94d070e7c7bc5cd61ba774ab38d441b567cce6c'
)
#-------------------------------------------------------------------------------------------------------------------------------------
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER="${pkgbase}"
export KBUILD_BUILD_TIMESTAMP="$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})"
#-------------------------------------------------------------------------------------------------------------------------------------
prepare() {
dirname=$(find "${srcdir}"/ -maxdepth 1 -type d -name 'linux*y' -printf "%f\n")
cd "${srcdir}"
#if [[ ! -d "${pkgbase}" && -n "${dirname}" ]]; then # Temp, needs removed...
mv "${dirname}" "${pkgbase}"
#fi
cd "${pkgbase}" || exit
touch localversion.10-pkgrel
touch localversion.20-pkgname
local src
for src in "${source[@]}"
do
src="${src%%::*}"
src="${src##*/}"
src="${src%.zst}" # Leaving in the case repo patches are added later.
[[ $src = *.patch ]] || continue
echo "Applying patch $src..."
patch -Np1 < "../$src"
done
echo "Setting config..."
cp ../config .config
make olddefconfig
yes "" | make LSMOD="${HOME}"/.config/modprobed.db localmodconfig # Comment this out to build all modules
diff -u ../config .config || :
make -s kernelrelease > version
echo "Prepared ${pkgbase} version $(<version)"
}
#-------------------------------------------------------------------------------------------------------------------------------------
build() {
cd "${pkgbase}"
make all
make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
}
#-------------------------------------------------------------------------------------------------------------------------------------
_package() {
pkgdesc="The $pkgdesc kernel and modules"
depends=(
coreutils
initramfs
kmod
)
optdepends=(
'linux-firmware: firmware images needed for some devices'
'scx-scheds: to use sched-ext schedulers'
'wireless-regdb: to set the correct wireless channels of your country'
)
provides=(
KSMBD-MODULE
VIRTUALBOX-GUEST-MODULES
WIREGUARD-MODULE
)
replaces=(
virtualbox-guest-modules-arch
wireguard-arch
)
cd "${pkgbase}"
local modulesdir="${pkgdir}/usr/lib/modules/$(<version)"
echo "Installing boot image..."
# systemd expects to find the kernel here to allow hibernation
# https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
# Used by mkinitcpio to name the kernel
echo "${pkgbase}" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
echo "Installing modules..."
ZSTD_CLEVEL=19 make INSTALL_MOD_PATH="${pkgdir}/usr" INSTALL_MOD_STRIP=1 \
DEPMOD=/doesnt/exist modules_install # Suppress depmod
# remove build link
rm "$modulesdir"/build
}
#-------------------------------------------------------------------------------------------------------------------------------------
_package-headers() {
pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
depends=(pahole)
cd "${pkgbase}"
local builddir="${pkgdir}/usr/lib/modules/$(<version)/build"
echo "Installing build files..."
install -Dt "${builddir}" -m644 .config Makefile Module.symvers System.map \
localversion.* version vmlinux tools/bpf/bpftool/vmlinux.h
install -Dt "${builddir}/kernel" -m644 kernel/Makefile
install -Dt "${builddir}/arch/x86" -m644 arch/x86/Makefile
cp -t "${builddir}" -a scripts
ln -srt "${builddir}" "${builddir}/scripts/gdb/vmlinux-gdb.py"
# required when STACK_VALIDATION is enabled
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
echo "Installing headers..."
cp -t "${builddir}" -a include
cp -t "${builddir}/arch/x86" -a arch/x86/include
install -Dt "${builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
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
echo "Installing KConfig files..."
find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
echo "Removing unneeded architectures..."
local arch
for arch in "${builddir}"/arch/*/
do
[[ $arch = */x86/ ]] && continue
echo "Removing $(basename "$arch")"
rm -r "$arch"
done
echo "Removing documentation..."
rm -r "${builddir}/Documentation"
echo "Removing broken symlinks..."
find -L "${builddir}" -type l -printf 'Removing %P\n' -delete
echo "Removing loose objects..."
find "${builddir}" -type f -name '*.o' -printf 'Removing %P\n' -delete
echo "Stripping build tools..."
local file
while read -rd '' file
do
case "$(file -Sib "$file")" in
application/x-sharedlib\;*) # Libraries (.so)
strip -v $STRIP_SHARED "$file" ;;
application/x-archive\;*) # Libraries (.a)
strip -v $STRIP_STATIC "$file" ;;
application/x-executable\;*) # Binaries
strip -v $STRIP_BINARIES "$file" ;;
application/x-pie-executable\;*) # Relocatable binaries
strip -v $STRIP_SHARED "$file" ;;
esac
done < <(find "${builddir}" -type f -perm -u+x ! -name vmlinux -print0)
echo "Stripping vmlinux..."
strip -v $STRIP_STATIC "${builddir}/vmlinux"
echo "Adding symlink..."
mkdir -p "${pkgdir}/usr/src"
ln -sr "${builddir}" "${pkgdir}/usr/src/${pkgbase}"
}
#-------------------------------------------------------------------------------------------------------------------------------------
_package-docs() {
pkgdesc="Documentation for the ${pkgdesc} kernel"
cd "${pkgbase}"
local builddir="${pkgdir}/usr/lib/modules/$(<version)/build"
echo "Installing documentation..."
local src dst
while read -rd '' src
do
dst="${src#Documentation/}"
dst="${builddir}/Documentation/${dst#output/}"
install -Dm644 "$src" "$dst"
done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
echo "Adding symlink..."
mkdir -p "${pkgdir}/usr/share/doc"
ln -sr "$builddir/Documentation" "${pkgdir}/usr/share/doc/${pkgbase}"
}
#-------------------------------------------------------------------------------------------------------------------------------------
pkgname=(
"${pkgbase}"
"$pkgbase-headers"
)
for _p in "${pkgname[@]}"
do
eval "package_$_p() {
$(declare -f "_package${_p#$pkgbase}")
_package${_p#$pkgbase}
}"
done
# vim:set ts=8 sts=2 sw=2 et:
TLDR:
How can I use the code in my wrapper script, in the 'pkgver()' function?
Is there a way to gain more control of the PKGBUILD such as function order, etc?
@Lone_Wolf Your suggestion will rename the archive I'm downloading. However I needed to rename the extracted root directory.
@tekstryder, would git be the right tool for the job of downloading the archived kernel source? The kernel.org git.web has a download link, but filtering it out to use is far from ideal. In my limited time playing around, there is a huge time element in some operations involving the git repos.
.
Last edited by NuSkool (Today 05:46:05)
Scripts I use: https://github.com/Cody-Learner
$ glxinfo | grep Device Device: AMD Radeon Vega 11 Graphics (radeonsi, raven, LLVM 19.1.7, DRM 3.60, 6.13.3-arch1-1.1) (0x15dd)
$ sudo dmesg | awk '/drm/ && /gfx/' [ 6.427009] [drm] add ip block number 6 <gfx_v9_0>
Offline