2 # Copyright 1999-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo/src/catalyst/livecd/runscript-support/Attic/kmerge.sh,v 1.17 2004/10/21 17:06:21 wolf31o2 Exp $
12 # default genkernel args
13 GK_ARGS="${clst_livecd_gk_mainargs} \
14 ${clst_livecd_gk_kernargs} \
15 --kerneldir=/usr/src/linux \
17 --kernel-config=/var/tmp/${clst_kname}.config \
18 --minkernpackage=/usr/portage/packages/gk_binaries/${clst_kname}-${clst_version_stamp}.tar.bz2 all"
20 # extra genkernel options that we have to test for
21 if [ "${clst_livecd_splash_type}" == "bootsplash" -a -n "${clst_livecd_splash_theme}" ]
23 GK_ARGS="${GK_ARGS} --bootsplash=${clst_livecd_splash_theme}"
26 if [ "${clst_livecd_splash_type}" == "gensplash" -a -n "${clst_livecd_splash_theme}" ]
28 GK_ARGS="${GK_ARGS} --gensplash=${clst_livecd_splash_theme}"
31 if [ -e "/var/tmp/${clst_kname}.postconf" ]
33 for x in $( cat /var/tmp/${clst_kname}.postconf )
35 clst_kernel_postconf="${clst_kernel_postconf} ${x}"
37 GK_ARGS="${GK_ARGS} --postconf=\"${clst_kernel_postconf}\""
40 if [ -e "/var/tmp/${clst_kname}.packages" ]
42 for x in $( cat /var/tmp/${clst_kname}.packages )
44 # we don't want to use the pkgcache for these since the results
45 # are kernel-dependent.
46 clst_kernel_merge="${clst_kernel_merge} ${x}"
48 GK_ARGS="${GK_ARGS} --callback=\"${clst_kernel_merge}\""
51 if [ "${clst_livecd_devmanager}" == "udev" ]
53 GK_ARGS="${GK_ARGS} --udev"
56 # build with genkernel using the set options
57 # callback is put here to avoid escaping issues
58 genkernel ${GK_ARGS} || exit 1
60 # pack up the modules for resuming
61 if [ -n "${clst_KERNCACHE}" ]
63 tar cjpf /usr/portage/packages/gk_binaries/${1}-modules-${clst_version_stamp}.tar.bz2 \
64 /lib/modules/"${1}" || die "Could not package kernel modules, exiting"
69 # Script to build each kernel, kernel-related packages
73 [ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
74 export CONFIG_PROTECT="-*"
77 #set the timezone for the kernel build
79 ln -s /usr/share/zoneinfo/UTC /etc/localtime
81 [ -e "/var/tmp/${clst_kname}.use" ] && export USE="$( cat /var/tmp/${clst_kname}.use )" || unset USE
82 [ -e "/var/tmp/${clst_kname}.gk_kernargs" ] && source /var/tmp/${clst_kname}.gk_kernargs
84 # Don't use pkgcache here, as the kernel source may get emerge with different USE variables
85 # (and thus different patches enabled/disabled.) Also, there's no real benefit in using the
86 # pkgcache for kernel source ebuilds.
87 emerge "${clst_ksource}" || exit 1
88 [ ! -e /usr/src/linux ] && die "Can't find required directory /usr/src/linux"
90 #if catalyst has set NULL_VALUE, extraversion wasn't specified so we skip this part
91 if [ "${clst_kextversion}" != "NULL_VALUE" ]
93 sed -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextversion}:" /usr/src/linux/Makefile
96 if [ -n "${clst_CCACHE}" ]
98 #enable ccache for genkernel
99 export PATH="/usr/lib/ccache/bin:${PATH}"
102 # grep out the kernel version so that we can do our modules magic
103 VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
104 PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
105 SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
106 EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | sed -e "s/EXTRAVERSION =//" -e "s/ //g"`
107 clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
109 # kernel building happens here
110 # does the old config exist? if it does not, we build by default
111 if [ -e "/usr/portage/packages/gk_binaries/${clst_kname}-${clst_version_stamp}.config" ]
113 # test to see if the kernel .configs are the same, if so, then we skip kernel building
114 test1=$(md5sum /var/tmp/${clst_kname}.config | cut -d " " -f 1)
115 test2=$(md5sum /usr/portage/packages/gk_binaries/${clst_kname}-${clst_version_stamp}.config | cut -d " " -f 1)
116 if [ "${test1}" == "${test2}" -a -n "${clst_KERNCACHE}" ]
119 echo "No kernel configuration change, skipping kernel build..."
123 # unpack our modules to the LiveCD fs
125 echo "Unpacking kernel modules from the previous build..."
127 [ ! -d /lib/modules ] && mkdir /lib/modules
128 tar xjpf /usr/portage/packages/gk_binaries/${clst_fudgeuname}-modules-${clst_version_stamp}.tar.bz2 \
129 -C / || die "Could not unpack kernel modules"
131 build_kernel ${clst_fudgeuname}
135 build_kernel ${clst_fudgeuname}
139 /sbin/modules-update --assume-kernel=${clst_fudgeuname}
141 #now the unmerge... (wipe db entry)
142 emerge -C ${clst_ksource}
145 # keep the config around so that we can resume at some point
146 [ -n "${clst_KERNCACHE}" ] && cp /var/tmp/${clst_kname}.config /usr/portage/packages/gk_binaries/${clst_kname}-${clst_version_stamp}.config