1 # Maintainer: Matt Parnell/ilikenwf <parwok@gmail.com>
2 # Original PKGBUILD Contributor: Patrick Bartels <p4ddy.b@gmail.com>
5 # Uncomment the line below if you want to maintain the git tree yourself.
11 true && pkgbase="linux-zen"
12 true && pkgname=("linux-zen" "linux-zen-headers")
15 pkgdesc="Featureful kernel including various new features, code and optimizations to better suit desktops"
16 url="http://www.zen-kernel.org"
18 arch=("i686" "x86_64")
21 source=(linux-zen.conf
23 md5sums=('ccec126fa0bfce4222a526ca02cf2de8'
24 '9769bc748f06ba48bed13203cc6efeea')
26 _gitroot="git://zen-kernel.org/kernel/zen-stable.git"
27 _gitname="zen-sources"
29 _builddir="$srcdir/build/"
30 _sourcedir="$srcdir/$_gitname/"
32 # compress the modules or not
36 if [ ! -d "$_gitname" ]; then
38 msg2 "Cloning initial copy of zen-sources..."
39 warning "This may take some time depending on your available bandwidth."
41 git clone --depth 1 "$_gitroot" "$_gitname"
43 _no_update="y" # update is not necessary
46 if [ "$_no_update" = "y" ]; then
47 msg2 "Skipping tree update..."
49 cd "$srcdir/$_gitname"
51 msg2 "Updating local tree..."
53 msg2 "Attempting to merge changes..."
55 if ! git merge origin/master; then
56 error "Merging failed..."
58 msg2 "Fixing local repository..."
59 git checkout -f "master"
61 git reset --hard "origin/master"
64 error "Update failed..."
67 warning "Press ENTER if you want to continue or CTRL+C to abort..."
75 if [ -e "$_builddir/.config" ]; then
76 msg2 "Using existing config found in build environment..."
78 if [ ! -d "$_builddir" ]; then
79 msg2 "Creating build directory..."
83 msg2 "Creating default config..." # also initializes the output directory
84 make -C "$_sourcedir" O="$_builddir" defconfig > /dev/null
86 warning "This package does not ship a kernel config."
89 warning "Thus it is up to you to create a one that fits your needs."
90 warning "Navigate to '$_builddir'"
91 warning "and either run 'make menuconfig' or if you want to use an existing config,"
92 warning "save it as '.config' and run 'make oldconfig' in order to update it."
93 warning "Having done that you can run 'makepkg' again."
99 msg2 "Updating output directory Makefile..."
100 make -C "$_sourcedir" O="$_builddir" outputmakefile
102 warning "Press ENTER if you want to build the kernel or CTRL+C to abort..."
105 # Number of CPU Cores
106 _CORES=$(cat /proc/cpuinfo|grep processor|wc -l)
107 if [ $_CORES -lt 1 ]; then
112 msg2 "Building kernel..."; make -j $_CORES bzImage
113 msg2 "Building modules..."; make -j $_CORES modules
116 package_linux-zen() {
117 depends=("coreutils" "linux-firmware" "module-init-tools" "mkinitcpio>=0.5.20")
118 optdepends=("linux-zen-headers: to build third party modules such as NVIDIA drivers or OSSv4"
119 "crda: to set the correct wireless channels of your country")
120 true && conflicts=("kernel26zen")
121 backup=(etc/mkinitcpio.d/linux-zen.conf)
122 install=linux-zen.install
124 msg2 "Determining kernel name..."
126 _kernver="$(make O="$_builddir" kernelrelease)"
127 msg2 "Kernel release name is: $_kernver"
131 msg2 "Installing kernel image..."
132 install -D -m644 "arch/x86/boot/bzImage" "$pkgdir/boot/vmlinuz-linux-zen"
134 msg2 "Installing modules (and firmware files)..."
135 make INSTALL_MOD_PATH="$pkgdir" modules_install
137 if [ -d "$pkgdir/lib/firmware" ]; then
138 msg2 "Removing firmware files..."
139 rm -r "$pkgdir/lib/firmware"
142 if [ $_compress = "y" ]; then
143 msg2 "Compressing kernel modules with gzip..."
144 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
147 # make room for external modules
148 if [ -d "${pkgdir}/lib/modules/extramodules-*" ]; then
149 rmdir "${pkgdir}/lib/modules/extramodules-*" &> /dev/null
152 mkdir "${pkgdir}/lib/modules/extramodules-${_kernver}"
153 ln -s "../extramodules-${_kernver}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
154 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_kernver}/version"
156 msg2 "Installing System.map..."
157 install -m644 "System.map" "$pkgdir/boot/System.map26-zen"
159 msg2 "Removing links to source and build directory..."
160 rm "$pkgdir/lib/modules/$_kernver/"{build,source}
162 msg2 "Updating kernel version in install script..."
163 sed -i "s/_kernel_version=.*/_kernel_version=$_kernver/" \
164 "$startdir/linux-zen.install"
166 msg2 "Installing files for mkinitcpio..."
167 install -D -m644 "$srcdir/linux-zen.conf" \
168 "$pkgdir/etc/mkinitcpio.d/linux-zen.conf"
170 install -D -m644 "$srcdir/linux-zen.preset" \
171 "$pkgdir/etc/mkinitcpio.d/linux-zen.preset"
172 sed -i "s/^ALL_kver=.*$/ALL_kver=$_kernver/" \
173 "$pkgdir/etc/mkinitcpio.d/linux-zen.preset"
176 package_linux-zen-headers() {
178 true && pkgdesc="Header files and scripts for building modules for linux-zen"
179 true && depends=("linux-zen")
180 true && conflicts=("kernel26zen-headers")
181 true && provides=("linux-headers")
183 _srcdir="/usr/src/linux-$_kernver"
185 msg2 "Installing files necessary for 3rd party modules such as NVIDIA drivers or OSSv4..."
186 mkdir -p "$pkgdir/$_srcdir/"{arch/x86,include}
188 install -D -m644 "$_sourcedir/Makefile" "$pkgdir/$_srcdir/Makefile"
189 install -D -m644 "$_sourcedir/kernel/Makefile" "$pkgdir/$_srcdir/kernel/Makefile"
190 install -D -m644 "$_builddir/.config" "$pkgdir/$_srcdir/.config"
191 install -D -m644 "$_builddir/Module.symvers" "$pkgdir/$_srcdir/Module.symvers"
192 install -D -m644 "$_builddir/include/linux/version.h" "$pkgdir/$_srcdir/include/linux/version.h"
193 install -D -m644 "$_builddir/arch/x86/kernel/asm-offsets.s" "$pkgdir/$_srcdir/arch/x86/kernel/asm-offsets.s"
194 install -D -m644 "$_sourcedir/arch/x86/Makefile" "$pkgdir/$_srcdir/arch/x86/Makefile"
196 if [ "$CARCH" = "i686" ]; then
197 install -D -m644 "$_sourcedir/arch/x86/Makefile_32.cpu" "$pkgdir/$_srcdir/arch/x86/Makefile_32.cpu"
200 cp -a "$_sourcedir/scripts" "$pkgdir/$_srcdir"
201 cp -a "$_builddir/scripts" "$pkgdir/$_srcdir"
202 cp -a "$_sourcedir/include" "$pkgdir/$_srcdir"
203 cp -a "$_builddir/include/"{generated,config} "$pkgdir/$_srcdir/include"
204 cp -a "$_sourcedir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
208 find drivers -type f -name "*.h";
209 find . -type f -name "Kconfig*";
210 } | while read file; do
211 install -D -m644 "$file" "$pkgdir/$_srcdir/$file"
214 msg2 "Fixing permissions on scripts directory..."
215 chmod og-w -R "$pkgdir/$_srcdir/scripts"
217 msg2 "Creating symlinks..."
218 mkdir -p "$pkgdir/lib/modules/$_kernver/"
219 ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/build"
220 ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/source"