1 # Contributor: Patrick Bartels <p4ddy.b@gmail.com>
3 # Uncomment the line below if you want to maintain the git tree yourself.
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.
14 true && pkgbase="zen-kernel"
15 true && pkgname=("kernel26-zen" "kernel26-zen-headers")
18 pkgdesc="Featureful kernel including various new features, code and optimizations to better suit desktops"
19 url="http://www.zen-kernel.org"
21 arch=("i686" "x86_64")
24 source=(kernel26-zen.conf
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")
41 if [ ! -d "$_gitname" ]; then
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
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
59 if [ "$_no_update" = "y" ]; then
60 msg2 "Skipping tree update..."
62 cd "$srcdir/$_gitname"
64 msg2 "Updating local tree..."
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"
74 git reset --hard "origin/master"
77 error "Update failed..."
80 warning "Press ENTER if you want to continue or CTRL+C to abort..."
88 if [ -e "$_builddir/.config" ]; then
89 msg2 "Using existing config found in build environment..."
91 if [ ! -d "$_builddir" ]; then
92 msg2 "Creating build directory..."
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."
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."
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..."
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..."
133 _kernver="$(make O="$_builddir" kernelrelease)"
134 msg2 "Kernel release name is: $_kernver"
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"
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"
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() {
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}
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"
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"
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"
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"