updated on Wed Jan 11 12:00:27 UTC 2012
[aur-mirror.git] / linux-besrv / PKGBUILD
blob7806430de22bb9a9f73d04e120b7aa24f4d074be
1 # Maintainer: BlackEagle < ike DOT devolder AT gmail DOT com >
2 # Contributor: Tobias Powalowski <tpowa@archlinux.org>
3 # Contributor: Thomas Baechler <thomas@archlinux.org>
5 _kernelname=-besrv
6 pkgbase="linux${_kernelname}"
7 pkgname="linux${_kernelname}"
8 true && pkgname=("linux${_kernelname}" "linux${_kernelname}-headers")
9 _basekernel=3.1
10 pkgver=${_basekernel}
11 pkgrel=7
12 arch=('i686' 'x86_64')
13 license=('GPL2')
14 url="http://www.kernel.org"
15 options=(!strip)
17 source=(
18         "http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
19         # the main kernel config files
20         "config-${_basekernel}-server.i686"
21         "config-${_basekernel}-server.x86_64"
22         # standard config files for mkinitcpio ramdisk
23         "linux${_kernelname}.preset"
25 sha256sums=(
26         '6f220258f3ce9f11d0e53860ccc2d9fe746117056212099876dbe5ee1de80af3'
27         'ae1a1a734ff8b01e7f04aa7e52add925bb8e2da7880ac60e4a0ce2948b1e3894'
28         '83c483e99d52b71fbb261dea63cfb04cc54b35e8fd5d43d43016d229a4265520'
29         '64b2cf77834533ae7bac0c71936087857d8787d0e2a349037795eb7e42d23dde'
32 # extra patches
33 _extrapatches=(
34         "http://www.kernel.org/pub/linux/kernel/v3.x/patch-3.1.7.gz"
36 _extrapatchessums=(
37         'c9085ee65c1b9829e09cecc73229683c5f81d0a82b1e650ab12dba6aae615eca'
39 if [ ${#_extrapatches[@]} -ne 0 ]; then
40         source=( "${source[@]}"
41                 "${_extrapatches[@]}"
42         )
43         sha256sums=( "${sha256sums[@]}"
44                 "${_extrapatchessums[@]}"
45         )
48 # some stuff for the AUR parser :p
49 if [ "aur" == "there" ]; then
50         source=("ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
51                         "config-${_basekernel}-server.i686"
52                         "config-${_basekernel}-server.x86_64"
53                         "linux${_kernelname}.preset"
54         )
57 build() {
58         cd ${srcdir}/linux-${_basekernel}
60         # extra patches
61         for patch in ${_extrapatches[@]}; do
62                 patch=$(basename ${patch} | sed -e 's/\.\(gz\|bz2\|xz\)//')
63                 msg2 "apply ${patch}"
64                 patch -Np1 -i ${srcdir}/${patch} > /dev/null 2>&1
65         done
67         # set configuration
68         msg2 "copy configuration"
69         if [ "$CARCH" = "x86_64" ]; then
70                 cat ../config-${_basekernel}-server.x86_64 >./.config
71         else
72                 cat ../config-${_basekernel}-server.i686 >./.config
73         fi
74         if [ "${_kernelname}" != "" ]; then
75                 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"\U${_kernelname}\"|g" ./.config
76         fi
78         # remove sublevel, this is a server version, needs to be updateable
79         # without rebooting all the time
80         msg2 "remove sublevel"
81         sed -e "s|SUBLEVEL = .*|SUBLEVEL = |g" -i Makefile
83         # hack to prevent output kernel from being marked as dirty or git
84         msg2 "apply hack to prevent kernel tree being marked dirty"
85         echo "" > ${srcdir}/linux-${_basekernel}/.scmversion
87         # get kernel version
88         msg2 "prepare"
89         make prepare
90         # load configuration
91         # Configure the kernel. Replace the line below with one of your choice.
92         #make menuconfig # CLI menu for configuration
93         #make xconfig # X-based configuration
94         #make oldconfig # using old config from previous kernel version
95         # ... or manually edit .config
96         ####################
97         # stop here
98         # this is useful to configure the kernel
99         #msg "Stopping build"
100         #return 1
101         ####################
102         # yes "" | make config
103         # build!
104         msg2 "build"
105         make ${MAKEFLAGS} bzImage modules
108 package_linux-besrv() {
109         pkgdesc="The Linux Kernel and modules, BlackEagle Server Edition"
110         groups=('base')
111         provides=('linux' 'linux-firmware')
112         backup=(
113                 "etc/mkinitcpio.d/${pkgname}.preset"
114         )
115         depends=('coreutils' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.7')
116         optdepends=(
117                 'crda: to set the correct wireless channels of your country'
118         )
119         replaces=(
120                 'nouveau-drm' 'kernel26-slk' "kernel26${_kernelname}" "linux-bemm"
121         )
122         conflicts=('linux-firmware')
124         install=${pkgname}.install
126         KARCH=x86
127         cd ${srcdir}/linux-${_basekernel}
129         mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
131         # get kernel version
132         _kernver=$(make kernelrelease)
134         # install modules
135         make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=${pkgdir} modules_install
137         # copy System.map and bzImage
138         cp System.map ${pkgdir}/boot/System.map${_kernelname}
139         cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz${_kernelname}
141         # install fallback mkinitcpio.conf file and preset file for kernel
142         install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
144         # set correct depmod command for install
145         sed \
146                 -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
147                 -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
148                 -i $startdir/${pkgname}.install
149         sed \
150                 -e "s|source .*|source /etc/mkinitcpio.d/${pkgname}.kver|g" \
151                 -e "s|default_image=.*|default_image=\"/boot/initramfs${_kernelname}.img\"|g" \
152                 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs${_kernelname}-fallback.img\"|g" \
153                 -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
155         echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
157         # remove build and source links
158         rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
160         _fldkernelname=$(echo ${_kernelname} | tr "[:lower:]" "[:upper:]")
161         # make room for external modules
162         ln -s "../${_basekernel}${_fldkernelname}-external" "${pkgdir}/lib/modules/${_kernver}/external"
163         # add real version for building modules and running depmod from post_install/upgrade
164         mkdir -p "${pkgdir}/lib/modules/${_basekernel}${_fldkernelname}-external"
165         echo "${_kernver}" > "${pkgdir}/lib/modules/${_basekernel}${_fldkernelname}-external/version"
167         # gzip all modules
168         find ${pkgdir} -name '*.ko' -exec gzip -9 {} \;
171 package_linux-besrv-headers() {
172         pkgdesc="Header files and scripts for building modules for linux${_kernelname}"
173         provides=('linux-headers')
174         replaces=("kernel26${_kernelname}-headers" "linux-bemm-headers")
175         mkdir -p ${pkgdir}/lib/modules/${_kernver}
176         cd ${pkgdir}/lib/modules/${_kernver}
177         ln -sf ../../../usr/src/linux-${_kernver} build
178         cd ${srcdir}/linux-${_basekernel}
179         install -D -m644 Makefile \
180                 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
181         install -D -m644 kernel/Makefile \
182                 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
183         install -D -m644 .config \
184                 ${pkgdir}/usr/src/linux-${_kernver}/.config
186         # copy files necessary for later builds, like nvidia and vmware
187         cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
188         cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
189         # fix permissions on scripts dir
190         chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
191         mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
193         mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
195         cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
196         if [ "$CARCH" = "i686" ]; then
197                 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
198         fi
199         cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
201         # add docbook makefile
202         install -D -m644 Documentation/DocBook/Makefile \
203                 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
205         # add config
206         for config in `find ./include/config -size +1c -type f`; do
207                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${config})
208                 cp -a ${config} ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${config})
209         done
211         # add headers
212         for header in `find -size +1c -name '*.h'`; do
213                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${header})
214                 cp -a ${header} ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${header})
215         done
217         # copy in Kconfig files
218         for i in `find . -name "Kconfig*"`; do
219                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
220                 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
221         done
223         # strip scripts directory
224         find ${pkgdir}/usr/src/linux-${_kernver}/scripts  -type f -perm -u+w 2>/dev/null | while read binary ; do
225                 case "$(file -bi "$binary")" in
226                         *application/x-sharedlib*) # Libraries (.so)
227                                 /usr/bin/strip $STRIP_SHARED "$binary"
228                         ;;
229                         *application/x-archive*) # Libraries (.a)
230                                 /usr/bin/strip $STRIP_STATIC "$binary"
231                         ;;
232                         *application/x-executable*) # Binaries
233                                 /usr/bin/strip $STRIP_BINARIES "$binary"
234                         ;;
235                 esac 
236         done
238         chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
239         find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
240         # remove unneeded architectures
241         rm -rf ${pkgdir}/usr/src/linux-${_kernver}/arch/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,score,sh,sh64,sparc,sparc64,tile,um,v850,xtensa}
243 pkgdesc="The Linux Kernel and modules, BlackEagle Server Edition"