3 compile_kernel_args() {
7 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
9 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
11 if [ "${KERNEL_CC}" != '' ]
13 ARGS="CC=\"${KERNEL_CC}\""
15 if [ "${KERNEL_LD}" != '' ]
17 ARGS="${ARGS} LD=\"${KERNEL_LD}\""
19 if [ "${KERNEL_AS}" != '' ]
21 ARGS="${ARGS} AS=\"${KERNEL_AS}\""
32 if [ "${UTILS_ARCH}" != '' ]
34 ARGS="ARCH=\"${UTILS_ARCH}\""
36 if [ "${UTILS_CC}" != '' ]
38 ARGS="CC=\"${UTILS_CC}\""
40 if [ "${UTILS_LD}" != '' ]
42 ARGS="${ARGS} LD=\"${UTILS_LD}\""
44 if [ "${UTILS_AS}" != '' ]
46 ARGS="${ARGS} AS=\"${UTILS_AS}\""
55 if [ "${UTILS_ARCH}" != '' ]
57 export ARCH="${UTILS_ARCH}"
59 if [ "${UTILS_CC}" != '' ]
61 export CC="${UTILS_CC}"
63 if [ "${UTILS_LD}" != '' ]
65 export LD="${UTILS_LD}"
67 if [ "${UTILS_AS}" != '' ]
69 export AS="${UTILS_AS}"
75 if [ "${UTILS_ARCH}" != '' ]
79 if [ "${UTILS_CC}" != '' ]
83 if [ "${UTILS_LD}" != '' ]
87 if [ "${UTILS_AS}" != '' ]
96 if [ "${KERNEL_CC}" != '' ]
98 export CC="${KERNEL_CC}"
100 if [ "${KERNEL_LD}" != '' ]
102 export LD="${KERNEL_LD}"
104 if [ "${KERNEL_AS}" != '' ]
106 export AS="${KERNEL_AS}"
108 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
110 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
116 if [ "${KERNEL_CC}" != '' ]
120 if [ "${KERNEL_LD}" != '' ]
124 if [ "${KERNEL_AS}" != '' ]
128 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
135 if [ "${ARCH}" != '' ]
137 export ORIG_ARCH="${ARCH}"
141 export ORIG_CC="${CC}"
145 export ORIG_LD="${LD}"
149 export ORIG_AS="${AS}"
151 if [ "${CROSS_COMPILE}" != '' ]
153 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
158 if [ "${ORIG_ARCH}" != '' ]
160 export ARCH="${ORIG_ARCH}"
163 if [ "${ORIG_CC}" != '' ]
165 export CC="${ORIG_CC}"
168 if [ "${ORIG_LD}" != '' ]
170 export LD="${ORIG_LD}"
173 if [ "${ORIG_AS}" != '' ]
175 export AS="${ORIG_AS}"
178 if [ "${ORIG_CROSS_COMPILE}" != '' ]
180 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
181 unset ORIG_CROSS_COMPILE
189 gen_die 'compile_generic(): improper usage!'
193 if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
197 elif [ "${2}" = 'utils' ]
202 case "${argstype}" in
203 kernel) ARGS="`compile_kernel_args`" ;;
204 utils) ARGS="`compile_utils_args`" ;;
205 *) ARGS="" ;; # includes runtask
209 # the eval usage is needed in the next set of code
210 # as ARGS can contain spaces and quotes, eg:
211 # ARGS='CC="ccache gcc"'
212 if [ "${argstype}" == 'runtask' ]
214 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
215 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
217 elif [ "${LOGLEVEL}" -gt "1" ]
219 # Output to stdout and logfile
220 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
221 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
224 # Output to logfile only
225 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
226 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
229 [ "${RET}" -ne '0' ] &&
230 gen_die "Failed to compile the \"${target}\" target..."
234 if [ "${argstype}" = 'kernel' ]
237 elif [ "${argstype}" = 'utils' ]
243 extract_dietlibc_bincache() {
245 rm -rf "${TEMP}/diet" > /dev/null
246 /bin/tar -jxpf "${DIETLIBC_BINCACHE}" ||
247 gen_die 'Could not extract dietlibc bincache!'
248 [ ! -d "${TEMP}/diet" ] &&
249 gen_die "${TEMP}/diet directory not found!"
253 clean_dietlibc_bincache() {
255 rm -rf "${TEMP}/diet" > /dev/null
260 # Only run ``make dep'' for 2.4 kernels
261 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
263 print_info 1 "kernel: >> Making dependencies..."
265 compile_generic dep kernel
270 print_info 1 " >> Compiling ${KV} modules..."
272 compile_generic modules kernel
273 export UNAME_MACHINE="${ARCH}"
274 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
275 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
277 MAKEOPTS_SAVE="${MAKEOPTS}"
278 MAKEOPTS="${MAKEOPTS_SAVE/-j?/-j1}"
280 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
281 compile_generic "modules_install" kernel
282 [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ] && MAKEOPTS="${MAKEOPTS_SAVE}"
288 [ "${KERNEL_MAKE}" = '' ] &&
289 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
291 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
292 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
293 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
295 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
296 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
298 if ! isTrue "${CMD_NOINSTALL}"
300 copy_image_with_preserve "kernel" \
302 "kernel-${KNAME}-${ARCH}-${KV}"
304 copy_image_with_preserve "System.map" \
306 "System.map-${KNAME}-${ARCH}-${KV}"
308 if [ "${ENABLE_PEGASOS_HACKS}" = 'yes' ]
310 copy_image_with_preserve "kernelz" \
311 "${KERNEL_BINARY_2}" \
315 cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
316 gen_die "Could not copy the kernel binary to ${TMPDIR}!"
317 cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
318 gen_die "Could not copy System.map to ${TMPDIR}!"
319 if [ "${ENABLE_PEGASOS_HACKS}" = 'yes' ]
321 cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
322 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
328 [ -f "${BUSYBOX_SRCTAR}" ] ||
329 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
330 [ -f "${BUSYBOX_CONFIG}" ] ||
331 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
333 rm -rf "${BUSYBOX_DIR}" > /dev/null
334 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
335 gen_die 'Could not extract busybox source tarball!'
336 [ -d "${BUSYBOX_DIR}" ] ||
337 gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
338 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
339 sed -i ${BUSYBOX_DIR}/.config -e 's/#\? \?CONFIG_FEATURE_INSTALLER[ =].*/CONFIG_FEATURE_INSTALLER=y/g'
341 patch -p1 < "${GK_SHARE}/pkg/busybox-1.1.3+gentoo-mdadm.patch"
342 patch -p1 < "${GK_SHARE}/pkg/busybox-1.1.3+gentoo-mdadm2.patch"
343 print_info 1 'busybox: >> Configuring...'
344 yes '' 2>/dev/null | compile_generic oldconfig utils
346 # Delete cache if stored config's MD5 does not match one to be used
347 if [ -f "${BUSYBOX_BINCACHE}" -a -f "${BUSYBOX_CONFIG}" ]
349 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config | md5sum)
350 newconfig_md5=$(md5sum < .config)
351 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
353 print_info 1 "busybox: >> Removing stale cache..."
354 rm -rf "${BUSYBOX_BINCACHE}"
356 print_info 1 "busybox: >> Using cache"
360 if [ ! -f "${BUSYBOX_BINCACHE}" ]
362 print_info 1 'busybox: >> Compiling...'
363 compile_generic all utils
364 print_info 1 'busybox: >> Copying to cache...'
365 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
366 gen_die 'Busybox executable does not exist!'
367 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
368 gen_die 'Could not strip busybox binary!'
369 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config ||
370 gen_die 'Could not create the busybox bincache!'
374 rm -rf "${BUSYBOX_DIR}" > /dev/null
378 compile_device_mapper
379 if [ ! -f "${LVM_BINCACHE}" ]
381 [ -f "${LVM_SRCTAR}" ] ||
382 gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
384 rm -rf ${LVM_DIR} > /dev/null
385 /bin/tar -zxpf ${LVM_SRCTAR} ||
386 gen_die 'Could not extract LVM source tarball!'
387 [ -d "${LVM_DIR}" ] ||
388 gen_die 'LVM directory ${LVM_DIR} is invalid!'
389 rm -rf "${TEMP}/device-mapper" > /dev/null
390 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
391 gen_die "Could not extract device-mapper binary cache!";
394 print_info 1 'lvm: >> Configuring...'
395 LDFLAGS="-L${TEMP}/device-mapper/lib" \
396 CFLAGS="-I${TEMP}/device-mapper/include" \
397 CPPFLAGS="-I${TEMP}/device-mapper/include" \
398 ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${LOGFILE} 2>&1 ||
399 gen_die 'Configure of lvm failed!'
400 print_info 1 'lvm: >> Compiling...'
401 compile_generic '' utils
402 compile_generic 'install' utils
405 print_info 1 ' >> Copying to bincache...'
406 strip "sbin/lvm.static" ||
407 gen_die 'Could not strip lvm.static!'
408 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static ||
409 gen_die 'Could not create binary cache'
412 rm -rf "${TEMP}/device-mapper" > /dev/null
413 rm -rf "${LVM_DIR}" lvm
418 compile_device_mapper
419 if [ ! -f "${DMRAID_BINCACHE}" ]
421 [ -f "${DMRAID_SRCTAR}" ] ||
422 gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
424 rm -rf ${DMRAID_DIR} > /dev/null
425 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
426 gen_die 'Could not extract DMRAID source tarball!'
427 [ -d "${DMRAID_DIR}" ] ||
428 gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
429 rm -rf "${TEMP}/device-mapper" > /dev/null
430 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
431 gen_die "Could not extract device-mapper binary cache!";
434 print_info 1 'dmraid: >> Configuring...'
436 LDFLAGS="-L${TEMP}/device-mapper/lib" \
437 CFLAGS="-I${TEMP}/device-mapper/include" \
438 CPPFLAGS="-I${TEMP}/device-mapper/include" \
439 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 ||
440 gen_die 'Configure of dmraid failed!'
442 # We dont necessarily have selinux installed yet... look into
443 # selinux global support in the future.
444 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
445 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
446 mkdir -p "${TEMP}/dmraid"
447 print_info 1 'dmraid: >> Compiling...'
448 # Force dmraid to be built with -j1 for bug #188273
449 MAKEOPTS=-j1 compile_generic '' utils
450 #compile_generic 'install' utils
451 mkdir ${TEMP}/dmraid/sbin
452 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
453 print_info 1 ' >> Copying to bincache...'
455 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
456 gen_die 'Could not create binary cache'
459 rm -rf "${TEMP}/device-mapper" > /dev/null
460 rm -rf "${DMRAID_DIR}" dmraid
466 if [ ! -f "${DEVFSD_BINCACHE}" ]
468 [ ! -f "${DEVFSD_SRCTAR}" ] &&
469 gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
471 rm -rf "${DEVFSD_DIR}"
472 /bin/tar -jxpf "${DEVFSD_SRCTAR}"
473 [ ! -d "${DEVFSD_DIR}" ] &&
474 gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
477 print_info 1 'devfsd: >> Compiling...'
478 compile_generic 'LDFLAGS=-static' utils
480 print_info 1 ' >> Copying to cache...'
481 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] || gen_die 'The devfsd executable does not exist after the compilation of devfsd!'
482 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Could not strip devfsd!'
483 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Compression of devfsd failed!'
484 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!'
485 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!'
488 rm -rf "${DEVFSD_DIR}" > /dev/null
492 compile_device_mapper() {
493 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
495 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
496 gen_die "Could not find device-mapper source tarball: ${DEVICE_MAPPER_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
498 rm -rf "${DEVICE_MAPPER_DIR}"
499 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
500 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
501 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
502 cd "${DEVICE_MAPPER_DIR}"
503 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
504 --disable-selinux >> ${LOGFILE} 2>&1 ||
505 gen_die 'Configuring device-mapper failed!'
506 print_info 1 'device-mapper: >> Compiling...'
507 compile_generic '' utils
508 compile_generic 'install' utils
509 print_info 1 ' >> Copying to cache...'
511 rm -rf "${TEMP}/device-mapper/man" ||
512 gen_die 'Could not remove manual pages!'
513 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
514 gen_die 'Could not strip dmsetup binary!'
515 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
516 gen_die 'Could not tar up the device-mapper binary!'
517 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
518 gen_die 'device-mapper cache not created!'
520 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
521 rm -rf "${TEMP}/device-mapper" > /dev/null
525 compile_e2fsprogs() {
526 if [ ! -f "${BLKID_BINCACHE}" ]
528 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
529 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
531 rm -rf "${E2FSPROGS_DIR}"
532 tar -zxpf "${E2FSPROGS_SRCTAR}"
533 [ ! -d "${E2FSPROGS_DIR}" ] &&
534 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
535 cd "${E2FSPROGS_DIR}"
536 print_info 1 'e2fsprogs: >> Configuring...'
537 ./configure --with-ldopts=-static >> ${LOGFILE} 2>&1 ||
538 gen_die 'Configuring e2fsprogs failed!'
539 print_info 1 'e2fsprogs: >> Compiling...'
540 MAKE=${UTILS_MAKE} compile_generic "" ""
541 print_info 1 'blkid: >> Copying to cache...'
542 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
543 gen_die 'Blkid executable does not exist!'
544 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
545 gen_die 'Could not strip blkid binary!'
546 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
547 gen_die 'bzip2 compression of blkid failed!'
548 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
549 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
552 rm -rf "${E2FSPROGS_DIR}" > /dev/null