3 source /tmp/chroot-functions.sh
5 check_genkernel_version
7 install -d /tmp/kerncache
8 PKGDIR=/tmp/kerncache/${clst_kname}/ebuilds
11 # default genkernel args
12 GK_ARGS="${clst_gk_mainargs} \
13 ${clst_kernel_gk_kernargs} \
14 --cachedir=/tmp/kerncache/${clst_kname}-genkernel_cache-${clst_version_stamp} \
16 --kerneldir=/usr/src/linux \
17 --modulespackage=/tmp/kerncache/${clst_kname}-modules-${clst_version_stamp}.tar.bz2 \
18 --minkernpackage=/tmp/kerncache/${clst_kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 all"
19 # extra genkernel options that we have to test for
20 if [ -n "${clst_KERNCACHE}" ]
22 GK_ARGS="${GK_ARGS} --kerncache=/tmp/kerncache/${clst_kname}-kerncache-${clst_version_stamp}.tar.bz2"
24 if [ -e /var/tmp/${clst_kname}.config ]
26 GK_ARGS="${GK_ARGS} --kernel-config=/var/tmp/${clst_kname}.config"
29 if [ -n "${clst_splash_theme}" ]
31 GK_ARGS="${GK_ARGS} --splash=${clst_splash_theme}"
32 # Setup case structure for livecd_type
33 case ${clst_livecd_type} in
34 gentoo-release-minimal|gentoo-release-universal)
35 case ${clst_hostarch} in
37 GK_ARGS="${GK_ARGS} --splash-res=1024x768"
44 if [ -d "/tmp/initramfs_overlay/${clst_initramfs_overlay}" ]
46 GK_ARGS="${GK_ARGS} --initramfs-overlay=/tmp/initramfs_overlay/${clst_initramfs_overlay}"
48 if [ -n "${clst_CCACHE}" ]
50 GK_ARGS="${GK_ARGS} --kernel-cc=/usr/lib/ccache/bin/gcc --utils-cc=/usr/lib/ccache/bin/gcc"
53 if [ "${clst_devmanager}" == "devfs" ]
55 GK_ARGS="${GK_ARGS} --no-udev"
58 if [ -n "${clst_linuxrc}" ]
60 GK_ARGS="${GK_ARGS} --linuxrc=/tmp/linuxrc"
63 if [ "${clst_target}" == "netboot2" -a -n "${clst_merge_path}" ]
65 GK_ARGS="${GK_ARGS} --initramfs-overlay=\"${clst_merge_path}\""
70 eval "clst_initramfs_overlay=\$clst_boot_kernel_${filtered_kname}_initramfs_overlay"
71 eval "clst_kernel_merge=\$clst_boot_kernel_${filtered_kname}_packages"
74 #echo "The GK_ARGS are"
76 export clst_kernel_merge
77 export clst_initramfs_overlay
78 # Build our list of kernel packages
79 if [ "${clst_livecd_type}" = "gentoo-release-livecd" ] \
80 && [ -n "${clst_kernel_merge}" ]
83 echo "${clst_kernel_merge}" > /usr/livecd/kernelpkgs.txt
85 # Build with genkernel using the set options
86 # callback is put here to avoid escaping issues
87 gk_callback_opts="-qN"
89 if [ -n "${clst_KERNCACHE}" ]
91 gk_callback_opts="${gk_callback_opts} -kb"
93 if [ -n "${clst_FETCH}" ]
95 gk_callback_opts="${gk_callback_opts} -f"
97 if [ "${clst_kernel_merge}" != "" ]
99 genkernel --callback="emerge ${gk_callback_opts} ${clst_kernel_merge}" \
102 genkernel ${GK_ARGS} || exit 1
104 md5sum /var/tmp/${clst_kname}.config | awk '{print $1}' > \
105 /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG
112 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
113 export CONFIG_PROTECT="-*"
115 # Set the timezone for the kernel build
117 cp -f /usr/share/zoneinfo/UTC /etc/localtime
119 filtered_kname=${clst_kname/-/_}
120 filtered_kname=${clst_kname/\//_}
121 filtered_kname=${filtered_kname/\./_}
123 eval "clst_kernel_use=\$clst_boot_kernel_${filtered_kname}_use"
124 eval "clst_kernel_gk_kernargs=\$clst_boot_kernel_${filtered_kname}_gk_kernargs"
125 eval "clst_ksource=\$clst_boot_kernel_${filtered_kname}_sources"
127 if [ -z "${clst_ksource}" ]
129 clst_ksource="virtual/linux-sources"
132 # Don't use pkgcache here, as the kernel source may get emerged with different
133 # USE variables (and thus different patches enabled/disabled.) Also, there's no
134 # real benefit in using the pkgcache for kernel source ebuilds.
137 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE ]
139 STR1=$(for i in `cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE`; do echo $i; done|sort)
140 STR2=$(for i in ${clst_kernel_use}; do echo $i; done|sort)
141 if [ "${STR1}" = "${STR2}" ]
143 #echo "USE Flags match"
146 if [ -n "${clst_KERNCACHE}" ]
148 [ -d /tmp/kerncache/${clst_kname}/ebuilds ] && \
149 rm -r /tmp/kerncache/${clst_kname}/ebuilds
150 [ -e /tmp/kerncache/${clst_kname}/usr/src/linux/.config ] && \
151 rm /tmp/kerncache/${clst_kname}/usr/src/linux/.config
157 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION ]
159 STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION`
160 STR2=${clst_kextraversion}
161 if [ "${STR1}" = "${STR2}" ]
163 if [ -n "${clst_KERNCACHE}" ]
165 #echo "EXTRAVERSION match"
172 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG ]
174 STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG`
175 STR2=`md5sum /var/tmp/${clst_kname}.config|awk '{print $1}'`
176 if [ "${STR1}" = "${STR2}" ]
178 if [ -n "${clst_KERNCACHE}" ]
186 [ -e /etc/make.conf ] && \
187 echo "USE=\"\${USE} ${clst_kernel_use} build\"" >> /etc/make.conf
189 if [ -n "${clst_KERNCACHE}" ]
191 mkdir -p /tmp/kerncache/${clst_kname}
192 clst_root_path=/tmp/kerncache/${clst_kname} PKGDIR=${PKGDIR} clst_myemergeopts="--quiet --nodeps --update --newuse" run_merge "${clst_ksource}" || exit 1
193 KERNELVERSION=`portageq best_visible / "${clst_ksource}"`
194 if [ ! -e /etc/portage/profile/package.provided ]
196 mkdir -p /etc/portage/profile
197 echo "${KERNELVERSION}" > /etc/portage/profile/package.provided
199 if ( ! grep -q "^${KERNELVERSION}\$" /etc/portage/profile/package.provided )
201 echo "${KERNELVERSION}" >> /etc/portage/profile/package.provided
204 [ -L /usr/src/linux ] && rm -f /usr/src/linux
205 ln -s /tmp/kerncache/${clst_kname}/usr/src/linux /usr/src/linux
207 [ -L /usr/src/linux ] && rm -f /usr/src/linux
208 run_merge "${clst_ksource}" || exit 1
212 # If catalyst has set to a empty string, extraversion wasn't specified so we
214 if [ "${EXTRAVERSION_MATCH}" = "0" ]
216 if [ ! "${clst_kextraversion}" = "" ]
218 echo "Setting extraversion to ${clst_kextraversion}"
219 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
220 echo ${clst_kextraversion} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
222 touch /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
227 sed -i "/USE=\"\${USE} ${clst_kernel_use} build\"/d" /etc/make.conf
228 # grep out the kernel version so that we can do our modules magic
229 VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
230 PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
231 SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
232 EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
233 clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
235 /sbin/update-modules --assume-kernel=${clst_fudgeuname}
238 echo ${clst_kernel_use} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE
241 if [ -n "${clst_KERNCACHE}" ]
243 if [ -e /etc/portage/profile/package.provided ]
245 sed -i "/^$(echo "${KERNELVERSION}" | sed -e 's|/|\\/|g')\$/d" /etc/portage/profile/package.provided