PKGBUILD 12.5 KB
Newer Older
philm's avatar
philm committed
1 2 3
#
# Core Packages for Chakra, part of chakra-project.org
#
4 5
# maintainer abveritas[at]chakra-project[dog]org>
# maintainer Manuel Tortosa <manutortosa[at]chakra-project[dot]org>
philm's avatar
philm committed
6

7
pkgbase=linux
8
pkgname=('linux' 'linux-headers' 'linux-docs') 
philm's avatar
philm committed
9
_kernelname=${pkgname#linux}
abveritas's avatar
abveritas committed
10
_basekernel=3.7
11
pkgver=3.7.6
abveritas's avatar
abveritas committed
12
pkgrel=2
13
arch=('x86_64')
14
url="http://www.kernel.org/"
philm's avatar
philm committed
15
license=('GPL2')
16 17
makedepends=('xmlto' 'docbook-xsl')
options=('!strip')
abveritas's avatar
abveritas committed
18
source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-3.7.tar.xz"
19
        "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
philm's avatar
philm committed
20
        # the main kernel config files
21
        'config.x86_64'
22 23 24 25 26 27 28 29
        #aufs patches
        'aufs3-loopback.patch'
        'aufs3-base.patch'
        'aufs3-proc_map.patch'
        'aufs3-standalone.patch'
        'aufs3-kbuild.patch'
        'aufs3.patch'
        'config.aufs'
philm's avatar
philm committed
30
        # standard config files for mkinitcpio ramdisk
31
        'linux.preset'
32
        'change-default-console-loglevel.patch'
abveritas's avatar
abveritas committed
33
        'fat-3.6.x.patch'
abveritas's avatar
abveritas committed
34
        'sp5100_tco-Add-SB8x0-chipset-support2.patch'
abveritas's avatar
abveritas committed
35 36
        'ath3k.patch'
        'security.patch')
abveritas's avatar
abveritas committed
37
md5sums=('21223369d682bcf44bcdfe1521095983'
38
         'ec61c44f37585a768d41c0439101ef9c'
39
         '05befa9b6c2a91015f89d6cda6802198'
abveritas's avatar
abveritas committed
40 41 42 43 44 45
         '2e33819e859125ba0176072d2cd5ac81'
         '6a1ffafeacb79be96c97e4638cea2452'
         '3074dfe1c01219b1b005a4e5f00e25cd'
         'f18131bd568796722284557193c3a3c0'
         'cd0a193e702bf4d607190e5249c67da8'
         '35a09afd2e995a88d36c342ade093c27'
46
         '52f4a2c7f6277774117c834d949d6b81'
47 48
         'eb14dcfd80c00852ef81ded6e826826a'
         '65cbe8e4c8efaf96dd162102e46ce81d'
abveritas's avatar
abveritas committed
49
         '88d501404f172dac6fcb248978251560'
abveritas's avatar
abveritas committed
50
         '57ee9aa09bdec07a5ce2b553b94c7039'
abveritas's avatar
abveritas committed
51 52
         'd393a0bbd762bf9d6f42d770b89e6811'
         'fc4928d107d638bb106901f1bfedd684')
philm's avatar
philm committed
53 54

