1 # Maintainer: DonVla <donvla@users.sourceforge.net>
9 pkgver=${_basekernel}${_minrev}
11 pkgdesc="The Linux kernel and modules for SAMSUNG N130 - optionally with Con Kolivas' ck patchset and/or BFQ patches"
15 url="http://www.kernel.org"
16 depends=('coreutils' 'linux-firmware' 'lzop' 'module-init-tools>=3.16' 'mkinitcpio>=0.7')
17 install="linux${_kernelname}.install"
18 backup=("etc/mkinitcpio.d/linux-N130.preset")
19 _kernel_path="http://www.kernel.org/pub/linux/kernel/v3.x"
20 _patchname="patch-${_basekernel}${_minrev}"
21 # http://users.on.net/~ckolivas/kernel/
23 #_ck_path="http://www.kernel.org/pub/linux/kernel/people/ck/patches/3.0/${_basekernel}/${_basekernel}.0-${_ck_patchver}"
24 _ck_path="http://ck.kolivas.org/patches/3.0/${_basekernel}/${_basekernel}.0-${_ck_patchver}"
25 _ck_patchname="patch-${_basekernel}.0-${_ck_patchver}"
27 _bfq_path="http://algo.ing.unimo.it/people/paolo/disk_sched/patches/3.1.0-${_bfq_ver}"
28 source=("${_kernel_path}/linux-${_basekernel}.tar.bz2"
29 "${_kernel_path}/${_patchname}.bz2"
30 "${_ck_path}/${_ck_patchname}.bz2"
31 "config" "mkinitcpio-N130.conf" "linux-N130.preset"
32 logo_linux_{clut224.ppm,mono.pbm,vga16.ppm}
33 "i915-fix-ghost-tv-output.patch"
34 "i915-fix-incorrect-error-message.patch"
35 "usb-add-reset-resume-quirk-for-several-webcams.patch"
36 "change-default-console-loglevel.patch"
37 "0001-block-prepare-I-O-context-code-for-BFQ-${_bfq_ver}-for-${_basekernel}.patch"
38 "0002-block-cgroups-kconfig-build-bits-for-BFQ-${_bfq_ver}-${_basekernel}.patch"
39 "0003-block-introduce-the-BFQ-${_bfq_ver}-I-O-sched-for-${_basekernel}.patch" )
40 # "${_bfq_path}/0001-block-prepare-I-O-context-code-for-BFQ-${_bfq_ver}-for-${_basekernel}.patch"
41 # "${_bfq_path}/0002-block-cgroups-kconfig-build-bits-for-BFQ-${_bfq_ver}-${_basekernel}.patch"
42 # "${_bfq_path}/0003-block-introduce-the-BFQ-${_bfq_ver}-I-O-sched-for-${_basekernel}.patch" )
43 optdepends=('crda: to set the correct wireless channels of your country')
44 md5sums=('8d43453f8159b2332ad410b19d86a931'
45 '84c040bb8c4f46d351731cb0c05d9474'
46 'a4c69095403ff44d5dfd8a935c3aca5a'
47 'fc377478442e8c2a7fa3464d2076fb1a'
48 'bfdcb2a4be0152282d0b2803c89644f7'
49 '6c44c7be508b5de9ae00533fead51ff6'
50 '6a5a1925501fe20fafd04fdb3cb4f6ed'
51 'e8c333eaeac43f5c6a1d7b2f47af12e2'
52 'c120adbd9c0daa0136237a83adeabd1e'
53 '263725f20c0b9eb9c353040792d644e5'
54 'a50c9076012cb2dda49952dc6ec3e9c1'
55 '52d41fa61e80277ace2b994412a0c856'
56 '9d3c56a4b999c8bfbd4018089a62f662'
57 'e470805b4ef9d469a85b6e2f811ac337'
58 '61ca56c06bf197c0548ecd9fe01b2515'
59 '93e1b461374ae8b5147bba9887964cbe')
60 sha256sums=('2573d2378c754b0c602b57586e9311e5b38c5d1e6c137f02873833633a4b9359'
61 '474698393a39b792c02b7269010a8fd90fb38bfe7bd6f7bfc7dc5984afbce6ee'
62 '46c8a5cbca3471522903250f1fa431c5378e24ce0f7cd221c624145bbc967d08'
63 '6179c881189fa458acad71c06cd8c2134ea2515787642375c58eacbe011a83b2'
64 '8e66344ccee4b9d41435aba32414a9ac34e92ff68b2cb1faa67f75fc26a22533'
65 'ed4d88380a4a70a460215cc444727fb5f90d8b10b5e899de9d5d24890efbf36c'
66 '4274579ccf42a9acc03283edffea2dda2c4a48e3fd734bbaeada4c16dff9d156'
67 '1e5bea8de1c2cc24498fb9a4fdbb313f36f38f671f2bfc46ccf7acbd7958a4b9'
68 'f9c7c1275313890fc12f6bab92e2c0794b5041e223d868eb0e34cd99baee3d7a'
69 '9ccadbe3eb30bb283af3eb869c3a4bdb764628854811cc616a2e02e9ef398705'
70 '6f2af62930ba30e219e50418931cd87966990b4b446d406d9a8ebc56190a9277'
71 'ffc2f8a4899e225d26600cbb4636fd6002ddd9c00c6cfa5e309a89a33baff49d'
72 'b9d79ca33b0b51ff4f6976b7cd6dbb0b624ebf4fbf440222217f8ffc50445de4'
73 '01855a32d43a8ce451466ee2072b0fddf98718daad4bd6f1fdd1c9c8ea6ead8a'
74 '0bfb39b76f4c86e5575fac037c84c4da65039e3e972fa8422e3c6b720e0566d2'
75 'e3a88737ee9adfd32a3b7355be2e1f0767ebb42136f247ee6acd430775917262')
78 # change to 1 (or else) if you want to use the BF scheduler
79 # http://users.on.net/~ckolivas/kernel/
81 # change to 1 (or else) if you want to use the BFQ i/o scheduler
82 # http://algo.ing.unimo.it/people/paolo/disk_sched/
84 # default resume partition -> your swap partition. eg:
85 #_RESUME_SWAP_PARTITION="/dev/sda3"
86 # NO PERSISTENT NAMING! If in doubt, leave it empty
87 _RESUME_SWAP_PARTITION=""
89 cd "${srcdir}/linux-${_basekernel}"
91 # Add revision patches
92 (( _do_patch )) && [[ ! -z "${_minrev}" ]] && msg "Adding revision patches..." && (patch -Np1 < "${srcdir}/${_patchname}")
94 # Add Arch Linux logo to the source
95 msg "Adding Arch Linux logo..."
96 install -v -m 0644 "${srcdir}/logo_linux_clut224.ppm" drivers/video/logo/logo_linux_clut224.ppm &&
97 install -v -m 0644 "${srcdir}/logo_linux_mono.pbm" drivers/video/logo/logo_linux_mono.pbm &&
98 install -v -m 0644 "${srcdir}/logo_linux_vga16.ppm" drivers/video/logo/logo_linux_vga16.ppm
101 ### Arch stock kernel patches
103 # Some chips detect a ghost TV output
104 # mailing list discussion: http://lists.freedesktop.org/archives/intel-gfx/2011-April/010371.html
105 # Arch Linux bug report: FS#19234
107 # It is unclear why this patch wasn't merged upstream, it was accepted,
108 # then dropped because the reasoning was unclear. However, it is clearly
110 (( _do_patch )) && patch -Np1 -i "${srcdir}/i915-fix-ghost-tv-output.patch"
112 # In 3.1.0, a DRM_DEBUG message is falsely declared as DRM_ERROR. This
113 # worries users, as this message is displayed even at loglevel 4. Fix
115 (( _do_patch )) && patch -Np1 -i "${srcdir}/i915-fix-incorrect-error-message.patch"
117 # Add the USB_QUIRK_RESET_RESUME for several webcams
119 (( _do_patch )) && patch -Np1 -i "${srcdir}/usb-add-reset-resume-quirk-for-several-webcams.patch"
121 # set DEFAULT_CONSOLE_LOGLEVEL to 4 (same value as the 'quiet' kernel param)
122 # remove this when a Kconfig knob is made available by upstream
123 # (relevant patch sent upstream: https://lkml.org/lkml/2011/7/26/227)
124 (( _do_patch )) && patch -Np1 -i "${srcdir}/change-default-console-loglevel.patch"
127 ### Additional linux-N130 patches
130 if (( _do_patch && _USE_CK_PATCHSET )); then
131 msg "Adding CK patchset..."
132 patch -Np1 < "${srcdir}/${_ck_patchname}"
135 if (( _do_patch && _USE_BFQ_PATCHES )); then
136 msg "Adding BFQ patches..."
138 for _patch in "${srcdir}"/000*-block-*.patch; do
139 patch -Np1 < "${_patch}"
144 cat ../config > ./.config
145 # set swap partition for resuming - no resume= kernel line needed
146 if [[ "${_RESUME_SWAP_PARTITION}" ]]; then
147 sed -e "s|CONFIG_PM_STD_PARTITION=.*|CONFIG_PM_STD_PARTITION=\""${_RESUME_SWAP_PARTITION}"\"|g" -i ./.config
150 sed -i "s|CONFIG_LOCALVERSION=.*|CONFIG_LOCALVERSION=\"${_kernelname}\"|g" ./.config
152 # set extraversion to pkgrel
153 #sed -ri "s|^(EXTRAVERSION =).*|\1 -${pkgrel}|" Makefile
155 # Remove EXTRAVERSION from Makefile. Version will remain ${pkgver}-${pkgrel}-${_kernelname}
156 sed -e "s|^EXTRAVERSION\ .*|EXTRAVERSION\ = "-${pkgrel}"|g" -i Makefile
158 # remove the sublevel from Makefile
159 # this ensures our kernel version is always 3.X-ARCH
160 # this way, minor kernel updates will not break external modules
161 # we need to change this soon, see FS#16702
162 #sed -ri 's|^(SUBLEVEL =).*|\1|' Makefile
168 ### Configure the kernel and stop afterwards
169 ### this is useful to configure the kernel
172 ### This one also moves the config file to ${startdir} for later use.
173 ### Don't forget to rebuild the checksums afterwards!
174 #make menuconfig && cp -v .config ${startdir}/config && msg "Stopping build" && return 1
176 #make nconfig && cp -v .config ${startdir}/config && msg "Stopping build" && return 1
180 make ${MAKEFLAGS} bzImage modules
186 cd "${srcdir}/linux-${_basekernel}"
188 _kernver="$(make kernelrelease)"
191 ### install kernel and modules (kernel package)
193 mkdir -p ${pkgdir}/{lib/modules,boot}
194 make INSTALL_MOD_PATH="${pkgdir}" modules_install
195 cp arch/${KARCH}/boot/bzImage ${pkgdir}/boot/vmlinuz${_kernelname}
198 install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
200 # install N130 mkinitcpio.conf and preset file for kernel
201 install -m644 -D ${srcdir}/mkinitcpio-N130.conf ${pkgdir}/etc/mkinitcpio-N130.conf
202 install -m644 -D ${srcdir}/linux${_kernelname}.preset ${pkgdir}/etc/mkinitcpio.d/linux${_kernelname}.preset
204 # set correct depmod command for install
206 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${_kernelname}/g" \
207 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
208 -i "${startdir}/linux${_kernelname}.install"
211 -e "s|ALL_kver=.*|ALL_kver=\"/boot/vmlinuz${_kernelname}\"|g" \
212 -e "s|default_image=.*|default_image=\"/boot/linux${_kernelname}.img\"|g" \
213 -e "s|fallback_image=.*|fallback_image=\"/boot/initramfs${_kernelname}-fallback.img\"|g" \
214 -i ${pkgdir}/etc/mkinitcpio.d/linux${_kernelname}.preset
216 # remove build and source links
217 rm -f "${pkgdir}/lib/modules/${_kernver}"/{source,build}
218 # remove the firmware
219 rm -rf "${pkgdir}/lib/firmware"
220 # gzip -9 all modules to safe 100MB of space
221 find "$pkgdir" -name '*.ko' -exec gzip -9 {} \;
223 # add real version for building modules and running depmod from post_install/upgrade
224 mkdir -p "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname}"
225 echo "${_kernver}" > "${pkgdir}/lib/modules/extramodules-${_basekernel}${_kernelname}/version"
226 # make room for external modules
227 ln -s "../extramodules-${_basekernel}${_kernelname}" "${pkgdir}/lib/modules/${_kernver}/extramodules"
230 ### install kernel headers (kernel headers package)
232 mkdir -p "${pkgdir}/lib/modules/${_kernver}"
233 cd "${pkgdir}/lib/modules/${_kernver}" && ln -sf ../../../usr/src/linux-${_kernver} build
235 cd "${srcdir}/linux-${_basekernel}"
236 install -D -m644 Makefile "${pkgdir}/usr/src/linux-${_kernver}/Makefile"
237 install -D -m644 kernel/Makefile "${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile"
238 install -D -m644 .config "${pkgdir}/usr/src/linux-${_kernver}/.config"
240 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/include"
241 for i in acpi asm-generic config crypto drm generated linux math-emu media net pcmcia scsi sound trace video xen; do
242 cp -a include/${i} "${pkgdir}/usr/src/linux-${_kernver}/include/"
245 # copy arch includes for external modules
246 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/arch/x86"
247 cp -a arch/x86/include "${pkgdir}/usr/src/linux-${_kernver}/arch/x86/"
249 # copy files necessary for later builds, like nvidia and vmware
250 cp Module.symvers "${pkgdir}/usr/src/linux-${_kernver}"
251 cp -a scripts "${pkgdir}/usr/src/linux-${_kernver}"
253 # fix permissions on scripts dir
254 chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
255 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
257 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
259 cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
260 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
261 cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
263 # add docbook makefile
264 install -D -m644 Documentation/DocBook/Makefile \
265 "${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile"
267 # add headers for lirc package
268 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
269 cp drivers/media/video/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
270 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102; do
271 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
272 cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
276 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
277 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
280 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
281 cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
282 # add wireless headers
283 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
284 cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
286 # add dvb and tuner headers for external modules
287 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
288 cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
289 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
290 cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
291 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb
292 cp drivers/media/dvb/dvb-usb/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-usb/
293 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends
294 cp drivers/media/dvb/frontends/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
295 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners
296 cp drivers/media/common/tuners/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/common/tuners/
298 # add xfs and shmem for aufs building
299 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs"
300 mkdir -p "${pkgdir}/usr/src/linux-${_kernver}/mm"
301 cp fs/xfs/xfs_sb.h "${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h"
303 # copy in Kconfig files
304 for i in `find . -name "Kconfig*"`; do
305 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
306 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
309 chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
310 find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
312 # strip scripts directory
313 find ${pkgdir}/usr/src/linux-${_kernver}/scripts -type f -perm -u+w 2>/dev/null | while read binary ; do
314 case "$(file -bi "$binary")" in
315 *application/x-sharedlib*) # Libraries (.so)
316 /usr/bin/strip $STRIP_SHARED "$binary";;
317 *application/x-archive*) # Libraries (.a)
318 /usr/bin/strip $STRIP_STATIC "$binary";;
319 *application/x-executable*) # Binaries
320 /usr/bin/strip $STRIP_BINARIES "$binary";;
324 # remove unneeded architectures
325 rm -rf "${pkgdir}/usr/src/linux-${_kernver}/arch"/{alpha,arm,arm26,avr32,blackfin,cris,frv,h8300,ia64,m32r,m68k,m68knommu,mips,microblaze,mn10300,parisc,powerpc,ppc,s390,sh,sh64,sparc,sparc64,um,v850,xtensa}