updated on Thu Jan 12 04:00:44 UTC 2012
[aur-mirror.git] / linux-next / PKGBUILD
blobbd8f697b2f6204bd7680fb21390714e9ff97d628
1 # Maintainer: Matt Parnell/ilikenwf <parwok@gmail.com>
2 # PKGBUILD Writer: Patrick Bartels <p4ddy.b@gmail.com>
4 # Uncomment the line below if you want to maintain the git tree yourself.
5 _no_update="y"
7 # AUR workaround...
8 pkgname="linux-next"
10 true && pkgbase="linux-next"
11 true && pkgname=("linux-next" "linux-next-headers")
12 pkgver=20120107
13 pkgrel=1
14 pkgdesc="Linux-Next kernel from git - use yaourt -G or store the build directory somewhere to keep a git repo."
15 url="http://www.kernel.org"
16 license=("GPL2")
17 arch=("i686" "x86_64")
18 makedepends=("git")
19 options=("!strip")
20 source=(linux-next.conf
21         linux-next.preset)
22 md5sums=('ccec126fa0bfce4222a526ca02cf2de8'
23          '26dbd49508006ebdd52ab6cade09c330')
25 _gitroot="https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
26 _gitname="linux-next"
28 _builddir="$srcdir/build/"
29 _sourcedir="$srcdir/$_gitname/"
31 # compress the modules with gzip or not
32 _compress="y"
34 fetch_sources() {
35         if [ ! -d "$_gitname" ]; then
36                 cd "$srcdir"
37                 msg2 "Cloning initial copy of linux-next..."
38                 warning "This may take some time depending on your available bandwidth."
40                 git clone --depth 1 "$_gitroot" "$_gitname"
42                 _no_update="y" # update is not necessary
43         fi
45         if [ "$_no_update" = "y" ]; then
46                 msg2 "Skipping tree update..."
47         else
48                 cd "$srcdir/$_gitname"
50                 msg2 "Updating local tree..."
51                 if git fetch; then
52                         msg2 "Attempting to merge changes..."
54                         if ! git merge origin/master; then
55                                 error "Merging failed..."
57                                 msg2 "Fixing local repository..."
58                                 git checkout -f "matt-playground"
59                                 git clean -xdf
60                                 git reset --hard "origin/master"
61                         fi
62                 else
63                         error "Update failed..."
64                 fi
66                 warning "Press ENTER if you want to continue or CTRL+C to abort..."
67                 read
68         fi
71 build() {
72         fetch_sources
74         if [ -e "$_builddir/.config" ]; then
75                 msg2 "Using existing config found in build environment..."
76         else
77                 if [ ! -d "$_builddir" ]; then
78                         msg2 "Creating build directory..."
79                         mkdir -p "$_builddir"
80                 fi
82                 msg2 "Creating default config..." # also initializes the output directory
83                 make -C "$_sourcedir" O="$_builddir" defconfig > /dev/null
85                 warning "This package does not ship a kernel config."
87                 plain   ""
88                 warning "Thus it is up to you to create a one that fits your needs."
89                 warning "Navigate to '$_builddir'"
90                 warning "and either run 'make menuconfig' or if you want to use an existing config,"
91                 warning "save it as '.config' and run 'make oldconfig' in order to update it."
92                 warning "Having done that you can run 'makepkg' again."
93                 plain   ""
95                 return 1
96         fi
98         msg2 "Updating output directory Makefile..."
99         make -C "$_sourcedir" O="$_builddir" outputmakefile
101         warning "Press ENTER if you want to build the kernel or CTRL+C to abort..."
102         read
103         
104         # Number of CPU Cores
105         _CORES=$(cat /proc/cpuinfo|grep processor|wc -l)
106         if [ $_CORES -lt 1 ]; then
107                 _CORES=1
108         fi
110         cd "$_builddir"
111         msg2 "Building kernel..."; make -j $_CORES bzImage
112         msg2 "Building modules..."; make -j $_CORES modules
115 package_linux-next() {
116         depends=("coreutils" "linux-firmware" "module-init-tools" "mkinitcpio>=0.5.20")
117         optdepends=("linux-next-headers: to build third party modules such as NVIDIA drivers or OSSv4"
118                     "crda: to set the correct wireless channels of your country")
119         backup=(etc/mkinitcpio.d/linux-next.conf)
120         install=linux-next.install
122         msg2 "Determining kernel name..."
123         cd "$_sourcedir"
124         _kernver="$(make O="$_builddir" kernelrelease)"
125         msg2 "Kernel release name is: $_kernver"
127         cd "$_builddir"
129         msg2 "Installing kernel image..."
130         install -D -m644 "arch/x86/boot/bzImage" "$pkgdir/boot/vmlinuz-linux-next"
132         msg2 "Installing modules (and firmware files)..."
133         make INSTALL_MOD_PATH="$pkgdir" modules_install
135         if [ -d "$pkgdir/lib/firmware" ]; then
136                 msg2 "Removing firmware files..."
137                 rm -r "$pkgdir/lib/firmware"
138         fi
139         
140         if [ $_compress = "y" ]; then
141                 msg2 "Compressing kernel modules with gzip..."
142                 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
143         fi
145         # make room for external modules
146         if [ -d "${pkgdir}/lib/modules/extramodules-*" ]; then
147                 rmdir "${pkgdir}/lib/modules/extramodules-*" &> /dev/null
148         fi
149         
150         mkdir "${pkgdir}/lib/modules/extramodules-${_kernver}"
151         ln -s "../extramodules-${_kernver}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
152         echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_kernver}/version"
153         
154         msg2 "Installing System.map..."
155         install -m644 "System.map" "$pkgdir/boot/System.map-next"
157         msg2 "Removing links to source and build directory..."
158         rm "$pkgdir/lib/modules/$_kernver/"{build,source}
160         msg2 "Updating kernel version in install script..."
161         sed -i "s/_kernel_version=.*/_kernel_version=$_kernver/" \
162                 "$startdir/linux-next.install"
164         msg2 "Installing files for mkinitcpio..."
165         install -D -m644 "$srcdir/linux-next.conf" \
166                 "$pkgdir/etc/mkinitcpio.d/linux-next.conf"
167         
168         install -D -m644 "$srcdir/linux-next.preset" \
169                 "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
170         sed -i "s/^ALL_kver=.*$/ALL_kver=$_kernver/" \
171                 "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
174 package_linux-next-headers() {
175         # AUR workaround
176         true && pkgdesc="Header files and scripts for building modules for linux-next"
177         true && depends=("linux-next")
178         true && provides=("linux-headers")
180         _srcdir="/usr/src/linux-$_kernver"
182         msg2 "Installing files necessary for 3rd party modules such as NVIDIA drivers or OSSv4..."
183         mkdir -p "$pkgdir/$_srcdir/"{arch/x86,include}
184         
185         install -D -m644 "$_sourcedir/Makefile" "$pkgdir/$_srcdir/Makefile"
186         install -D -m644 "$_sourcedir/kernel/Makefile" "$pkgdir/$_srcdir/kernel/Makefile"
187         install -D -m644 "$_builddir/.config" "$pkgdir/$_srcdir/.config"
188         install -D -m644 "$_builddir/Module.symvers" "$pkgdir/$_srcdir/Module.symvers"
189         install -D -m644 "$_builddir/include/linux/version.h" "$pkgdir/$_srcdir/include/linux/version.h"
190         install -D -m644 "$_builddir/arch/x86/kernel/asm-offsets.s" "$pkgdir/$_srcdir/arch/x86/kernel/asm-offsets.s"
191         install -D -m644 "$_sourcedir/arch/x86/Makefile" "$pkgdir/$_srcdir/arch/x86/Makefile"
193         if [ "$CARCH" = "i686" ]; then
194                 install -D -m644 "$_sourcedir/arch/x86/Makefile_32.cpu" "$pkgdir/$_srcdir/arch/x86/Makefile_32.cpu"
195         fi
197         cp -a "$_sourcedir/scripts" "$pkgdir/$_srcdir"
198         cp -a "$_builddir/scripts" "$pkgdir/$_srcdir"
199         cp -a "$_sourcedir/include" "$pkgdir/$_srcdir"
200         cp -a "$_builddir/include/"{generated,config} "$pkgdir/$_srcdir/include"
201         cp -a "$_sourcedir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
203         cd "$_sourcedir"
204         {
205                 find drivers -type f -name "*.h";
206                 find . -type f -name "Kconfig*";
207         } | while read file; do
208                 install -D -m644 "$file" "$pkgdir/$_srcdir/$file"
209         done
211         msg2 "Fixing permissions on scripts directory..."
212         chmod og-w -R "$pkgdir/$_srcdir/scripts"
214         msg2 "Creating symlinks..."
215         mkdir -p "$pkgdir/lib/modules/$_kernver/"
216         ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/build"
217         ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/source"