2 # Copyright 1999-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
5 source /tmp/chroot-functions.sh
7 check_genkernel_version
9 PKGDIR=/usr/portage/packages/gk_binaries/${clst_kname}/ebuilds
12 # default genkernel args
13 GK_ARGS="${clst_gk_mainargs} \
14 ${clst_kernel_gk_kernargs} \
15 --cachedir=/usr/portage/packages/gk_binaries/${clst_kname}-genkernel_cache-${clst_version_stamp} \
18 --kerneldir=/usr/src/linux \
19 --kernel-config=/var/tmp/${clst_kname}.config \
20 --modulespackage=/usr/portage/packages/gk_binaries/${clst_kname}-modules-${clst_version_stamp}.tar.bz2 \
21 --minkernpackage=/usr/portage/packages/gk_binaries/${clst_kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 \
22 --kerncache=/usr/portage/packages/gk_binaries/${clst_kname}-kerncache-${clst_version_stamp}.tar.bz2 all"
23 # extra genkernel options that we have to test for
24 if [ "${clst_splash_type}" == "bootsplash" -a -n "${clst_splash_theme}" ]
26 GK_ARGS="${GK_ARGS} --bootsplash=${clst_splash_theme}"
29 if [ "${clst_splash_type}" == "gensplash" -a -n "${clst_splash_theme}" ]
31 GK_ARGS="${GK_ARGS} --gensplash=${clst_splash_theme}"
34 if [ -d "${clst_initramfs_overlay}" ]
36 GK_ARGS="${GK_ARGS} --initramfs-overlay=/tmp/initramfs_overlay/${clst_initramfs_overlay}"
38 if [ -n "${clst_CCACHE}" ]
40 GK_ARGS="${GK_ARGS} --kernel-cc=/usr/lib/ccache/bin/gcc --utils-cc=/usr/lib/ccache/bin/gcc"
43 if [ "${clst_devmanager}" == "devfs" ]
45 GK_ARGS="${GK_ARGS} --no-udev"
51 eval "clst_initramfs_overlay=\$clst_boot_kernel_${clst_kname}_initramfs_overlay"
52 eval "clst_kernel_merge=\$clst_boot_kernel_${clst_kname}_packages"
55 #echo "The GK_ARGS are"
57 export clst_kernel_merge
58 export clst_initramfs_overlay
59 # build with genkernel using the set options
60 # callback is put here to avoid escaping issues
61 if [ -n "${clst_KERNCACHE}" ]
63 if [ "$clst_kernel_merge" != "" ]
65 genkernel --callback="PKGDIR=${PKGDIR} emerge -kb ${clst_kernel_merge}" \
68 genkernel ${GK_ARGS} || exit 1
71 if [ "$clst_kernel_merge" != "" ]
73 genkernel --callback="emerge ${clst_kernel_merge}" \
76 genkernel ${GK_ARGS} || exit 1
79 md5sum /var/tmp/${clst_kname}.config|awk '{print $1}' > /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG
88 # Script to build each kernel, kernel-related packages
95 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
96 export CONFIG_PROTECT="-*"
98 #set the timezone for the kernel build
100 ln -s /usr/share/zoneinfo/UTC /etc/localtime
102 eval "clst_kernel_use=\$clst_boot_kernel_${clst_kname}_use"
103 export USE=$clst_kernel_use
105 eval "clst_kernel_gk_kernargs=\$clst_boot_kernel_${clst_kname}_gk_kernargs"
106 eval "clst_ksource=\$clst_boot_kernel_${clst_kname}_sources"
110 # Don't use pkgcache here, as the kernel source may get emerge with different USE variables
111 # (and thus different patches enabled/disabled.) Also, there's no real benefit in using the
112 # pkgcache for kernel source ebuilds.
115 if [ -e /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE ]
118 STR1=$(for i in `cat /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE`; do echo $i; done|sort)
119 STR2=$(for i in ${clst_kernel_use}; do echo $i; done|sort)
120 if [ "${STR1}" = "${STR2}" ]
122 #echo "USE Flags match"
125 if [ -n "${clst_KERNCACHE}" ]
127 [ -d /usr/portage/packages/gk_binaries/${clst_kname}/ebuilds ] && \
128 rm -r /usr/portage/packages/gk_binaries/${clst_kname}/ebuilds
129 [ -e /usr/portage/packages/gk_binaries/${clst_kname}/usr/src/linux/.config ] && \
130 rm /usr/portage/packages/gk_binaries/${clst_kname}/usr/src/linux/.config
136 if [ -e /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION ]
138 STR1=`cat /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION`
139 STR2=${clst_kextraversion}
140 if [ "${STR1}" = "${STR2}" ]
142 if [ -n "${clst_KERNCACHE}" ]
144 #echo "EXTRAVERSION match"
151 if [ -e /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG ]
153 STR1=`cat /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG`
154 STR2=`md5sum /var/tmp/${clst_kname}.config|awk '{print $1}'`
155 if [ "${STR1}" = "${STR2}" ]
157 if [ -n "${clst_KERNCACHE}" ]
166 if [ "${USE_MATCH}" = "0" -o "${EXTRAVERSION_MATCH}" = "0" -o "${CONFIG_MATCH}" = "0" ]
168 echo "Cleaning up ${clst_kname} kernel install ..."
169 echo "This may take some time ..."
170 if [ -d /usr/portage/packages/gk_binaries/${clst_kname}/ ]
172 rm -r /usr/portage/packages/gk_binaries/${clst_kname}/ || exit 1
176 mkdir -p /usr/portage/packages/gk_binaries/${clst_kname}
178 if [ -n "${clst_KERNCACHE}" ]
180 ROOT=/usr/portage/packages/gk_binaries/${clst_kname} PKGDIR=${PKGDIR} USE="${USE} symlink build" emerge -ukb "${clst_ksource}" || exit 1
181 KERNELVERSION=`/usr/lib/portage/bin/portageq best_visible / "${clst_ksource}"`
182 if [ ! -e /etc/portage/profile/package.provided ]
184 mkdir -p /etc/portage/profile
185 echo "${KERNELVERSION}" > /etc/portage/profile/package.provided
187 if ( ! grep -q "^${KERNELVERSION}" /etc/portage/profile/package.provided )
189 echo "${KERNELVERSION}" >> /etc/portage/profile/package.provided
192 [ -d /usr/src/linux ] && rm /usr/src/linux
193 ln -s /usr/portage/packages/gk_binaries/${clst_kname}/usr/src/linux /usr/src/linux
195 USE="${USE} symlink build" emerge "${clst_ksource}" || exit 1
198 #if catalyst has set to a empty string, extraversion wasn't specified so we skip this part
199 if [ "${EXTRAVERSION_MATCH}" != "1" ]
201 if [ "${clst_kextraversion}" != "" ]
203 echo "Setting extraversion to ${clst_kextraversion}"
204 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
205 echo ${clst_kextraversion} > /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
207 touch /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
213 # grep out the kernel version so that we can do our modules magic
214 VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
215 PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
216 SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
217 EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
218 clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
220 /sbin/modules-update --assume-kernel=${clst_fudgeuname}
223 echo ${clst_kernel_use} > /usr/portage/packages/gk_binaries/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE