aboutsummaryrefslogtreecommitdiff
# Contributor: Wojtek Kosior <kwojtus@protonmail.com>

# Loosely based on Hyperbola's linux-libre-lts package

_kernelname=linux-libre-lts
pkgname=${_kernelname}-source
_pkgbasever=4.9-gnu
_pkgver=${_pkgbasever%-*}.176-gnu


_srcname=linux-${_pkgbasever%-*}
pkgver=${_pkgver//-/_}
pkgrel=1
pkgdesc="Source of the Linux-libre kernel - Long Term Support (LTS)"
arch=('any')
url="https://linux-libre.fsfla.org/"
license=('GPL-2')
source=("https://linux-libre.fsfla.org/pub/linux-libre/releases/${_pkgbasever}/linux-libre-${_pkgbasever}.tar.xz"{,.sign}
        "https://linux-libre.fsfla.org/pub/linux-libre/releases/${_pkgver}/patch-${_pkgbasever}-${_pkgver}.xz"{,.sign}
        'change-default-console-loglevel.patch'
        'radeon_hack.patch'
        '0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch'
        '0002-fix-Atmel-maXTouch-touchscreen-support.patch')
sha512sums=('885eb0a7fab45dc749acb4329b4330a43b704df2d5f2f5aac1811503c132ca53ca49452f9b1cc80b0826c7a4962dbe4937aecb697aa823b2543ba2cabc704816'
            'SKIP'
            '2c92d52f33ecb1d5c6aa26a0b14b022f6908c4fa69d8ab52475fb11405fcbc890bb4d7f688936f8458c35d596e3b818e4632b7669e177f527247117c1934d47e'
            'SKIP'
            'd9d28e02e964704ea96645a5107f8b65cae5f4fb4f537e224e5e3d087fd296cb770c29ac76e0ce95d173bc420ea87fb8f187d616672a60a0cae618b0ef15b8c8'
            'f4c6deb6f3f7467ba4de303542d9c786287caeab7ef7bbd976056fc9c4fae3469884cae0f44533c6d86022d9887176b90e654ffd5b68dbe10ce465d303712357'
            '02af4dd2a007e41db0c63822c8ab3b80b5d25646af1906dc85d0ad9bb8bbf5236f8e381d7f91cf99ed4b0978c50aee37cb9567cdeef65b7ec3d91b882852b1af'
            'b8fe56e14006ab866970ddbd501c054ae37186ddc065bb869cf7d18db8c0d455118d5bda3255fb66a0dde38b544655cfe9040ffe46e41d19830b47959b2fb168')
validpgpkeys=('474402C8C582DAFBE389C427BCB7CF877E7D47A7')  # Alexandre Oliva

noextract=("linux-libre-${_pkgbasever}.tar.xz" "patch-${_pkgbasever}-${_pkgver}.xz")

prepare() {
  cd "${srcdir}/"
  
  # Here we create script to be used for unpacking the sources we'll install.
  # This scripts assumes patches went to /usr/src/${_kernelname}/patches
  echo -n "\
#!/bin/sh

mkdir -p \"\$1\" && cd \"\$1\"

bsdtar -xf /usr/src/${_kernelname}/linux-libre-${_pkgbasever}.tar.xz

cd ${_srcname}

# add upstream patch
xzcat /usr/src/${_kernelname}/patches/patch-${_pkgbasever}-${_pkgver}.xz | patch -p1

# Hyperbola's PKGBUILD mentions possibility of adding latest fixes from stable queue.
# Idk how this works, so I just leave the link:
# http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git

# set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
# remove this when a Kconfig knob is made available by upstream
# (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
patch -p1 -i /usr/src/${_kernelname}/patches/change-default-console-loglevel.patch

# hack to enable Radeon R600 evergreen GPUs
# https://www.fsfla.org/pipermail/linux-libre/2016-July/003224.html
patch -p1 -i /usr/src/${_kernelname}/patches/radeon_hack.patch

# maintain the TTY over USB disconnects
# http://www.coreboot.org/EHCI_Gadget_Debug
patch -p1 -i /usr/src/${_kernelname}/patches/0001-usb-serial-gadget-no-TTY-hangup-on-USB-disconnect-WI.patch

# fix Atmel maXTouch touchscreen support
# https://labs.parabola.nu/issues/877
# http://www.fsfla.org/pipermail/linux-libre/2015-November/003202.html
patch -p1 -i /usr/src/${_kernelname}/patches/0002-fix-Atmel-maXTouch-touchscreen-support.patch
" > prepare-linux-libre-lts-source
}

package() {
    install -m755 -d ${pkgdir}/usr/src/${_kernelname}/patches

    # install patches
    cd ${srcdir}
    install -m644 *.patch patch-${_pkgbasever}-${_pkgver}.xz \
	    ${pkgdir}/usr/src/${_kernelname}/patches/
    
    #install tarball
    install -m644 linux-libre-${_pkgbasever}.tar.xz 	    ${pkgdir}/usr/src/${_kernelname}/

    # install our script
    install -m755 -d ${pkgdir}/usr/bin
    install -m755 ${srcdir}/prepare-linux-libre-lts-source ${pkgdir}/usr/bin
}