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

6
pkgbase=linux
7
pkgname=('linux' 'linux-headers' 'linux-docs') 
philm's avatar
philm committed
8
_kernelname=${pkgname#linux}
Manuel's avatar
Manuel committed
9
_basekernel=3.9
Manuel's avatar
Manuel committed
10
pkgver=3.9.2
Manuel's avatar
Manuel committed
11
pkgrel=1
12
arch=('x86_64')
13
url="http://www.kernel.org/"
philm's avatar
philm committed
14
license=('GPL2')
15 16
makedepends=('xmlto' 'docbook-xsl')
options=('!strip')
Manuel's avatar
Manuel committed
17
source=("http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
Manuel's avatar
Manuel committed
18
        "http://www.kernel.org/pub/linux/kernel/v3.x/patch-${pkgver}.xz"
philm's avatar
philm committed
19
        # the main kernel config files
20
        'config.x86_64'
21 22 23 24 25 26 27 28
        #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
29
        # standard config files for mkinitcpio ramdisk
30
        'linux.preset'
Manuel's avatar
Manuel committed
31
        'change-default-console-loglevel.patch')
Manuel's avatar
Manuel committed
32
md5sums=('4348c9b6b2eb3144d601e87c19d5d909'
Manuel's avatar
Manuel committed
33 34 35 36 37 38 39 40
         'adeb2556568f79e827e7a0ce4c483605'
         '698318024a36e40b4d44eac67c3a7ecd'
         '89fbb605ef398297b8dc43409c849c92'
         'd5f57f666f02ca25ba298210e2332ce8'
         'cf2ad9065886e56698524eab323ac656'
         '460247f1b4da5dccdaacfa6d161131f0'
         '498abc1e34df8a7d19e43980c74f2bc2'
         '3ce07d164880e16ae622d1dadb6e5b7a'
41
         '52f4a2c7f6277774117c834d949d6b81'
42
         'eb14dcfd80c00852ef81ded6e826826a'
Manuel's avatar
Manuel committed
43
         '65cbe8e4c8efaf96dd162102e46ce81d')
philm's avatar
philm committed
44 45

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

48
  # add upstream patch
Manuel's avatar
Manuel committed
49
  patch -p1 -i "${srcdir}/patch-${pkgver}"
50 51 52 53 54 55 56

  # add latest fixes from stable queue, if needed
  # 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)
57 58 59
  patch -p1 -i "${srcdir}/change-default-console-loglevel.patch"

  #aufs patches for Live:
60
  patch -p1 -i "${srcdir}/aufs3.patch"
61
  patch -p1 -i "${srcdir}/aufs3-base.patch"
62 63
  patch -p1 -i "${srcdir}/aufs3-kbuild.patch"
  patch -p1 -i "${srcdir}/aufs3-loopback.patch"
64 65
  patch -p1 -i "${srcdir}/aufs3-proc_map.patch"
  patch -p1 -i "${srcdir}/aufs3-standalone.patch"
66
  
67
  cat "${srcdir}/config.x86_64" > ./.config
68

69
  cat "${srcdir}/config.aufs" >> ./.config
70

philm's avatar
philm committed
71 72 73
  if [ "${_kernelname}" != "" ]; then
    sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
  fi
Phil's avatar
Phil committed
74

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

Phil's avatar
Phil committed
78
  # get kernel version
philm's avatar
philm committed
79
  make prepare
Phil's avatar
Phil committed
80

philm's avatar
philm committed
81 82 83 84 85 86 87
  # 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
88 89 90
  
  # rewrite configuration
  yes "" | make config >/dev/null
Phil's avatar
Phil committed
91

philm's avatar
philm committed
92 93 94 95 96 97
  ####################
  # stop here
  # this is useful to configure the kernel
  #msg "Stopping build"
  #return 1
  ####################
Phil's avatar
Phil committed
98

philm's avatar
philm committed
99
  # build!
100
  make ${MAKEFLAGS} bzImage modules
philm's avatar
philm committed
101 102 103 104 105
}

package_linux() {
  pkgdesc="The Linux Kernel and modules"
  groups=('base')
106
  depends=('coreutils' 'linux-firmware' 'kmod' 'mkinitcpio>=0.7')
philm's avatar
philm committed
107
  optdepends=('crda: to set the correct wireless channels of your country')
108
  provides=('nouveau-drm' 'kernel26' 'acerhk=0.5.35' 'aufs3')
Manuel's avatar
Manuel committed
109
  conflicts=('kernel26' 'nvidia-96xx=96.43.20-9' 'acerhk' 'tiacx')
110
  replaces=('kernel26' 'aufs3' 'nouveau-drm')
philm's avatar
philm committed
111
  backup=("etc/mkinitcpio.d/${pkgname}.preset")
112
  install=linux.install
philm's avatar
philm committed
113 114 115 116 117 118

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

  KARCH=x86

  # get kernel version
119
  _kernver="$(make kernelrelease)"
philm's avatar
philm committed
120 121

  mkdir -p "${pkgdir}"/{lib/modules,lib/firmware,boot}
122
  make INSTALL_MOD_PATH="${pkgdir}" modules_install
philm's avatar
philm committed
123 124 125 126 127 128
  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
129
  install -D -m644 "${srcdir}/linux.preset" "${pkgdir}/etc/mkinitcpio.d/linux.preset"
philm's avatar
philm committed
130 131 132

  # set correct depmod command for install
  sed \
133 134 135
    -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/" \
    -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" \
    -i "${startdir}/linux.install"
philm's avatar
philm committed
136
  sed \
137 138 139 140 141
    -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
142 143 144 145 146

  # 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
147
  # gzip -9 all modules to save 100MB of space
philm's avatar
philm committed
148
  find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
Phil's avatar
Phil committed
149
  # make room for external modules
abveritas's avatar
abveritas committed
150
  ln -s "../extramodules-${_basekernel}${_kernelname:--CHAKRA}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
Phil's avatar
Phil committed
151
  # add real version for building modules and running depmod from post_install/upgrade
abveritas's avatar
abveritas committed
152 153
  mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}"
  echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname:--CHAKRA}/version"
154
  
philm's avatar
philm committed
155 156 157 158 159 160 161 162
}

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
163
  install -dm755 "${pkgdir}/lib/modules/${_kernver}"
philm's avatar
philm committed
164

abveritas's avatar
abveritas committed
165 166
  cd "${pkgdir}/lib/modules/${_kernver}"
  ln -sf ../../../usr/src/linux-${_kernver} build
philm's avatar
philm committed
167 168 169 170 171 172 173 174 175 176 177 178

  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
179
    media net pcmcia scsi sound trace uapi video xen; do
philm's avatar
philm committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
    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
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
  # 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
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
  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
237 238
  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
239 240 241 242 243
  # 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
244 245 246
  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
247 248

  # add dvb headers
abveritas's avatar
abveritas committed
249 250 251 252 253 254
  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
255 256 257 258 259 260

  # 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"

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

philm's avatar
philm committed
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
  # 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
286
  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
287 288 289 290 291 292 293 294 295 296 297
}

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
298
  cp -al Documentation "${pkgdir}/usr/src/linux-${_kernver}"
philm's avatar
philm committed
299 300 301 302 303
  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"
Manuel's avatar
Manuel committed
304
}