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.
10 true && pkgbase="linux-next"
11 true && pkgname=("linux-next" "linux-next-headers")
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"
17 arch=("i686" "x86_64")
20 source=(linux-next.conf
22 md5sums=('ccec126fa0bfce4222a526ca02cf2de8'
23 '26dbd49508006ebdd52ab6cade09c330')
25 _gitroot="https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
28 _builddir="$srcdir/build/"
29 _sourcedir="$srcdir/$_gitname/"
31 # compress the modules with gzip or not
35 if [ ! -d "$_gitname" ]; then
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
45 if [ "$_no_update" = "y" ]; then
46 msg2 "Skipping tree update..."
48 cd "$srcdir/$_gitname"
50 msg2 "Updating local tree..."
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"
60 git reset --hard "origin/master"
63 error "Update failed..."
66 warning "Press ENTER if you want to continue or CTRL+C to abort..."
74 if [ -e "$_builddir/.config" ]; then
75 msg2 "Using existing config found in build environment..."
77 if [ ! -d "$_builddir" ]; then
78 msg2 "Creating build directory..."
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."
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."
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..."
104 # Number of CPU Cores
105 _CORES=$(cat /proc/cpuinfo|grep processor|wc -l)
106 if [ $_CORES -lt 1 ]; then
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..."
124 _kernver="$(make O="$_builddir" kernelrelease)"
125 msg2 "Kernel release name is: $_kernver"
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"
140 if [ $_compress = "y" ]; then
141 msg2 "Compressing kernel modules with gzip..."
142 find "${pkgdir}" -name '*.ko' -exec gzip -9 {} \;
145 # make room for external modules
146 rmdir "${pkgdir}/lib/modules/extramodules-*" &> /dev/null #remove the old one if it exists
147 mkdir "${pkgdir}/lib/modules/extramodules-${_kernver}"
148 ln -s "../extramodules-${_kernver}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
149 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_kernver}/version"
151 msg2 "Installing System.map..."
152 install -m644 "System.map" "$pkgdir/boot/System.map-next"
154 msg2 "Removing links to source and build directory..."
155 rm "$pkgdir/lib/modules/$_kernver/"{build,source}
157 msg2 "Updating kernel version in install script..."
158 sed -i "s/_kernel_version=.*/_kernel_version=$_kernver/" \
159 "$startdir/linux-next.install"
161 msg2 "Installing files for mkinitcpio..."
162 install -D -m644 "$srcdir/linux-next.conf" \
163 "$pkgdir/etc/mkinitcpio.d/linux-next.conf"
165 install -D -m644 "$srcdir/linux-next.preset" \
166 "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
167 sed -i "s/^ALL_kver=.*$/ALL_kver=$_kernver/" \
168 "$pkgdir/etc/mkinitcpio.d/linux-next.preset"
171 package_linux-next-headers() {
173 true && pkgdesc="Header files and scripts for building modules for linux-next"
174 true && depends=("linux-next")
175 true && provides=("linux-headers")
177 _srcdir="/usr/src/linux-$_kernver"
179 msg2 "Installing files necessary for 3rd party modules such as NVIDIA drivers or OSSv4..."
180 mkdir -p "$pkgdir/$_srcdir/"{arch/x86,include}
182 install -D -m644 "$_sourcedir/Makefile" "$pkgdir/$_srcdir/Makefile"
183 install -D -m644 "$_sourcedir/kernel/Makefile" "$pkgdir/$_srcdir/kernel/Makefile"
184 install -D -m644 "$_builddir/.config" "$pkgdir/$_srcdir/.config"
185 install -D -m644 "$_builddir/Module.symvers" "$pkgdir/$_srcdir/Module.symvers"
186 install -D -m644 "$_builddir/include/linux/version.h" "$pkgdir/$_srcdir/include/linux/version.h"
187 install -D -m644 "$_builddir/arch/x86/kernel/asm-offsets.s" "$pkgdir/$_srcdir/arch/x86/kernel/asm-offsets.s"
188 install -D -m644 "$_sourcedir/arch/x86/Makefile" "$pkgdir/$_srcdir/arch/x86/Makefile"
190 if [ "$CARCH" = "i686" ]; then
191 install -D -m644 "$_sourcedir/arch/x86/Makefile_32.cpu" "$pkgdir/$_srcdir/arch/x86/Makefile_32.cpu"
194 cp -a "$_sourcedir/scripts" "$pkgdir/$_srcdir"
195 cp -a "$_builddir/scripts" "$pkgdir/$_srcdir"
196 cp -a "$_sourcedir/include" "$pkgdir/$_srcdir"
197 cp -a "$_builddir/include/"{generated,config} "$pkgdir/$_srcdir/include"
198 cp -a "$_sourcedir/arch/x86/include" "$pkgdir/$_srcdir/arch/x86"
202 find drivers -type f -name "*.h";
203 find . -type f -name "Kconfig*";
204 } | while read file; do
205 install -D -m644 "$file" "$pkgdir/$_srcdir/$file"
208 msg2 "Fixing permissions on scripts directory..."
209 chmod og-w -R "$pkgdir/$_srcdir/scripts"
211 msg2 "Creating symlinks..."
212 mkdir -p "$pkgdir/lib/modules/$_kernver/"
213 ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/build"
214 ln -s "$_srcdir" "$pkgdir/lib/modules/$_kernver/source"