simplify custom kernels #30863

This commit is contained in:
Tobias Powalowski 2012-08-08 08:13:48 +00:00
parent e42591ff10
commit fc67baf6ed
1 changed files with 66 additions and 46 deletions

112
PKGBUILD
View File

@ -2,24 +2,22 @@
# Maintainer: Tobias Powalowski <tpowa@archlinux.org> # Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Maintainer: Thomas Baechler <thomas@archlinux.org> # Maintainer: Thomas Baechler <thomas@archlinux.org>
pkgbase=linux pkgbase=linux # Build stock -ARCH kernel
pkgname=('linux' 'linux-headers' 'linux-docs') # Build stock -ARCH kernel #pkgbase=linux-custom # Build kernel with a different name
# pkgname=linux-custom # Build kernel with a different name _srcname=linux-3.5
_kernelname=${pkgname#linux} pkgver=3.5.0
_basekernel=3.5
pkgver=${_basekernel}
pkgrel=2 pkgrel=2
arch=('i686' 'x86_64') arch=('i686' 'x86_64')
url="http://www.kernel.org/" url="http://www.kernel.org/"
license=('GPL2') license=('GPL2')
makedepends=('xmlto' 'docbook-xsl') makedepends=('xmlto' 'docbook-xsl')
options=('!strip') options=('!strip')
source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.5.tar.xz" source=("http://www.kernel.org/pub/linux/kernel/v3.x/${_srcname}.tar.xz"
#"http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz" #"http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
# the main kernel config files # the main kernel config files
'config' 'config.x86_64' 'config' 'config.x86_64'
# standard config files for mkinitcpio ramdisk # standard config files for mkinitcpio ramdisk
"${pkgname}.preset" 'linux.preset'
'change-default-console-loglevel.patch' 'change-default-console-loglevel.patch'
'avmfritz-only-few-bytes-are-transfered-on-a-conn.patch') 'avmfritz-only-few-bytes-are-transfered-on-a-conn.patch')
md5sums=('24153eaaa81dedc9481ada8cd9c3b83d' md5sums=('24153eaaa81dedc9481ada8cd9c3b83d'
@ -29,8 +27,10 @@ md5sums=('24153eaaa81dedc9481ada8cd9c3b83d'
'9d3c56a4b999c8bfbd4018089a62f662' '9d3c56a4b999c8bfbd4018089a62f662'
'2afcc001cc178be72e3a19d95f4bd5eb') '2afcc001cc178be72e3a19d95f4bd5eb')
_kernelname=${pkgbase#linux}
build() { build() {
cd "${srcdir}/linux-${_basekernel}" cd "${srcdir}/${_srcname}"
# add upstream patch # add upstream patch
#patch -p1 -i "${srcdir}/patch-${pkgver}" #patch -p1 -i "${srcdir}/patch-${pkgver}"
@ -55,6 +55,7 @@ build() {
if [ "${_kernelname}" != "" ]; then if [ "${_kernelname}" != "" ]; then
sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
sed -i "s|CONFIG_LOCALVERSION_AUTO=.*|CONFIG_LOCALVERSION_AUTO=n|" ./.config
fi fi
# set extraversion to pkgrel # set extraversion to pkgrel
@ -74,57 +75,67 @@ build() {
#make oldconfig # using old config from previous kernel version #make oldconfig # using old config from previous kernel version
# ... or manually edit .config # ... or manually edit .config
# rewrite configuration
yes "" | make config >/dev/null
# save configuration for later reuse
if [ "${CARCH}" = "x86_64" ]; then
cat .config > "${startdir}/config.x86_64.last"
else
cat .config > "${startdir}/config.last"
fi
#################### ####################
# stop here # stop here
# this is useful to configure the kernel # this is useful to configure the kernel
#msg "Stopping build" #msg "Stopping build"; return 1
#return 1
#################### ####################
yes "" | make config
# build! # build!
make ${MAKEFLAGS} bzImage modules make ${MAKEFLAGS} LOCALVERSION= bzImage modules
} }
package_linux() { _package() {
pkgdesc="The Linux Kernel and modules" pkgdesc="The ${pkgbase} kernel and modules"
groups=('base') [ "${pkgbase}" = "linux" ] && groups=('base')
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7') depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
optdepends=('crda: to set the correct wireless channels of your country') optdepends=('crda: to set the correct wireless channels of your country')
provides=('kernel26') provides=("kernel26${_kernelname}=${pkgver}")
conflicts=('kernel26') conflicts=("kernel26${_kernelname}")
replaces=('kernel26') replaces=("kernel26${_kernelname}")
backup=("etc/mkinitcpio.d/${pkgname}.preset") backup=("etc/mkinitcpio.d/${pkgbase}.preset")
install=${pkgname}.install install=linux.install
cd "${srcdir}/linux-${_basekernel}" cd "${srcdir}/${_srcname}"
KARCH=x86 KARCH=x86
# get kernel version # get kernel version
_kernver="$(make kernelrelease)" _kernver="$(make LOCALVERSION= kernelrelease)"
_basekernel=${_kernver%%-*}
_basekernel=${_basekernel%.*}
mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot} mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
make INSTALL_MOD_PATH="${pkgdir}" modules_install make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}" modules_install
cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}" cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}"
# add vmlinux # add vmlinux
install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux" install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"
# install fallback mkinitcpio.conf file and preset file for kernel # install fallback mkinitcpio.conf file and preset file for kernel
install -D -m644 "${srcdir}/${pkgname}.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset" install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
# set correct depmod command for install # set correct depmod command for install
sed \ sed \
-e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \ -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
-e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \ -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
-i "${startdir}/${pkgname}.install" -i "${startdir}/linux.install"
sed \ sed \
-e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|g" \ -e "1s|'linux.*'|'${pkgbase}'|" \
-e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|g" \ -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgbase}\"|" \
-e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|g" \ -e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgbase}.img\"|" \
-i "${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset" -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgbase}-fallback.img\"|" \
-i "${pkgdir}/etc/mkinitcpio.d/${pkgbase}.preset"
# remove build and source links # remove build and source links
rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build} rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
@ -145,18 +156,18 @@ package_linux() {
depmod -b "$pkgdir" -F System.map "$_kernver" depmod -b "$pkgdir" -F System.map "$_kernver"
} }
package_linux-headers() { _package-headers() {
pkgdesc="Header files and scripts for building modules for linux kernel" pkgdesc="Header files and scripts for building modules for ${pkgbase} kernel"
provides=('kernel26-headers') provides=("kernel26${_kernelname}-headers=${pkgver}")
conflicts=('kernel26-headers') conflicts=("kernel26${_kernelname}-headers")
replaces=('kernel26-headers') replaces=("kernel26${_kernelname}-headers")
install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}" install -dm755 "${pkgdir}/usr/lib/modules/${_kernver}"
cd "${pkgdir}/usr/lib/modules/${_kernver}" cd "${pkgdir}/usr/lib/modules/${_kernver}"
ln -sf ../../../src/linux-${_kernver} build ln -sf ../../../src/linux-${_kernver} build
cd "${srcdir}/linux-${_basekernel}" cd "${srcdir}/${_srcname}"
install -D -m644 Makefile \ install -D -m644 Makefile \
"${pkgdir}/usr/src/linux-${_kernver}/Makefile" "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
install -D -m644 kernel/Makefile \ install -D -m644 kernel/Makefile \
@ -276,13 +287,13 @@ package_linux-headers() {
rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,c6x,cris,frv,h8300,hexagon,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,openrisc,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,unicore32,um,v850,xtensa} rm -rf "${pkgdir}"/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,c6x,cris,frv,h8300,hexagon,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,openrisc,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,unicore32,um,v850,xtensa}
} }
package_linux-docs() { _package-docs() {
pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel." pkgdesc="Kernel hackers manual - HTML documentation that comes with the ${pkgbase} kernel"
provides=('kernel26-docs') provides=("kernel26${_kernelname}-docs=${pkgver}")
conflicts=('kernel26-docs') conflicts=("kernel26${_kernelname}-docs")
replaces=('kernel26-docs') replaces=("kernel26${_kernelname}-docs")
cd "${srcdir}/linux-${_basekernel}" cd "${srcdir}/${_srcname}"
mkdir -p "${pkgdir}/usr/src/linux-${_kernver}" mkdir -p "${pkgdir}/usr/src/linux-${_kernver}"
cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}" cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}"
@ -292,3 +303,12 @@ package_linux-docs() {
# remove a file already in linux package # remove a file already in linux package
rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile" rm -f "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
} }
pkgname=("${pkgbase}" "${pkgbase}-headers" "${pkgbase}-docs")
for _p in ${pkgname[@]}; do
eval "package_${_p}() {
_package${_p#${pkgbase}}
}"
done
# vim:set ts=8 sts=2 sw=2 et: