Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Maintainer: Matt Parnell/ilikenwf <parwok@gmail.com>
- # PKGBUILD Writer: Patrick Bartels <p4ddy.b@gmail.com>
- # Uncomment the line below if you want to maintain the git tree yourself.
- _no_update="y"
- # AUR workaround...
- pkgname="linux-next"
- true && pkgbase="linux-next"
- true && pkgname=("linux-next" "linux-next-headers")
- pkgver=3.11
- pkgrel=1
- pkgdesc="Linux-Next kernel from git - use yaourt -G or store the build directory somewhere to keep a git repo."
- url="http://www.kernel.org"
- license=("GPL2")
- arch=("i686" "x86_64")
- makedepends=("git")
- options=("!strip")
- source=(linux-next.conf
- linux-next.preset)
- md5sums=('ccec126fa0bfce4222a526ca02cf2de8'
- '26dbd49508006ebdd52ab6cade09c330')
- _gitroot="https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
- _gitname="linux-next"
- declare _builddir
- declare _sourcedir
- declare _kernver
- # compress the modules with gzip or not
- _compress="y"
- fetch_sources() {
- if [ ! -d "$_gitname" ]; then
- cd "$srcdir"
- msg2 "Cloning initial copy of linux-next..."
- warning "This may take some time depending on your available bandwidth."
- git clone --depth 1 "$_gitroot" "$_gitname"
- _no_update="y" # update is not necessary
- fi
- if [ "$_no_update" = "y" ]; then
- msg2 "Skipping tree update..."
- else
- cd "$srcdir/$_gitname"
- msg2 "Updating local tree..."
- if git fetch; then
- msg2 "Attempting to merge changes..."
- if ! git merge origin/master; then
- error "Merging failed..."
- msg2 "Fixing local repository..."
- git checkout -f "matt-playground"
- git clean -xdf
- git reset --hard "origin/master"
- fi
- else
- error "Update failed..."
- fi
- warning "Press ENTER if you want to continue or CTRL+C to abort..."
- read
- fi
- }
- build() {
- fetch_sources
- _builddir="$srcdir/build"
- _sourcedir="$srcdir/$_gitname/"
- # don't run depmod on 'make install'. We'll do this ourselves in packaging
- sed -i '2iexit 0' $_sourcedir/scripts/depmod.sh
- if [ -e "$_builddir/.config" ]; then
- msg2 "Using existing config found in build environment..."
- else
- if [ ! -d "$_builddir" ]; then
- msg2 "Creating build directory..."
- mkdir -p "$_builddir"
- fi
- msg2 "Creating default config..." # also initializes the output directory
- make -C "$_sourcedir" O="$_builddir" defconfig > /dev/null
- warning "This package does not ship a kernel config."
- plain ""
- warning "Thus it is up to you to create a one that fits your needs."
- warning "Navigate to '$_builddir'"
- warning "and either run 'make menuconfig' or if you want to use an existing config,"
- warning "save it as '.config' and run 'make oldconfig' in order to update it."
- warning "Having done that you can run 'makepkg' again."
- plain ""
- return 1
- fi
- msg2 "Updating output directory Makefile..."
- make -C "$_sourcedir" O="$_builddir" outputmakefile
- warning "Press ENTER if you want to build the kernel or CTRL+C to abort..."
- read
- # Number of CPU Cores
- _CORES=$(cat /proc/cpuinfo|grep processor|wc -l)
- if [ $_CORES -lt 1 ]; then
- _CORES=1
- fi
- cd "$_builddir"
- msg2 "Building kernel..."; make -j $_CORES bzImage
- msg2 "Building modules..."; make -j $_CORES modules
- }
- package_linux-next() {
- depends=("coreutils" "linux-firmware" "kmod" "mkinitcpio>=0.5.20")
- optdepends=("linux-next-headers: to build third party modules such as NVIDIA drivers or OSSv4"
- "crda: to set the correct wireless channels of your country")
- backup=(etc/mkinitcpio.d/linux-next.conf)
- install=linux-next.install
- _builddir="$srcdir/build/"
- _sourcedir="$srcdir/$_gitname/"
- msg2 "Determining kernel name..."
- cd "$_sourcedir"
- _kernver="$(make O="$_builddir" kernelrelease)"
- msg2 "Kernel release name is: $_kernver"
- cd "$_builddir"
- msg2 "Installing kernel image..."
- install -D -m644 "arch/x86/boot/bzImage" "$pkgdir/boot/vmlinuz-linux-next"
- msg2 "Installing modules (and firmware files)..."
- make INSTALL_MOD_PATH="$pkgdir" modules_install
- if [ -d "$pkgdir/lib/firmware" ]; then
- msg2 "Removing firmware files..."
- rm -r "$pkgdir/lib/firmware"
- fi
- if [ $_compress = "y" ]; then
- msg2 "Compressing kernel modules with gzip..."
- find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
- fi
- # make room for external modules
- if [ -d "${pkgdir}/lib/modules/extramodules-*" ]; then
- rmdir "${pkgdir}/lib/modules/extramodules-*" &> /dev/null
- fi
- ln -s "../extramodules-${_kernver}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
- # add real version for building modules and running depmod from post_install/upgrade
- mkdir -p "${pkgdir}/lib/modules/extramodules-${_kernver}"
- echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_kernver}/version"
- msg2 "Installing System.map..."
- install -m644 "System.map" "$pkgdir/boot/System.map-next"
- msg2 "Removing links to source and build directory..."
- rm "$pkgdir/lib/modules/$_kernver/"{build,source}
- msg2 "Updating kernel version in install script..."
- sed -i "s/_kernel_version=.*/_kernel_version=$_kernver/" \
- "$startdir/linux-next.install"
- msg2 "Installing files for mkinitcpio..."
- install -D -m644 "$srcdir/linux-next.conf" \
- "$pkgdir/etc/mkinitcpio.d/linux-next.conf"
- install -D -m644 "$srcdir/linux-next.preset" \
- "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
- sed -i "s/^ALL_kver=.*$/ALL_kver=$_kernver/" \
- "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
- # move module tree /lib -> /usr/lib
- mkdir -p "$pkgdir/usr/lib"
- mv -v "$pkgdir/lib" "$pkgdir/usr/"
- # Now we call depmod...
- depmod -b "$pkgdir/usr/" -F System.map "$_kernver"
- }
- package_linux-next-headers() {
- # AUR workaround
- true && pkgdesc="Header files and scripts for building modules for linux-next"
- true && depends=("linux-next")
- true && provides=("linux-headers")
- _builddir="$srcdir/build"
- _sourcedir="$srcdir/$_gitname"
- cd "$_sourcedir"
- _kernver="$(make O="$_builddir" kernelrelease)"
- _srcdir="/usr/src/linux-$_kernver"
- msg2 "Installing files necessary for 3rd party modules such as NVIDIA drivers or OSSv4..."
- mkdir -p "$pkgdir$_srcdir/"{arch/x86,include}
- echo "$pkgdir$_srcdir/"
- install -D -m644 "$_sourcedir/Makefile" "$pkgdir/$_srcdir/Makefile"
- install -D -m644 "$_sourcedir/kernel/Makefile" "$pkgdir/$_srcdir/kernel/Makefile"
- install -D -m644 "$_builddir/.config" "$pkgdir/$_srcdir/.config"
- install -D -m644 "$_builddir/Module.symvers" "$pkgdir/$_srcdir/Module.symvers"
- install -D -m644 "$_builddir/include/generated/uapi/linux/version.h" "$pkgdir/$_srcdir/include/linux/version.h"
- install -D -m644 "$_builddir/arch/x86/kernel/asm-offsets.s" "$pkgdir/$_srcdir/arch/x86/kernel/asm-offsets.s"
- install -D -m644 "$_sourcedir/arch/x86/Makefile" "$pkgdir/$_srcdir/arch/x86/Makefile"
- if [ "$CARCH" = "i686" ]; then
- install -D -m644 "$_sourcedir/arch/x86/Makefile_32.cpu" "$pkgdir/$_srcdir/arch/x86/Makefile_32.cpu"
- fi
- cp -a "$_sourcedir/scripts" "$pkgdir/$_srcdir"
- cp -a "$_builddir/scripts" "$pkgdir/$_srcdir"
- cp -a "$_sourcedir/include" "$pkgdir/$_srcdir"
- cp -a "$_builddir/include/"{generated,config} "$pkgdir/$_srcdir/include"
- cp -a "$_sourcedir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
- cp -a "$_builddir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
- cd "$_sourcedir"
- {
- find drivers -type f -name "*.h";
- find . -type f -name "Kconfig*";
- } | while read file; do
- install -D -m644 "$file" "$pkgdir/$_srcdir/$file"
- done
- msg2 "Fixing permissions on scripts directory..."
- chmod og-w -R "$pkgdir/$_srcdir/scripts"
- msg2 "Creating symlinks..."
- mkdir -p "$pkgdir/lib/modules/$_kernver/"
- ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/build"
- ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/source"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement