updated on Fri Jan 13 16:00:36 UTC 2012
[aur-mirror.git] / linux-bede / PKGBUILD
blob42808af5670ac288e1363ee6bd8825bee2a31832
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=-bede
6 pkgbase="linux${_kernelname}"
7 pkgname="linux${_kernelname}"
8 true && pkgname=("linux${_kernelname}" "linux${_kernelname}-headers")
9 _basekernel=3.2
10 _patchver=0
11 pkgver=${_basekernel}
12 pkgrel=3
13 arch=('i686' 'x86_64')
14 license=('GPL2')
15 url="http://www.kernel.org"
16 options=(!strip)
18 source=(
19         "http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
20         # the main kernel config files
21         "config-${_basekernel}-desktop.i686"
22         "config-${_basekernel}-desktop.x86_64"
23         # standard config files for mkinitcpio ramdisk
24         "linux${_kernelname}.preset"
25         # sysctl updates for desktop usage picked up from opensuse
26         "sysctl-desktop.i686"
27         "sysctl-desktop.x86_64"
29 sha256sums=(
30         'dd96ed02b53fb5d57762e4b1f573460909de472ca588f81ec6660e4a172e7ba7'
31         'a34d983842bc66395596539470cc3f9d0b42695c9a6b6cd8fd7f96c6783d40e2'
32         'd1b6ca5414cbe579ed27a9744ecf7aae30523b2844afb5500a0cc7c4ad9e9a43'
33         'd5bb4aabbd556f8a3452198ac42cad6ecfae020b124bcfea0aa7344de2aec3b5'
34         'cce2cd65f49ef30e9f2c977210fcb3f21707b53088615eb737e2bb53c67ca7c9'
35         '5d59b290f2ec7354048e24cc52048e104fa91a3ac4c393adbb0e268c129d03e2'
38 # revision patches
39 if [ ${_patchver} -ne 0 ]; then
40         pkgver=${_basekernel}.${_patchver}
41         _patchname="patch-${pkgver}"
42         source=( "${source[@]}"
43                 "http://www.kernel.org/pub/linux/kernel/v3.x/${_patchname}.gz"
44         )
45         sha256sums=( "${sha256sums[@]}"
46                 ''
47         )
50 # extra patches
51 _extrapatches=(
53 _extrapatchessums=(
55 if [ ${#_extrapatches[@]} -ne 0 ]; then
56         source=( "${source[@]}"
57                 "${_extrapatches[@]}"
58         )
59         sha256sums=( "${sha256sums[@]}"
60                 "${_extrapatchessums[@]}"
61         )
64 # some stuff for the AUR parser :p
65 if [ "aur" == "there" ]; then
66         source=(
67                 "http://www.kernel.org/pub/linux/kernel/v3.x/linux-${_basekernel}.tar.xz"
68                 # the main kernel config files
69                 "config-${_basekernel}-desktop.i686"
70                 "config-${_basekernel}-desktop.x86_64"
71                 # standard config files for mkinitcpio ramdisk
72                 "linux${_kernelname}.preset"
73                 # sysctl updates for desktop usage picked up from opensuse
74                 "sysctl-desktop.i686"
75                 "sysctl-desktop.x86_64"
76         )
79 build() {
80         cd ${srcdir}/linux-${_basekernel}
81         # Add revision patches
82         if [ ${_patchver} -ne 0 ]; then
83                 msg2 "apply ${_patchname}"
84                 patch -Np1 -i ${srcdir}/${_patchname}
85         fi
87         # extra patches
88         for patch in ${_extrapatches[@]}; do
89                 msg2 "apply ${patch}"
90                 patch -Np1 -i ${srcdir}/${patch}
91         done
93         # set configuration
94         msg2 "copy configuration"
95         if [ "$CARCH" = "x86_64" ]; then
96                 cat ../config-${_basekernel}-desktop.x86_64 >./.config
97         else
98                 cat ../config-${_basekernel}-desktop.i686 >./.config
99         fi
100         if [ "${_kernelname}" != "" ]; then
101                 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"\U${_kernelname}\"|g" ./.config
102         fi
104         # set extraversion to pkgrel
105         msg2 "set extraversion to ${pkgrel}"
106         sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
108         # hack to prevent output kernel from being marked as dirty or git
109         msg2 "apply hack to prevent kernel tree being marked dirty"
110         echo "" > ${srcdir}/linux-${_basekernel}/.scmversion
112         # get kernel version
113         msg2 "prepare"
114         make prepare
115         # load configuration
116         # Configure the kernel. Replace the line below with one of your choice.
117         #make menuconfig # CLI menu for configuration
118         #make xconfig # X-based configuration
119         #make oldconfig # using old config from previous kernel version
120         # ... or manually edit .config
121         ####################
122         # stop here
123         # this is useful to configure the kernel
124         #msg "Stopping build"
125         #return 1
126         ####################
127         # yes "" | make config
128         # build!
129         msg2 "build"
130         make ${MAKEFLAGS} bzImage modules
133 package_linux-bede() {
134         pkgdesc="The Linux Kernel and modules, BlackEagle Desktop Edition"
135         groups=('base')
136         provides=('linux')
137         backup=(
138                 "etc/mkinitcpio.d/${pkgname}.preset"
139                 "etc/sysctl.d/sysctl-${pkgname}.conf"
140         )
141         depends=('coreutils' 'module-init-tools>=3.12-2' 'mkinitcpio>=0.7')
142         optdepends=(
143                 'crda: to set the correct wireless channels of your country'
144                 'linux-firmware: when having some hardware needing special firmware'
145         )
146         replaces=(
147                 'nouveau-drm' 'kernel26-slk' "kernel26${_kernelname}" "linux-bemm"
148         )
150         install=${pkgname}.install
152         KARCH=x86
153         cd ${srcdir}/linux-${_basekernel}
155         mkdir -p ${pkgdir}/{lib/modules,lib/firmware,boot}
157         # get kernel version
158         _kernver=$(make kernelrelease)
160         # install modules
161         make INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=${pkgdir} modules_install
163         # copy System.map and bzImage
164         cp System.map ${pkgdir}/boot/System.map${_kernelname}
165         cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz${_kernelname}
167         # install fallback mkinitcpio.conf file and preset file for kernel
168         install -m644 -D ${srcdir}/${pkgname}.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
170         # install sysctl enhancements
171         if [ "$CARCH" = "x86_64" ]; then
172                 install -m644 -D ${srcdir}/sysctl-desktop.x86_64 ${pkgdir}/etc/sysctl.d/sysctl-${pkgname}.conf
173         else
174                 install -m644 -D ${srcdir}/sysctl-desktop.i686 ${pkgdir}/etc/sysctl.d/sysctl-${pkgname}.conf
175         fi
177         # set correct depmod command for install
178         sed \
179                 -e  "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
180                 -e  "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
181                 -i $startdir/${pkgname}.install
182         sed \
183                 -e "s|source .*|source /etc/mkinitcpio.d/${pkgname}.kver|g" \
184                 -e "s|default_image=.*|default_image=\"/boot/initramfs${_kernelname}.img\"|g" \
185                 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs${_kernelname}-fallback.img\"|g" \
186                 -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
188         echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
190         # remove build and source links
191         rm -f ${pkgdir}/lib/modules/${_kernver}/{source,build}
193         # remove the firmware
194         rm -rf ${pkgdir}/lib/firmware
196         _fldkernelname=$(echo ${_kernelname} | tr "[:lower:]" "[:upper:]")
197         # make room for external modules
198         ln -s "../${_basekernel}${_fldkernelname}-external" "${pkgdir}/lib/modules/${_kernver}/external"
199         # add real version for building modules and running depmod from post_install/upgrade
200         mkdir -p "${pkgdir}/lib/modules/${_basekernel}${_fldkernelname}-external"
201         echo "${_kernver}" > "${pkgdir}/lib/modules/${_basekernel}${_fldkernelname}-external/version"
203         # gzip all modules
204         find ${pkgdir} -name '*.ko' -exec gzip -9 {} \;
207 package_linux-bede-headers() {
208         pkgdesc="Header files and scripts for building modules for linux${_kernelname}"
209         provides=('linux-headers')
210         replaces=("kernel26${_kernelname}-headers" "linux-bemm-headers")
211         mkdir -p ${pkgdir}/lib/modules/${_kernver}
212         cd ${pkgdir}/lib/modules/${_kernver}
213         ln -sf ../../../usr/src/linux-${_kernver} build
214         cd ${srcdir}/linux-${_basekernel}
215         install -D -m644 Makefile \
216                 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
217         install -D -m644 kernel/Makefile \
218                 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
219         install -D -m644 .config \
220                 ${pkgdir}/usr/src/linux-${_kernver}/.config
222         # copy files necessary for later builds, like nvidia and vmware
223         cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
224         cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
225         # fix permissions on scripts dir
226         chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
227         mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
229         mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
231         cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
232         if [ "$CARCH" = "i686" ]; then
233                 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
234         fi
235         cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
237         # add docbook makefile
238         install -D -m644 Documentation/DocBook/Makefile \
239                 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
241         # add config
242         for config in `find ./include/config -size +1c -type f`; do
243                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${config})
244                 cp -a ${config} ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${config})
245         done
247         # add headers
248         for header in `find -size +1c -name '*.h'`; do
249                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${header})
250                 cp -a ${header} ${pkgdir}/usr/src/linux-${_kernver}/$(dirname ${header})
251         done
253         # copy in Kconfig files
254         for i in `find . -name "Kconfig*"`; do
255                 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
256                 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
257         done
259         # strip scripts directory
260         find ${pkgdir}/usr/src/linux-${_kernver}/scripts  -type f -perm -u+w 2>/dev/null | while read binary ; do
261                 case "$(file -bi "$binary")" in
262                         *application/x-sharedlib*) # Libraries (.so)
263                                 /usr/bin/strip $STRIP_SHARED "$binary"
264                         ;;
265                         *application/x-archive*) # Libraries (.a)
266                                 /usr/bin/strip $STRIP_STATIC "$binary"
267                         ;;
268                         *application/x-executable*) # Binaries
269                                 /usr/bin/strip $STRIP_BINARIES "$binary"
270                         ;;
271                 esac 
272         done
274         chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
275         find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
276         # remove unneeded architectures
277         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}
279 pkgdesc="The Linux Kernel and modules, BlackEagle Desktop Edition"