package build for linux
This commit is contained in:
259
PKGBUILD
Normal file
259
PKGBUILD
Normal file
@@ -0,0 +1,259 @@
|
||||
# Maintainer: Thomas Kuschel <thomas@kuschel.at>
|
||||
|
||||
pkgbase=linux-tkt
|
||||
_srcname=linux
|
||||
_gitver=v5.17.1
|
||||
_patchver=20220315
|
||||
# patchver=master
|
||||
_patchname=more-uarches-for-kernel-5.17+.patch
|
||||
pkgver=5.17.v.1
|
||||
pkgrel=1
|
||||
|
||||
arch=('x86_64')
|
||||
url="https://www.kernel.org/"
|
||||
license=('GPL2')
|
||||
makedepends=('kmod' 'inetutils' 'bc' 'git' 'libelf' 'lzop' 'gcc>=10.3')
|
||||
options=('!strip')
|
||||
|
||||
source=("git+https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git#tag=$_gitver"
|
||||
# the main kernel config files
|
||||
'config-tkt.x86_64'
|
||||
# standard config files for mkinitcpio ramdisk
|
||||
"${pkgbase}.preset"
|
||||
# linux package install directives for pacman
|
||||
'linux.install'
|
||||
# patch from our graysky archlinux colleague, at https://github.com/graysky2/kernel_compiler_patch
|
||||
"https://raw.githubusercontent.com/graysky2/kernel_compiler_patch/$_patchver/$_patchname"
|
||||
)
|
||||
sha256sums=('SKIP'
|
||||
#config-tkt.x86_64
|
||||
#'6fd15429ded75ec4ef43f0bbf2bc1648bf09d9f430078441b5d715b4c31cd644'
|
||||
'SKIP'
|
||||
#.preset file linux-tkt.preset
|
||||
'f1eaf5f24b251b823ff6991119b4bc80df5ba22065803b7bd2f1f09d1bd06e0e'
|
||||
#linux install file
|
||||
'd590e751ab4cf424b78fd0d57e53d187f07401a68c8b468d17a5f39a337dacf0'
|
||||
#grayskypatch
|
||||
'dea86a521603414a8c7bf9cf1f41090d5d6f8035ce31407449e25964befb1e50'
|
||||
)
|
||||
|
||||
_kernelname=${pkgbase#linux}
|
||||
|
||||
pkgver() {
|
||||
echo $pkgver
|
||||
}
|
||||
|
||||
prepare() {
|
||||
cd "${_srcname}"
|
||||
if [ "${CARCH}" = "x86_64" ]; then
|
||||
cat "${srcdir}/config-tkt.x86_64" > ./.config
|
||||
else
|
||||
echo "Sorry, non x86_64 arch not supported."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# don't run depmod on 'make install'. We'll do this ourselves in packaging
|
||||
sed -i '2iexit 0' scripts/depmod.sh
|
||||
|
||||
# Implement all packaged patches.
|
||||
msg2 "Implementing custom kernel patches"
|
||||
while read patch; do
|
||||
echo "Applying $patch"
|
||||
git apply $patch || exit 2
|
||||
done <<< $(ls ../*.patch)
|
||||
|
||||
# get kernel version
|
||||
msg2 "Preparing kernel"
|
||||
yes "" | make prepare
|
||||
|
||||
# load configuration
|
||||
msg2 "Preparing config"
|
||||
# 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
|
||||
make olddefconfig # old config from previous kernel, defaults for new options
|
||||
# ... or manually edit .config
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${_srcname}"
|
||||
|
||||
#old: Force zenv2 architecture optimisation.
|
||||
# Force the local machine instruction subsets (hence the result might not run on different machines)
|
||||
export CFLAGS="-march=native -mtune=native -O2 -pipe -fstack-protector-strong"
|
||||
export CXXFLAGS="${CFLAGS}"
|
||||
make ${MAKEFLAGS} LOCALVERSION= bzImage modules
|
||||
}
|
||||
|
||||
_package() {
|
||||
pkgdesc="Linux kernel aimed at the native CPU based hardware"
|
||||
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7' 'lzop')
|
||||
optdepends=('crda: to set the correct wireless channels of your country')
|
||||
backup=("etc/mkinitcpio.d/${pkgbase}.preset")
|
||||
install=linux.install
|
||||
|
||||
cd "${_srcname}"
|
||||
|
||||
KARCH=x86
|
||||
|
||||
# get kernel version
|
||||
_kernver="$(make LOCALVERSION= kernelrelease)"
|
||||
_basekernel=${_kernver%%-*}
|
||||
_basekernel=${_basekernel%.*}
|
||||
|
||||
mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
|
||||
make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
|
||||
cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
|
||||
|
||||
# set correct depmod command for install
|
||||
cp -f "${startdir}/${install}" "${startdir}/${install}.pkg"
|
||||
true && install=${install}.pkg
|
||||
sed \
|
||||
-e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
|
||||
-e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
|
||||
-i "${startdir}/${install}"
|
||||
|
||||
# install mkinitcpio preset file for kernel
|
||||
install -D -m644 "${srcdir}/${pkgbase}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
|
||||
sed \
|
||||
-e "1s|'linux.*'|'${pkgbase}'|" \
|
||||
-e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgbase}\"|" \
|
||||
-e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgbase}.img\"|" \
|
||||
-e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgbase}-fallback.img\"|" \
|
||||
-i "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
|
||||
|
||||
# remove build and source links
|
||||
rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
|
||||
# remove the firmware
|
||||
rm -rf "${pkgdir}/lib/firmware"
|
||||
# make room for external modules
|
||||
ln -s "../extramodules-${_basekernel}${_kernelname:--ARCH}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
|
||||
# add real version for building modules and running depmod from post_install/upgrade
|
||||
mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}"
|
||||
echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--ARCH}/version"
|
||||
|
||||
# Now we call depmod...
|
||||
depmod -b "${pkgdir}" -F System.map "${_kernver}"
|
||||
|
||||
# move module tree /lib -> /usr/lib
|
||||
mkdir -p "${pkgdir}/usr"
|
||||
mv "${pkgdir}/lib" "${pkgdir}/usr/"
|
||||
|
||||
# add vmlinux
|
||||
install -D -m644 vmlinux "${pkgdir}/usr/lib/modules/${_kernver}/build/vmlinux"
|
||||
|
||||
# add vmlinuz in /usr/lib/modules/ and info for correct hook triggers
|
||||
cp arch/$KARCH/boot/bzImage "${pkgdir}/usr/lib/modules/${_kernver}/vmlinuz"
|
||||
echo ${pkgbase} > "${pkgdir}/usr/lib/modules/${_kernver}/pkgbase"
|
||||
|
||||
# add System.map
|
||||
install -D -m644 System.map "${pkgdir}/boot/System.map-${_kernver}"
|
||||
}
|
||||
|
||||
_package-headers() {
|
||||
pkgdesc="Header files and scripts for building modules for Linux kernel aimed at the local CPU based hardware"
|
||||
|
||||
install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
|
||||
|
||||
cd "${_srcname}"
|
||||
install -D -m644 Makefile \
|
||||
"${pkgdir}/usr/lib/modules/${_kernver}/build/Makefile"
|
||||
install -D -m644 kernel/Makefile \
|
||||
"${pkgdir}/usr/lib/modules/${_kernver}/build/kernel/Makefile"
|
||||
install -D -m644 .config \
|
||||
"${pkgdir}/usr/lib/modules/${_kernver}/build/.config"
|
||||
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include"
|
||||
|
||||
for i in $(ls include/); do
|
||||
cp -a include/${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/include/"
|
||||
done
|
||||
|
||||
# copy arch includes for external modules
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86"
|
||||
cp -a arch/x86/include "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/x86/"
|
||||
|
||||
# copy files necessary for later builds, like nvidia and vmware
|
||||
cp Module.symvers "${pkgdir}/usr/lib/modules/${_kernver}/build"
|
||||
cp -a scripts "${pkgdir}/usr/lib/modules/${_kernver}/build"
|
||||
|
||||
# Make tmpdir for versions
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/.tmp_versions"
|
||||
|
||||
# add kernel files to headers
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel"
|
||||
cp arch/${KARCH}/Makefile "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/"
|
||||
cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/lib/modules/${_kernver}/build/arch/${KARCH}/kernel/"
|
||||
|
||||
# add dm headers
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
|
||||
cp drivers/md/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/drivers/md"
|
||||
|
||||
# add inotify.h
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux"
|
||||
cp include/linux/inotify.h "${pkgdir}/usr/lib/modules/${_kernver}/build/include/linux/"
|
||||
|
||||
# add wireless headers
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/net/mac80211/"
|
||||
cp net/mac80211/*.h "${pkgdir}/usr/lib/modules/${_kernver}/build/net/mac80211/"
|
||||
|
||||
# copy in Kconfig files
|
||||
for i in $(find . -name "Kconfig*"); do
|
||||
mkdir -p "${pkgdir}"/usr/lib/modules/${_kernver}/build/`echo ${i} | sed 's|/Kconfig.*||'`
|
||||
cp ${i} "${pkgdir}/usr/lib/modules/${_kernver}/build/${i}"
|
||||
done
|
||||
|
||||
# Fix file conflict with -doc package
|
||||
rm "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/kbuild"/Kconfig.*-*
|
||||
rm "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/Kconfig"
|
||||
|
||||
# Add objtool for CONFIG_STACK_VALIDATION
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build/tools"
|
||||
cp -a tools/objtool "${pkgdir}/usr/lib/modules/${_kernver}/build/tools"
|
||||
|
||||
chown -R root.root "${pkgdir}/usr/lib/modules/${_kernver}/build"
|
||||
find "${pkgdir}/usr/lib/modules/${_kernver}/build" -type d -exec chmod 755 {} \;
|
||||
|
||||
# strip scripts directory
|
||||
find "${pkgdir}/usr/lib/modules/${_kernver}/build/scripts" -type f -perm -u+w 2>/dev/null | while read binary ; do
|
||||
case "$(file -bi "${binary}")" in
|
||||
*application/x-sharedlib*) # Libraries (.so)
|
||||
/usr/bin/strip ${STRIP_SHARED} "${binary}";;
|
||||
*application/x-archive*) # Libraries (.a)
|
||||
/usr/bin/strip ${STRIP_STATIC} "${binary}";;
|
||||
*application/x-executable*) # Binaries
|
||||
/usr/bin/strip ${STRIP_BINARIES} "${binary}";;
|
||||
esac
|
||||
done
|
||||
|
||||
# remove unneeded architectures
|
||||
while read modarch; do
|
||||
rm -rf $modarch
|
||||
done <<< $(find "${pkgdir}"/usr/lib/modules/${_kernver}/build/arch/ -maxdepth 1 -mindepth 1 -type d | grep -v /x86$)
|
||||
|
||||
}
|
||||
|
||||
_package-docs() {
|
||||
pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel"
|
||||
|
||||
cd "${_srcname}"
|
||||
|
||||
mkdir -p "${pkgdir}/usr/lib/modules/${_kernver}/build"
|
||||
cp -al Documentation "${pkgdir}/usr/lib/modules/${_kernver}/build"
|
||||
find "${pkgdir}" -type f -exec chmod 444 {} \;
|
||||
find "${pkgdir}" -type d -exec chmod 755 {} \;
|
||||
|
||||
# remove a file already in linux package
|
||||
rm -f "${pkgdir}/usr/lib/modules/${_kernver}/build/Documentation/DocBook/Makefile"
|
||||
|
||||
}
|
||||
|
||||
pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
|
||||
for _p in ${pkgname[@]}; do
|
||||
eval "package_${_p}() {
|
||||
$(declare -f "_package${_p#${pkgbase}}")
|
||||
_package${_p#${pkgbase}}
|
||||
}"
|
||||
done
|
||||
@@ -1 +0,0 @@
|
||||
../config-tkt.x86_64
|
||||
10852
config-tkt.x86_64
Normal file
10852
config-tkt.x86_64
Normal file
File diff suppressed because it is too large
Load Diff
16
linux-tkt.preset
Normal file
16
linux-tkt.preset
Normal file
@@ -0,0 +1,16 @@
|
||||
# mkinitcpio preset file for the 'linux-tkt' package
|
||||
|
||||
ALL_config="/etc/mkinitcpio.conf"
|
||||
ALL_kver="/boot/vmlinuz-linux-tkt"
|
||||
|
||||
export COMPRESSION="lzop"
|
||||
|
||||
PRESETS=('default' 'fallback')
|
||||
|
||||
#default_config="/etc/mkinitcpio.conf"
|
||||
default_image="/boot/initramfs-linux-tkt.img"
|
||||
#default_options=""
|
||||
|
||||
#fallback_config="/etc/mkinitcpio.conf"
|
||||
fallback_image="/boot/initramfs-linux-tkt-fallback.img"
|
||||
fallback_options="-S autodetect"
|
||||
37
linux.install
Normal file
37
linux.install
Normal file
@@ -0,0 +1,37 @@
|
||||
# arg 1: the new package version
|
||||
# arg 2: the old package version
|
||||
|
||||
KERNEL_NAME=
|
||||
KERNEL_VERSION=
|
||||
|
||||
post_install () {
|
||||
# updating module dependencies
|
||||
echo ">>> Updating module dependencies. Please wait ..."
|
||||
depmod ${KERNEL_VERSION}
|
||||
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
|
||||
mkinitcpio -p linux${KERNEL_NAME}
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
if findmnt --fstab -uno SOURCE /boot &>/dev/null && ! mountpoint -q /boot; then
|
||||
echo "WARNING: /boot appears to be a separate partition but is not mounted."
|
||||
fi
|
||||
|
||||
# updating module dependencies
|
||||
echo ">>> Updating module dependencies. Please wait ..."
|
||||
depmod ${KERNEL_VERSION}
|
||||
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..."
|
||||
mkinitcpio -p linux${KERNEL_NAME}
|
||||
|
||||
if [ $(vercmp $2 3.13) -lt 0 ]; then
|
||||
echo ">>> WARNING: AT keyboard support is no longer built into the kernel."
|
||||
echo ">>> In order to use your keyboard during early init, you MUST"
|
||||
echo ">>> include the 'keyboard' hook in your mkinitcpio.conf."
|
||||
fi
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
# also remove the compat symlinks
|
||||
rm -f boot/initramfs-linux${KERNEL_NAME}.img
|
||||
rm -f boot/initramfs-linux${KERNEL_NAME}-fallback.img
|
||||
}
|
||||
Reference in New Issue
Block a user