1 # Contributor: kang <kang@rsbac.org>
5 pkgdesc="RSBAC is a mandatory access control patch for Linux, this package is the patche kernel"
7 url="http://www.rsbac.org"
10 source=('config' 'kernel26.preset' 'kernel26.install')
11 md5sums=('47a7f9ed207e7e18e52a2c4c97f054af'
12 'c4dd66695c20e92881d688faf8ba242f'
13 '612dfdf70574b1d06ac820b6dfb6eeb6')
15 install=kernel26.install
17 backup=(etc/mkinitcpio.d/${pkgname}.preset)
18 depends=('coreutils' 'linux-firmware' 'module-init-tools' 'mkinitcpio>=0.5.20')
21 _gitroot="git://git.rsbac.org/linux-2.6"
26 msg "Connecting to GIT server...."
28 if [ -d $_gitname ] ; then
29 cd $_gitname && git pull origin
30 msg "The local files are updated."
32 git clone $_gitroot $_gitname
35 msg "GIT checkout done or server timeout"
36 msg "Starting make..."
38 rm -rf "$srcdir/$_gitname-build"
39 git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
40 cd "$srcdir/$_gitname-build"
46 msg "Configuring kernel..."
47 cp ../config ./.config
48 while true; do echo; done | make oldconfig
49 make prepare || return 1
51 #uncomment if you would like to change options before building
54 msg "Building kernel..."
55 make bzImage modules || return 1
61 cd "$srcdir/$_gitname-build"
62 _kernver="$(make kernelrelease)"
63 mkdir -p ${pkgdir}/{lib/modules,boot}
64 make INSTALL_MOD_PATH=${pkgdir} modules_install || return 1
65 cp System.map ${pkgdir}/boot/System.map26-${pkgname}
66 cp arch/$KARCH/boot/bzImage ${pkgdir}/boot/vmlinuz26-${pkgname}
68 install -m644 -D vmlinux ${pkgdir}/usr/src/linux-${_kernver}/vmlinux
70 # install fallback mkinitcpio.conf file and preset file for kernel
71 install -m644 -D ${srcdir}/kernel26.preset ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset || return 1
72 # set correct depmod command for install
74 -e "s/KERNEL_NAME=.*/KERNEL_NAME=${pkgname}/g" \
75 -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/g" \
76 -i $startdir/kernel26.install
78 -e "s|source .*|source /etc/mkinitcpio.d/${pkgname}.kver|g" \
79 -e "s|default_image=.*|default_image=\"/boot/${pkgname}.img\"|g" \
80 -e "s|fallback_image=.*|fallback_image=\"/boot/${pkgname}-fallback.img\"|g" \
81 -i ${pkgdir}/etc/mkinitcpio.d/${pkgname}.preset
83 echo -e "# DO NOT EDIT THIS FILE\nALL_kver='${_kernver}'" > ${pkgdir}/etc/mkinitcpio.d/${pkgname}.kver
85 rm -rf ${pkgdir}/lib/firmware
88 # Add the headers package
89 mkdir -p ${pkgdir}/lib/modules/${_kernver}
90 cd ${pkgdir}/lib/modules/${_kernver}
91 ln -sf ../../../usr/src/linux-${_kernver} build
92 cd "$srcdir/$_gitname-build"
93 install -D -m644 Makefile \
94 ${pkgdir}/usr/src/linux-${_kernver}/Makefile
95 install -D -m644 kernel/Makefile \
96 ${pkgdir}/usr/src/linux-${_kernver}/kernel/Makefile
97 install -D -m644 .config \
98 ${pkgdir}/usr/src/linux-${_kernver}/.config
99 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include
101 for i in acpi asm-generic config generated linux math-emu media net pcmcia scsi sound trace video; do
102 cp -a include/$i ${pkgdir}/usr/src/linux-${_kernver}/include/
105 # copy arch includes for external modules
106 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/x86
107 cp -a arch/x86/include ${pkgdir}/usr/src/linux-${_kernver}/arch/x86/
109 # copy files necessary for later builds, like nvidia and vmware
110 cp Module.symvers ${pkgdir}/usr/src/linux-${_kernver}
111 cp -a scripts ${pkgdir}/usr/src/linux-${_kernver}
112 # fix permissions on scripts dir
113 chmod og-w -R ${pkgdir}/usr/src/linux-${_kernver}/scripts
114 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/.tmp_versions
116 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel
118 cp arch/$KARCH/Makefile ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
119 if [ "$CARCH" = "i686" ]; then
120 cp arch/$KARCH/Makefile_32.cpu ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/
122 cp arch/$KARCH/kernel/asm-offsets.s ${pkgdir}/usr/src/linux-${_kernver}/arch/$KARCH/kernel/
124 # add headers for lirc package
125 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video
126 cp drivers/media/video/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/
127 for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
128 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
129 cp -a drivers/media/video/$i/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/video/$i
131 # add docbook makefile
132 install -D -m644 Documentation/DocBook/Makefile \
133 ${pkgdir}/usr/src/linux-${_kernver}/Documentation/DocBook/Makefile
135 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
136 cp drivers/md/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/md
138 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/linux
139 cp include/linux/inotify.h ${pkgdir}/usr/src/linux-${_kernver}/include/linux/
140 # add wireless headers
141 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
142 cp net/mac80211/*.h ${pkgdir}/usr/src/linux-${_kernver}/net/mac80211/
143 # add dvb headers for external modules
145 # http://bugs.archlinux.org/task/9912
146 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core
147 cp drivers/media/dvb/dvb-core/*.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/dvb-core/
148 # add dvb headers for external modules
150 # http://bugs.archlinux.org/task/11194
151 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
152 cp include/config/dvb/*.h ${pkgdir}/usr/src/linux-${_kernver}/include/config/dvb/
153 # add dvb headers for http://mcentral.de/hg/~mrec/em28xx-new
155 # http://bugs.archlinux.org/task/13146
156 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
157 cp drivers/media/dvb/frontends/lgdt330x.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
158 cp drivers/media/video/msp3400-driver.h ${pkgdir}/usr/src/linux-${_kernver}/drivers/media/dvb/frontends/
159 # add xfs and shmem for aufs building
160 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs
161 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/mm
162 cp fs/xfs/xfs_sb.h ${pkgdir}/usr/src/linux-${_kernver}/fs/xfs/xfs_sb.h
163 # add headers vor virtualbox
165 # http://bugs.archlinux.org/task/14568
166 cp -a include/drm $pkgdir/usr/src/linux-${_kernver}/include/
167 # add headers for broadcom wl
169 # http://bugs.archlinux.org/task/14568
170 cp -a include/trace $pkgdir/usr/src/linux-${_kernver}/include/
171 # copy in Kconfig files
172 for i in `find . -name "Kconfig*"`; do
173 mkdir -p ${pkgdir}/usr/src/linux-${_kernver}/`echo $i | sed 's|/Kconfig.*||'`
174 cp $i ${pkgdir}/usr/src/linux-${_kernver}/$i
177 chown -R root.root ${pkgdir}/usr/src/linux-${_kernver}
178 find ${pkgdir}/usr/src/linux-${_kernver} -type d -exec chmod 755 {} \;
179 # remove unneeded architectures
180 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}