blob: a2ebe09322f90c8b271c53fc1ae40f9d2e48ca3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
#!/bin/bash
source /tmp/chroot-functions.sh
check_genkernel_version
install -d /tmp/kerncache
PKGDIR=/tmp/kerncache/${clst_kname}/ebuilds
setup_gk_args() {
# default genkernel args
GK_ARGS=(
"${clst_kernel_gk_kernargs[@]}"
--cachedir=/tmp/kerncache/${clst_kname}-genkernel_cache-${clst_version_stamp}
--no-mountboot
--kerneldir=/usr/src/linux
--modulespackage=/tmp/kerncache/${clst_kname}-modules-${clst_version_stamp}.tar.bz2
--minkernpackage=/tmp/kerncache/${clst_kname}-kernel-initrd-${clst_version_stamp}.tar.bz2 all
)
# extra genkernel options that we have to test for
if [ -n "${clst_gk_mainargs}" ]
then
GK_ARGS+=("${clst_gk_mainargs}")
fi
if [ -n "${clst_KERNCACHE}" ]
then
GK_ARGS+=(--kerncache=/tmp/kerncache/${clst_kname}-kerncache-${clst_version_stamp}.tar.bz2)
fi
if [ -e /var/tmp/${clst_kname}.config ]
then
GK_ARGS+=(--kernel-config=/var/tmp/${clst_kname}.config)
fi
if [ -n "${clst_splash_theme}" ]
then
GK_ARGS+=(--splash=${clst_splash_theme})
# Setup case structure for livecd_type
case ${clst_livecd_type} in
gentoo-release-minimal|gentoo-release-universal)
case ${clst_hostarch} in
amd64|x86)
GK_ARGS+=(--splash-res=1024x768)
;;
esac
;;
esac
fi
if [ -d "/tmp/initramfs_overlay/${clst_initramfs_overlay}" ]
then
GK_ARGS+=(--initramfs-overlay=/tmp/initramfs_overlay/${clst_initramfs_overlay})
fi
if [ -n "${clst_CCACHE}" ]
then
GK_ARGS+=(--kernel-cc=/usr/lib/ccache/bin/gcc --utils-cc=/usr/lib/ccache/bin/gcc)
fi
if [ -n "${clst_linuxrc}" ]
then
GK_ARGS+=(--linuxrc=/tmp/linuxrc)
fi
if [ -n "${clst_busybox_config}" ]
then
GK_ARGS+=(--busybox-config=/tmp/busy-config)
fi
if [ "${clst_target}" == "netboot2" ]
then
GK_ARGS+=(--netboot)
if [ -n "${clst_merge_path}" ]
then
GK_ARGS+=(--initramfs-overlay="${clst_merge_path}")
fi
fi
if [[ "${clst_VERBOSE}" == "true" ]]
then
GK_ARGS+=(--loglevel=2)
fi
}
genkernel_compile(){
eval "clst_initramfs_overlay=\$clst_boot_kernel_${filtered_kname}_initramfs_overlay"
eval "clst_kernel_merge=\$clst_boot_kernel_${filtered_kname}_packages"
setup_gk_args
#echo "The GK_ARGS are"
#echo ${GK_ARGS[@]}
export clst_kernel_merge
export clst_initramfs_overlay
# Build our list of kernel packages
case ${clst_livecd_type} in
gentoo-release-live*)
if [ -n "${clst_kernel_merge}" ]
then
mkdir -p /usr/livecd
echo "${clst_kernel_merge}" > /usr/livecd/kernelpkgs.txt
fi
;;
esac
# Build with genkernel using the set options
# callback is put here to avoid escaping issues
if [[ "${clst_VERBOSE}" == "true" ]]
then
gk_callback_opts="-vN"
else
gk_callback_opts="-qN"
fi
PKGDIR=${PKGDIR}
if [ -n "${clst_KERNCACHE}" ]
then
gk_callback_opts="${gk_callback_opts} -kb"
fi
if [ -n "${clst_FETCH}" ]
then
gk_callback_opts="${gk_callback_opts} -f"
fi
if [ "${clst_kernel_merge}" != "" ]
then
genkernel --callback="emerge ${gk_callback_opts} ${clst_kernel_merge}" \
"${GK_ARGS[@]}" || exit 1
else
genkernel "${GK_ARGS[@]}" || exit 1
fi
if [ -n "${clst_KERNCACHE}" -a -e /var/tmp/${clst_kname}.config ]
then
md5sum /var/tmp/${clst_kname}.config | awk '{print $1}' > \
/tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG
fi
}
build_kernel() {
genkernel_compile
}
[ -n "${clst_ENVSCRIPT}" ] && source /tmp/envscript
export CONFIG_PROTECT="-*"
# Set the timezone for the kernel build
rm /etc/localtime
cp -f /usr/share/zoneinfo/UTC /etc/localtime
filtered_kname=${clst_kname/-/_}
filtered_kname=${clst_kname/\//_}
filtered_kname=${filtered_kname/\./_}
eval "clst_kernel_use=\$clst_boot_kernel_${filtered_kname}_use"
eval eval clst_kernel_gk_kernargs=( \$clst_boot_kernel_${filtered_kname}_gk_kernargs )
eval "clst_ksource=\$clst_boot_kernel_${filtered_kname}_sources"
if [ -z "${clst_ksource}" ]
then
clst_ksource="virtual/linux-sources"
fi
# Don't use pkgcache here, as the kernel source may get emerged with different
# USE variables (and thus different patches enabled/disabled.) Also, there's no
# real benefit in using the pkgcache for kernel source ebuilds.
# Check if we have a match in kerncach
if [ -n "${clst_KERNCACHE}" ]
then
USE_MATCH=0
if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE ]
then
STR1=$(for i in `cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE`; do echo $i; done|sort)
STR2=$(for i in ${clst_kernel_use}; do echo $i; done|sort)
if [ "${STR1}" = "${STR2}" ]
then
#echo "USE Flags match"
USE_MATCH=1
else
[ -d /tmp/kerncache/${clst_kname}/ebuilds ] && \
rm -r /tmp/kerncache/${clst_kname}/ebuilds
[ -e /tmp/kerncache/${clst_kname}/usr/src/linux/.config ] && \
rm /tmp/kerncache/${clst_kname}/usr/src/linux/.config
fi
fi
EXTRAVERSION_MATCH=0
if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION ]
then
STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION`
STR2=${clst_kextraversion}
if [ "${STR1}" = "${STR2}" ]
then
#echo "EXTRAVERSION match"
EXTRAVERSION_MATCH=1
fi
fi
CONFIG_MATCH=0
if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG ]
then
if [ ! -e /var/tmp/${clst_kname}.config ]
then
CONFIG_MATCH=1
else
STR1=`cat /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.CONFIG`
STR2=`md5sum /var/tmp/${clst_kname}.config|awk '{print $1}'`
if [ "${STR1}" = "${STR2}" ]
then
CONFIG_MATCH=1
fi
fi
fi
# install dependencies of kernel sources ahead of time in case
# package.provided generated below causes them not to be (re)installed
PKGDIR=${PKGDIR} clst_myemergeopts="--quiet --update --newuse --onlydeps" run_merge "${clst_ksource}" || exit 1
# Create the kerncache directory if it doesn't exists
mkdir -p /tmp/kerncache/${clst_kname}
if [ -e /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.KERNELVERSION ]
then
KERNELVERSION=$(</tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.KERNELVERSION)
mkdir -p ${clst_port_conf}/profile
echo "${KERNELVERSION}" > ${clst_port_conf}/profile/package.provided
else
rm -f ${clst_port_conf}/profile/package.provided
fi
# Don't use package.provided if there's a pending up/downgrade
if [[ "$(portageq best_visible / ${clst_ksource})" == "${KERNELVERSION}" ]]; then
echo "No pending updates for ${clst_ksource}"
else
echo "Pending updates for ${clst_ksource}, removing package.provided"
rm ${clst_port_conf}/profile/package.provided
fi
[ -L /usr/src/linux ] && rm -f /usr/src/linux
PKGDIR=${PKGDIR} clst_myemergeopts="--quiet --update --newuse" run_merge "${clst_ksource}" || exit 1
SOURCESDIR="/tmp/kerncache/${clst_kname}/sources"
if [ -L /usr/src/linux ]
then
# A kernel was merged, move it to $SOURCESDIR
[ -e ${SOURCESDIR} ] && rm -Rf ${SOURCESDIR}
KERNELVERSION=`portageq best_visible / "${clst_ksource}"`
echo "${KERNELVERSION}" > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.KERNELVERSION
echo "Moving kernel sources to ${SOURCESDIR} ..."
mv `readlink -f /usr/src/linux` ${SOURCESDIR}
fi
ln -sf ${SOURCESDIR} /usr/src/linux
# If catalyst has set to a empty string, extraversion wasn't specified so we
# skip this part
if [ "${EXTRAVERSION_MATCH}" = "0" ]
then
if [ ! "${clst_kextraversion}" = "" ]
then
echo "Setting extraversion to ${clst_kextraversion}"
${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
echo ${clst_kextraversion} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
else
touch /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.EXTRAVERSION
fi
fi
else
run_merge "${clst_ksource}" || exit 1
#ensure that there is a /usr/src/linux symlink and it points to the sources we just installed
echo "Adjusting /usr/src/linux to point to \
$(portageq contents / $(portageq best_visible / "${clst_ksource}" 2>/dev/null) 2>/dev/null | grep --color=never '/usr/src/' | head -n1 2>/dev/null)"
ln -snf $(portageq contents / $(portageq best_visible / "${clst_ksource}" 2>/dev/null) 2>/dev/null | grep --color=never '/usr/src/' | head -n1 2>/dev/null) \
/usr/src/linux
if [ ! "${clst_kextraversion}" = "" ]
then
echo "Setting extraversion to ${clst_kextraversion}"
${clst_sed} -i -e "s:EXTRAVERSION \(=.*\):EXTRAVERSION \1-${clst_kextraversion}:" /usr/src/linux/Makefile
fi
fi
# Update USE flag in make.conf
[ -e ${clst_make_conf} ] && \
echo "USE=\"\${USE} ${clst_kernel_use} build\"" >> ${clst_make_conf}
make_destpath
build_kernel
${clst_sed} -i "/USE=\"\${USE} ${clst_kernel_use} \"/d" ${clst_make_conf}
# grep out the kernel version so that we can do our modules magic
VER=`grep ^VERSION\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
PAT=`grep ^PATCHLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
SUB=`grep ^SUBLEVEL\ \= /usr/src/linux/Makefile | awk '{ print $3 };'`
EXV=`grep ^EXTRAVERSION\ \= /usr/src/linux/Makefile | ${clst_sed} -e "s/EXTRAVERSION =//" -e "s/ //g"`
clst_fudgeuname=${VER}.${PAT}.${SUB}${EXV}
unset USE
if [ -n "${clst_KERNCACHE}" ]
then
echo ${clst_kernel_use} > /tmp/kerncache/${clst_kname}/${clst_kname}-${clst_version_stamp}.USE
fi
|