build() {
55
  cd "${srcdir}/linux-${_basekernel}"
philm's avatar
philm committed
56

57
  # add upstream patch
58
  patch -p1 -i "${srcdir}/patch-${pkgver}"
59 60 61 62

  # add latest fixes from stable queue, if needed
  # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git

abveritas's avatar
abveritas committed
63 64
  # fix cosmetic fat issue
  patch -p1 -i "${srcdir}/fat-3.6.x.patch"
abveritas's avatar
abveritas committed
65
  # "kernel: sp5100_tco: mmio address 0xfec000f0 already in use" error
abveritas's avatar
abveritas committed
66
  # https://bugzilla.kernel.org/show_bug.cgi?id=43176
67
  #patch -p1 -i "${srcdir}/sp5100_tco-Add-SB8x0-chipset-support2.patch"
abveritas's avatar
abveritas committed
68 69
  # bug http://chakra-linux.org/bugs/index.php?do=details&task_id=501
  patch -p1 -i "${srcdir}/ath3k.patch"
abveritas's avatar
abveritas committed
70 71 72 73
  # Fix out-of-bounds access to sock_diag_handlerscurrent, code does not test for
  # this condition therefore is vulnerable to an out-of-bound access opening doors
  # for a privilege escalation
  patch -p1 -i "${srcdir}/security.patch"
74 75 76 77

  # 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)
78 79 80
  patch -p1 -i "${srcdir}/change-default-console-loglevel.patch"

  #aufs patches for Live:
81
  patch -p1 -i "${srcdir}/aufs3.patch"
82
  patch -p1 -i "${srcdir}/aufs3-base.patch"
83 84
  patch -p1 -i "${srcdir}/aufs3-kbuild.patch"
  patch -p1 -i "${srcdir}/aufs3-loopback.patch"
85 86
  patch -p1 -i "${srcdir}/aufs3-proc_map.patch"
  patch -p1 -i "${srcdir}/aufs3-standalone.patch"
87
  
88
  cat "${srcdir}/config.x86_64" > ./.config
89

90
  cat "${srcdir}/config.aufs" >> ./.config
91

philm's avatar
philm committed
92 93 94
  if [ "${_kernelname}" != "" ]; then
    sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  fi
Phil's avatar
Phil committed
95

96 97 98
  # set extraversion to pkgrel
  sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile

Phil's avatar
Phil committed
99
  # get kernel version
philm's avatar
philm committed
100
  make prepare
Phil's avatar
Phil committed
101

philm's avatar
philm committed
102 103 104 105 106 107 108
  # 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
109 110 111
  
  # rewrite configuration
  yes "" | make config >/dev/null
Phil's avatar
Phil committed
112

philm's avatar
philm committed
113 114 115 116 117 118
  ####################
  # stop here
  # this is useful to configure the kernel
  #msg "Stopping build"
  #return 1
  ####################
Phil's avatar
Phil committed
119

philm's avatar
philm committed
120
  # build!
121
  make ${MAKEFLAGS} bzImage modules
philm's avatar
philm committed
122 123 124 125 126
}

package_linux() {
  pkgdesc="The Linux Kernel and modules"
  groups=('base')
127
  depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
philm's avatar
philm committed
128
  optdepends=('crda: to set the correct wireless channels of your country')
129 130 131
  provides=('nouveau-drm' 'kernel26' 'acerhk=0.5.35' 'aufs3')
  conflicts=('kernel26' 'nvidia-96xx=96.43.20-9' 'acerhk')
  replaces=('kernel26' 'aufs3' 'nouveau-drm')
philm's avatar
philm committed
132
  backup=("etc/mkinitcpio.d/${pkgname}.preset")
133
  install=linux.install
philm's avatar
philm committed
134 135 136 137 138 139

  cd "${srcdir}/linux-${_basekernel}"

  KARCH=x86

  # get kernel version
140
  _kernver="$(make kernelrelease)"
philm's avatar
philm committed
141 142

  mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
143
  make INSTALL_MOD_PATH="${pkgdir}" modules_install
philm's avatar
philm committed
144 145 146 147 148 149
  cp arch/$KARCH/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgname}"

  # add vmlinux
  install -D -m644 vmlinux "${pkgdir}/usr/src/linux-${_kernver}/vmlinux"

  # install fallback mkinitcpio.conf file and preset file for kernel
150
  install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/linux.preset"
philm's avatar
philm committed
151 152 153

  # set correct depmod command for install
  sed \
154 155 156
    -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
    -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
    -i "${startdir}/linux.install"
philm's avatar
philm committed
157
  sed \
158 159 160 161 162
    -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.preset"
philm's avatar
philm committed
163 164 165 166 167

  # remove build and source links
  rm -f "${pkgdir}"/lib/modules/${_kernver}/{source,build}
  # remove the firmware
  rm -rf "${pkgdir}/lib/firmware"
Phil's avatar
Phil committed
168
  # gzip -9 all modules to save 100MB of space
philm's avatar
philm committed
169
  find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
Phil's avatar
Phil committed
170
  # make room for external modules
abveritas's avatar
abveritas committed
171
  ln -s "../extramodules-${_basekernel}${_kernelname:--CHAKRA}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
Phil's avatar
Phil committed
172
  # add real version for building modules and running depmod from post_install/upgrade
abveritas's avatar
abveritas committed
173 174
  mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}"
  echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}/version"
175
  
philm's avatar
philm committed
176 177 178 179 180 181 182 183
}

