mirror of
https://gitdl.cn/https://github.com/chakralinux/core.git
synced 2025-02-10 14:04:37 +08:00
216 lines
7.5 KiB
Bash
216 lines
7.5 KiB
Bash
# Source global configuration
|
|
source ../linux.conf
|
|
|
|
pkgbase=linux
|
|
pkgname=('linux' 'linux-headers' 'linux-docs')
|
|
_srcname=linux-${_basekernel}
|
|
pkgver=${_kernelver}
|
|
pkgrel=1
|
|
arch=('x86_64')
|
|
url="http://www.kernel.org/"
|
|
license=('GPL2')
|
|
makedepends=('xmlto' 'docbook-xsl' 'kmod' 'inetutils' 'bc' 'libelf')
|
|
options=('!strip')
|
|
source=(http://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.{xz,sign}
|
|
http://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.{xz,sign}
|
|
# the main kernel config files
|
|
config.x86_64
|
|
# standard config files for mkinitcpio ramdisk
|
|
linux.preset)
|
|
sha256sums=('f81d59477e90a130857ce18dc02f4fbe5725854911db1e7ba770c7cd350f96a7'
|
|
'SKIP'
|
|
'da5d8db44b0988e4c45346899d3f5a51f8bd6c25f14e729615ca9ff9f17bdefd'
|
|
'SKIP'
|
|
'1a3c7879bda6eadff088c75071ff344ffa682fd240a6cdfd9b14ab654c8a157d'
|
|
'f0d90e756f14533ee67afda280500511a62465b4f76adcc5effa95a40045179c')
|
|
validpgpkeys=(
|
|
'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
|
|
'647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
|
|
)
|
|
|
|
prepare() {
|
|
cd ${_srcname}
|
|
|
|
# add upstream patch
|
|
msg "adding upstream patch"
|
|
patch -p1 -i "${srcdir}/patch-${pkgver}"
|
|
|
|
chmod +x scripts/checkpatch.pl
|
|
chmod +x tools/objtool/sync-check.sh
|
|
|
|
# security patches
|
|
# add latest fixes from stable queue, if needed
|
|
# http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git
|
|
|
|
cat "${srcdir}/config.x86_64" > ./.config
|
|
|
|
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
|
|
|
|
# set extraversion to pkgrel
|
|
sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
|
|
|
|
# don't run depmod on 'make install'. We'll do this ourselves in packaging
|
|
sed -i '2iexit 0' scripts/depmod.sh
|
|
|
|
# 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
|
|
|
|
# rewrite configuration
|
|
yes "" | make config >/dev/null
|
|
|
|
# save configuration for later reuse
|
|
cat .config > "${startdir}/config.x86_64.last"
|
|
}
|
|
|
|
build() {
|
|
cd "$_srcname"
|
|
|
|
make ${MAKEFLAGS} LOCALVERSION= bzImage modules
|
|
}
|
|
|
|
package_linux() {
|
|
pkgdesc="The Linux Kernel and modules"
|
|
groups=('base')
|
|
depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
|
|
optdepends=('crda: to set the correct wireless channels of your country')
|
|
backup=("etc/mkinitcpio.d/${pkgname}.preset")
|
|
install=linux.install
|
|
|
|
cd ${_srcname}
|
|
|
|
# get kernel version
|
|
_kernver="$(make LOCALVERSION= kernelrelease)"
|
|
_basekernel=${_kernver%%-*}
|
|
_basekernel=${_basekernel%.*}
|
|
|
|
mkdir -p "${pkgdir}"/{boot,usr/lib/modules}
|
|
make LOCALVERSION= INSTALL_MOD_PATH="${pkgdir}/usr" modules_install
|
|
cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"
|
|
|
|
# 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 fallback mkinitcpio.conf file and preset file for kernel
|
|
install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/linux${_kernelname}.preset"
|
|
sed \
|
|
-e "1s|'linux.*'|'${pkgname}'|" \
|
|
-e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz-${pkgname}\"|" \
|
|
-e "s|default_image=.*|default_image=\"/boot/initramfs-${pkgname}.img\"|" \
|
|
-e "s|fallback_image=.*|fallback_image=\"/boot/initramfs-${pkgname}-fallback.img\"|" \
|
|
-i "${pkgdir}/etc/mkinitcpio.d/linux${_kernelname}.preset"
|
|
|
|
# remove build and source links
|
|
rm -f "${pkgdir}"/usr/lib/modules/${_kernver}/{source,build}
|
|
|
|
# gzip -9 all modules to save 100MB of space
|
|
find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
|
|
|
|
# make room for external modules
|
|
ln -s "../extramodules-${_basekernel}${_kernelname:--CHAKRA}" "${pkgdir}/usr/lib/modules/${_kernver}/extramodules"
|
|
# add real version for building modules and running depmod from post_install/upgrade
|
|
mkdir -p "${pkgdir}/usr/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}"
|
|
echo "${_kernver}" > "${pkgdir}/usr/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}/version"
|
|
|
|
# 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_linux-headers() {
|
|
pkgdesc="Header files and scripts for building modules for linux kernel"
|
|
|
|
cd ${_srcname}
|
|
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/x86" -m644 arch/x86/Makefile
|
|
install -Dt "${_builddir}/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
|
|
|
|
cp -t "${_builddir}/arch/x86" -a arch/x86/include
|
|
|
|
install -Dt "${_builddir}/drivers/md" -m644 drivers/md/*.h
|
|
install -Dt "${_builddir}/net/mac80211" -m644 net/mac80211/*.h
|
|
|
|
# http://bugs.archlinux.org/task/9912
|
|
install -Dt "${_builddir}/drivers/media/dvb-core" -m644 drivers/media/dvb-core/*.h
|
|
|
|
# http://bugs.archlinux.org/task/13146
|
|
install -Dt "${_builddir}/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/lgdt330x.h
|
|
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
|
|
if [[ ${_arch} != */x86/ ]]; then
|
|
rm -r "${_arch}"
|
|
fi
|
|
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)
|
|
}
|
|
|
|
package_linux-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 {} \;
|
|
}
|