updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / zen-kernel / PKGBUILD
blob10c1b99c233d678827cf23da235a998134241b20
1 # Contributor: Patrick Bartels <p4ddy.b@gmail.com>
3 # Uncomment the line below if you want to maintain the git tree yourself.
4 #_no_update="y"
6 # If this variable is set, the PKGBUILD won't clone the repository.
7 # Instead it will download a snapshot of a working git tree and update it.
8 # This is a temporary solution to reduce the GIT server's stress.
9 _use_snapshot="y"
11 # AUR workaround...
12 pkgname="zen-kernel"
14 true && pkgbase="zen-kernel"
15 true && pkgname=("kernel26-zen" "kernel26-zen-headers")
16 pkgver="20110120"
17 pkgrel="6"
18 pkgdesc="Featureful kernel including various new features, code and optimizations to better suit desktops"
19 url="http://www.zen-kernel.org"
20 license=("GPL2")
21 arch=("i686" "x86_64")
22 makedepends=("git")
23 options=("!strip")
24 source=(kernel26-zen.conf
25         kernel26-zen.preset)
26 md5sums=("ccec126fa0bfce4222a526ca02cf2de8"
27          "bd38031713df2bfea42c4fe804958474")
29 _gitroot="git://zen-kernel.org/kernel/zen-stable.git"
30 _gitname="zen-sources"
32 _builddir="$srcdir/build/"
33 _sourcedir="$srcdir/$_gitname/"
35 if [ "$_use_snapshot" = "y" ] && [ ! -d "$_sourcedir" ]; then
36         source+=(http://downloads.zen-kernel.org/snapshots/zen-stable/linux-2.6-zen.v2.6.36-zen0-full-git.tar.gz)
37         md5sums+=("2f8a8fe0ab79bf7cb2ebaff6d0a0b044")
40 fetch_sources() {
41         if [ ! -d "$_gitname" ]; then
42                 cd "$srcdir"
44                 if [ "$_use_snapshot" = "y" ]; then
45                         msg2 "Renaming snapshot directory..."
46                         mv "$srcdir/linux-2.6-zen" "$_sourcedir"
48                         _no_update="n" # always perform an update on the very first build
49                 else
50                         msg2 "Cloning initial copy of zen-sources..."
51                         warning "This may take some time depending on your available bandwidth."
53                         git clone --depth 1 "$_gitroot" "$_gitname"
55                         _no_update="y" # update is not necessary
56                 fi
57         fi
59         if [ "$_no_update" = "y" ]; then
60                 msg2 "Skipping tree update..."
61         else
62                 cd "$srcdir/$_gitname"
64                 msg2 "Updating local tree..."
65                 if git fetch; then
66                         msg2 "Attempting to merge changes..."
68                         if ! git merge origin/master; then
69                                 error "Merging failed..."
71                                 msg2 "Fixing local repository..."
72                                 git checkout -f "master"
73                                 git clean -xdf
74                                 git reset --hard "origin/master"
75                         fi
76                 else
77                         error "Update failed..."
78                 fi
80                 warning "Press ENTER if you want to continue or CTRL+C to abort..."
81                 read
82         fi
85 build() {
86         fetch_sources
88         if [ -e "$_builddir/.config" ]; then
89                 msg2 "Using existing config found in build environment..."
90         else
91                 if [ ! -d "$_builddir" ]; then
92                         msg2 "Creating build directory..."
93                         mkdir -p "$_builddir"
94                 fi
96                 msg2 "Creating default config..." # also initializes the output directory
97                 make -C "$_sourcedir" O="$_builddir" defconfig > /dev/null
99                 warning "This package does not ship a kernel config."
101                 plain   ""
102                 warning "Thus it is up to you to create a one that fits your needs."
103                 warning "Navigate to '$_builddir'"
104                 warning "and either run 'make menuconfig' or if you want to use an existing config,"
105                 warning "save it as '.config' and run 'make oldconfig' in order to update it."
106                 warning "Having done that you can run 'makepkg' again."
107                 plain   ""
109                 return 1
110         fi
112         msg2 "Updating output directory Makefile..."
113         make -C "$_sourcedir" O="$_builddir" outputmakefile
115         warning "Press ENTER if you want to build the kernel or CTRL+C to abort..."
116         read
118         cd "$_builddir"
119         msg2 "Building kernel..."; make bzImage
120         msg2 "Building modules..."; make modules
123 package_kernel26-zen() {
124         depends=("coreutils" "linux-firmware" "module-init-tools" "mkinitcpio>=0.5.20")
125         optdepends=("kernel26-zen-headers: to build third party modules such as NVIDIA drivers or OSSv4"
126                     "crda: to set the correct wireless channels of your country")
127         true && conflicts=("kernel26zen")
128         backup=(etc/mkinitcpio.d/kernel26-zen.conf)
129         install=kernel26-zen.install
131         msg2 "Determining kernel name..."
132         cd "$_sourcedir"
133         _kernver="$(make O="$_builddir" kernelrelease)"
134         msg2 "Kernel release name is: $_kernver"
136         cd "$_builddir"
138         msg2 "Installing kernel image..."
139         install -D -m644 "arch/x86/boot/bzImage" "$pkgdir/boot/vmlinuz26-zen"
141         msg2 "Installing modules (and firmware files)..."
142         make INSTALL_MOD_PATH="$pkgdir" modules_install
144         if [ -d "$pkgdir/lib/firmware" ]; then
145                 msg2 "Removing firmware files..."
146                 rm -r "$pkgdir/lib/firmware"
147         fi
149         msg2 "Installing System.map..."
150         install -m644 "System.map" "$pkgdir/boot/System.map26-zen"
152         msg2 "Removing links to source and build directory..."
153         rm "$pkgdir/lib/modules/$_kernver/"{build,source}
155         msg2 "Updating kernel version in install script..."
156         sed -i "s/_kernel_version=.*/_kernel_version=$_kernver/" \
157                 "$startdir/kernel26-zen.install"
159         msg2 "Installing files for mkinitcpio..."
160         install -D -m644 "$srcdir/kernel26-zen.conf" \
161                 "$pkgdir/etc/mkinitcpio.d/kernel26-zen.conf"
162         
163         install -D -m644 "$srcdir/kernel26-zen.preset" \
164                 "$pkgdir/etc/mkinitcpio.d/kernel26-zen.preset"
165         sed -i "s/^ALL_kver=.*$/ALL_kver=$_kernver/" \
166                 "$pkgdir/etc/mkinitcpio.d/kernel26-zen.preset"
169 package_kernel26-zen-headers() {
170         # AUR workaround
171         true && pkgdesc="Header files and scripts for building modules for kernel26-zen"
172         true && depends=("kernel26-zen")
173         true && conflicts=("kernel26zen-headers")
175         _srcdir="/usr/src/linux-$_kernver"
177         msg2 "Installing files necessary for 3rd party modules such as NVIDIA drivers or OSSv4..."
178         mkdir -p "$pkgdir/$_srcdir/"{arch/x86,include}
179         
180         install -D -m644 "$_sourcedir/Makefile" "$pkgdir/$_srcdir/Makefile"
181         install -D -m644 "$_sourcedir/kernel/Makefile" "$pkgdir/$_srcdir/kernel/Makefile"
182         install -D -m644 "$_builddir/.config" "$pkgdir/$_srcdir/.config"
183         install -D -m644 "$_builddir/Module.symvers" "$pkgdir/$_srcdir/Module.symvers"
184         install -D -m644 "$_builddir/include/linux/version.h" "$pkgdir/$_srcdir/include/linux/version.h"
185         install -D -m644 "$_builddir/arch/x86/kernel/asm-offsets.s" "$pkgdir/$_srcdir/arch/x86/kernel/asm-offsets.s"
186         install -D -m644 "$_sourcedir/arch/x86/Makefile" "$pkgdir/$_srcdir/arch/x86/Makefile"
188         if [ "$CARCH" = "i686" ]; then
189                 install -D -m644 "$_sourcedir/arch/x86/Makefile_32.cpu" "$pkgdir/$_srcdir/arch/x86/Makefile_32.cpu"
190         fi
192         cp -a "$_sourcedir/scripts" "$pkgdir/$_srcdir"
193         cp -a "$_builddir/scripts" "$pkgdir/$_srcdir"
194         cp -a "$_sourcedir/include" "$pkgdir/$_srcdir"
195         cp -a "$_builddir/include/"{generated,config} "$pkgdir/$_srcdir/include"
196         cp -a "$_sourcedir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
198         cd "$_sourcedir"
199         {
200                 find drivers -type f -name "*.h";
201                 find . -type f -name "Kconfig*";
202         } | while read file; do
203                 install -D -m644 "$file" "$pkgdir/$_srcdir/$file"
204         done
206         msg2 "Fixing permissions on scripts directory..."
207         chmod og-w -R "$pkgdir/$_srcdir/scripts"
209         msg2 "Creating symlinks..."
210         mkdir -p "$pkgdir/lib/modules/$_kernver/"
211         ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/build"
212         ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/source"