package_linux-headers() {
  pkgdesc="Header files and scripts for building modules for linux kernel"
  provides=('kernel26-headers')
  conflicts=('kernel26-headers')
  replaces=('kernel26-headers')

abveritas's avatar
abveritas committed
184
  install -dm755 "${pkgdir}/lib/modules/${_kernver}"
philm's avatar
philm committed
185

abveritas's avatar
abveritas committed
186 187
  cd "${pkgdir}/lib/modules/${_kernver}"
  ln -sf ../../../usr/src/linux-${_kernver} build
philm's avatar
philm committed
188 189 190 191 192 193 194 195 196 197 198 199

  cd "${srcdir}/linux-${_basekernel}"
  install -D -m644 Makefile \
    "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
  install -D -m644 kernel/Makefile \
    "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
  install -D -m644 .config \
    "${pkgdir}/usr/src/linux-${_kernver}/.config"

  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"

  for i in acpi asm-generic config crypto drm generated linux math-emu \
abveritas's avatar
abveritas committed
200
    media net pcmcia scsi sound trace uapi video xen; do
philm's avatar
philm committed
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
    cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
  done

  # copy arch includes for external modules
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
  cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"

  # copy files necessary for later builds, like nvidia and vmware
  cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
  cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"

  # fix permissions on scripts dir
  chmod og-w -R "${pkgdir}/usr/src/linux-${_kernver}/scripts"
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions"

  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel"

  cp arch/${KARCH}/Makefile "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/"

  cp arch/${KARCH}/kernel/asm-offsets.s "${pkgdir}/usr/src/linux-${_kernver}/arch/${KARCH}/kernel/"

  # add headers for lirc package
abveritas's avatar
abveritas committed
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
  # pci
  for i in bt8xx cx88 saa7134; do
    mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/pci/${i}"
    cp -a drivers/media/pci/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/pci/${i}"
  done
  # usb
  for i in cpia2 em28xx pwc sn9c102; do
    mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/${i}"
    cp -a drivers/media/usb/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/${i}"
  done
  # i2c
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c"
  cp drivers/media/i2c/*.h  "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/"
  for i in cx25840; do
    mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/${i}"
    cp -a drivers/media/i2c/${i}/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/${i}"
philm's avatar
philm committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
  done

  # add docbook makefile
  install -D -m644 Documentation/DocBook/Makefile \
    "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"

  # add dm headers
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"
  cp drivers/md/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/md"

  # add inotify.h
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/linux"
  cp include/linux/inotify.h "${pkgdir}/usr/src/linux-${_kernver}/include/linux/"

  # add wireless headers
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"
  cp net/mac80211/*.h "${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/"

  # add dvb headers for external modules
abveritas's avatar
abveritas committed
258 259
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-core"
  cp drivers/media/dvb-core/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-core/"
philm's avatar
philm committed
260 261 262 263 264
  # and...
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"
  cp include/config/dvb/*.h "${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/"

  # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
abveritas's avatar
abveritas committed
265 266 267
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  cp drivers/media/dvb-frontends/lgdt330x.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  cp drivers/media/i2c/msp3400-driver.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/i2c/"
philm's avatar
philm committed
268 269

  # add dvb headers
abveritas's avatar
abveritas committed
270 271 272 273 274 275
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/dvb-usb"
  cp drivers/media/usb/dvb-usb/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/usb/dvb-usb/"
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends"
  cp drivers/media/dvb-frontends/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb-frontends/"
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/tuners"
  cp drivers/media/tuners/*.h "${pkgdir}/usr/src/linux-${_kernver}/drivers/media/tuners/"
philm's avatar
philm committed
276 277 278 279 280 281

  # add xfs and shmem for aufs building
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
  cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"

282 283 284
  #aufs3-util need
  sed -i "s:__user::g" "${pkgdir}/usr/src/linux-${_kernver}/include/linux/aufs_type.h"

philm's avatar
philm committed
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
  # copy in Kconfig files
  for i in `find . -name "Kconfig*"`; do
    mkdir -p "${pkgdir}"/usr/src/linux-${_kernver}/`echo ${i} | sed 's|/Kconfig.*||'`
    cp ${i} "${pkgdir}/usr/src/linux-${_kernver}/${i}"
  done

  chown -R root.root "${pkgdir}/usr/src/linux-${_kernver}"
  find "${pkgdir}/usr/src/linux-${_kernver}" -type d -exec chmod 755 {} \;

  # strip scripts directory
  find "${pkgdir}/usr/src/linux-${_kernver}/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
307
  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}
philm's avatar
philm committed
308 309 310 311 312 313 314 315 316 317 318
}

package_linux-docs() {
  pkgdesc="Kernel hackers manual - HTML documentation that comes with the Linux kernel."
  provides=('kernel26-docs')
  conflicts=('kernel26-docs')
  replaces=('kernel26-docs')

  cd "${srcdir}/linux-${_basekernel}"

  mkdir -p "${pkgdir}/usr/src/linux-${_kernver}"
Phil's avatar
Phil committed
319
  cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}"
philm's avatar
philm committed
320 321 322 323 324 325
  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/src/linux-${_kernver}/Documentation/DocBook/Makefile"
}