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 [ -n "${clst_linuxrc}" ]
55 GK_ARGS="${GK_ARGS} --linuxrc=/tmp/linuxrc"
58 if [ "${clst_target}" == "netboot2" ]
60 GK_ARGS="${GK_ARGS} --netboot"
62 if [ -n "${clst_merge_path}" ]
64 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 case ${clst_livecd_type} in
81 if [ -n "${clst_kernel_merge}" ]
84 echo "${clst_kernel_merge}" > /usr/livecd/kernelpkgs.txt
88 # Build with genkernel using the set options
89 # callback is put here to avoid escaping issues
90 gk_callback_opts="-qN"
92 if [ -n "${clst_KERNCACHE}" ]
94 gk_callback_opts="${gk_callback_opts} -kb"
96 if [ -n "${clst_FETCH}" ]
98 gk_callback_opts="${gk_callback_opts} -f"
100 if [ "${clst_kernel_merge}" != "" ]
102 genkernel --callback="emerge ${gk_callback_opts} ${clst_kernel_merge}" \
105 genkernel ${GK_ARGS} || exit 1
107 md5sum /var/tmp/${clst_kname}.config | awk '{print $1}' > \
108 /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG
115 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
116 export CONFIG_PROTECT="-*"
118 # Set the timezone for the kernel build
120 cp -f /usr/share/zoneinfo/UTC /etc/localtime
122 filtered_kname=${clst_kname/-/_}
123 filtered_kname=${clst_kname/\//_}
124 filtered_kname=${filtered_kname/\./_}
126 eval "clst_kernel_use=\$clst_boot_kernel_${filtered_kname}_use"
127 eval "clst_kernel_gk_kernargs=\$clst_boot_kernel_${filtered_kname}_gk_kernargs"
128 eval "clst_ksource=\$clst_boot_kernel_${filtered_kname}_sources"
130 if [ -z "${clst_ksource}" ]
132 clst_ksource="virtual/linux-sources"
135 # Don't use pkgcache here, as the kernel source may get emerged with different
136 # USE variables (and thus different patches enabled/disabled.) Also, there's no
137 # real benefit in using the pkgcache for kernel source ebuilds.
140 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE ]
142 STR1=$(for i in `cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE`; do echo $i; done|sort)
143 STR2=$(for i in ${clst_kernel_use}; do echo $i; done|sort)
144 if [ "${STR1}" = "${STR2}" ]
146 #echo "USE Flags match"
149 if [ -n "${clst_KERNCACHE}" ]
151 [ -d /tmp/kerncache/${clst_kname}/ebuilds ] && \
152 rm -r /tmp/kerncache/${clst_kname}/ebuilds
153 [ -e /tmp/kerncache/${clst_kname}/usr/src/linux/.config ] && \
154 rm /tmp/kerncache/${clst_kname}/usr/src/linux/.config
160 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION ]
162 STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION`
163 STR2=${clst_kextraversion}
164 if [ "${STR1}" = "${STR2}" ]
166 if [ -n "${clst_KERNCACHE}" ]
168 #echo "EXTRAVERSION match"
175 if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG ]
177 STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG`
178 STR2=`md5sum /var/tmp/${clst_kname}.config|awk '{print $1}'`
179 if [ "${STR1}" = "${STR2}" ]
181 if [ -n "${clst_KERNCACHE}" ]
189 [ -e /etc/make.conf ] && \
190 echo "USE=\"\${USE} ${clst_kernel_use} build\"" >> /etc/make.conf
192 if [ -n "${clst_KERNCACHE}" ]
194 mkdir -p /tmp/kerncache/${clst_kname}
195 clst_root_path=/tmp/kerncache/${clst_kname} PKGDIR=${PKGDIR} clst_myemergeopts="--quiet --nodeps --update --newuse" run_merge "${clst_ksource}" || exit 1
196 KERNELVERSION=`portageq best_visible / "${clst_ksource}"`
197 if [ ! -e /etc/portage/profile/package.provided ]
199 mkdir -p /etc/portage/profile
200 echo "${KERNELVERSION}" > /etc/portage/profile/package.provided
202 if ( ! grep -q "^${KERNELVERSION}\$" /etc/portage/profile/package.provided )
204 echo "${KERNELVERSION}" >> /etc/portage/profile/package.provided
207 [ -L /usr/src/linux ] && rm -f /usr/src/linux
208 ln -s /tmp/kerncache/${clst_kname}/usr/src/linux /usr/src/linux
210 [ -L /usr/src/linux ] && rm -f /usr/src/linux
211 run_merge "${clst_ksource}" || exit 1
215 # If catalyst has set to a empty string, extraversion wasn't specified so we
217 if [ "${EXTRAVERSION_MATCH}" = "0" ]
219 if [ ! "${clst_kextraversion}" = "" ]
221 echo "Setting extraversion to ${clst_kextraversion}"
222 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
223 echo ${clst_kextraversion} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
225 touch /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
230 sed -i "/USE=\"\${USE} ${clst_kernel_use} build\"/d" /etc/make.conf
231 # grep out the kernel version so that we can do our modules magic
232 VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
233 PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
234 SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
235 EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
236 clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
238 /sbin/update-modules --assume-kernel=${clst_fudgeuname}
241 echo ${clst_kernel_use} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE
244 if [ -n "${clst_KERNCACHE}" ]
246 if [ -e /etc/portage/profile/package.provided ]
248 sed -i "/^$(echo "${KERNELVERSION}" | sed -e 's|/|\\/|g')\$/d" /etc/portage/profile/package.provided