8 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
10 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
12 if [ "${KERNEL_CC}" != '' ]
14 ARGS="CC=\"${KERNEL_CC}\""
16 if [ "${KERNEL_LD}" != '' ]
18 ARGS="${ARGS} LD=\"${KERNEL_LD}\""
20 if [ "${KERNEL_AS}" != '' ]
22 ARGS="${ARGS} AS=\"${KERNEL_AS}\""
33 if [ "${UTILS_ARCH}" != '' ]
35 ARGS="ARCH=\"${UTILS_ARCH}\""
37 if [ "${UTILS_CC}" != '' ]
39 ARGS="CC=\"${UTILS_CC}\""
41 if [ "${UTILS_LD}" != '' ]
43 ARGS="${ARGS} LD=\"${UTILS_LD}\""
45 if [ "${UTILS_AS}" != '' ]
47 ARGS="${ARGS} AS=\"${UTILS_AS}\""
56 if [ "${UTILS_ARCH}" != '' ]
58 export ARCH="${UTILS_ARCH}"
60 if [ "${UTILS_CC}" != '' ]
62 export CC="${UTILS_CC}"
64 if [ "${UTILS_LD}" != '' ]
66 export LD="${UTILS_LD}"
68 if [ "${UTILS_AS}" != '' ]
70 export AS="${UTILS_AS}"
76 if [ "${UTILS_ARCH}" != '' ]
80 if [ "${UTILS_CC}" != '' ]
84 if [ "${UTILS_LD}" != '' ]
88 if [ "${UTILS_AS}" != '' ]
97 if [ "${KERNEL_CC}" != '' ]
99 export CC="${KERNEL_CC}"
101 if [ "${KERNEL_LD}" != '' ]
103 export LD="${KERNEL_LD}"
105 if [ "${KERNEL_AS}" != '' ]
107 export AS="${KERNEL_AS}"
109 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
111 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
117 if [ "${KERNEL_CC}" != '' ]
121 if [ "${KERNEL_LD}" != '' ]
125 if [ "${KERNEL_AS}" != '' ]
129 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
136 if [ "${ARCH}" != '' ]
138 export ORIG_ARCH="${ARCH}"
142 export ORIG_CC="${CC}"
146 export ORIG_LD="${LD}"
150 export ORIG_AS="${AS}"
152 if [ "${CROSS_COMPILE}" != '' ]
154 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
159 if [ "${ORIG_ARCH}" != '' ]
161 export ARCH="${ORIG_ARCH}"
164 if [ "${ORIG_CC}" != '' ]
166 export CC="${ORIG_CC}"
169 if [ "${ORIG_LD}" != '' ]
171 export LD="${ORIG_LD}"
174 if [ "${ORIG_AS}" != '' ]
176 export AS="${ORIG_AS}"
179 if [ "${ORIG_CROSS_COMPILE}" != '' ]
181 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
182 unset ORIG_CROSS_COMPILE
190 gen_die 'compile_generic(): improper usage!'
194 if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
198 elif [ "${2}" = 'utils' ]
203 case "${argstype}" in
204 kernel) ARGS="`compile_kernel_args`" ;;
205 utils) ARGS="`compile_utils_args`" ;;
206 *) ARGS="" ;; # includes runtask
211 # the eval usage is needed in the next set of code
212 # as ARGS can contain spaces and quotes, eg:
213 # ARGS='CC="ccache gcc"'
214 if [ "${argstype}" == 'runtask' ]
216 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
217 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
219 elif [ "${DEBUGLEVEL}" -gt "1" ]
221 # Output to stdout and debugfile
222 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
223 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${DEBUGFILE}
226 # Output to debugfile only
227 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
228 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${DEBUGFILE} 2>&1
231 [ "${RET}" -ne '0' ] &&
232 gen_die "Failed to compile the \"${target}\" target..."
236 if [ "${argstype}" = 'kernel' ]
239 elif [ "${argstype}" = 'utils' ]
245 extract_dietlibc_bincache() {
247 rm -rf "${TEMP}/diet" > /dev/null
248 /bin/tar -jxpf "${DIETLIBC_BINCACHE}" ||
249 gen_die 'Could not extract dietlibc bincache!'
250 [ ! -d "${TEMP}/diet" ] &&
251 gen_die "${TEMP}/diet directory not found!"
255 clean_dietlibc_bincache() {
257 rm -rf "${TEMP}/diet" > /dev/null
262 # Only run ``make dep'' for 2.4 kernels
263 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
265 print_info 1 "kernel: >> Making dependencies..."
267 compile_generic dep kernel
272 print_info 1 " >> Compiling ${KV} modules..."
274 compile_generic modules kernel
275 export UNAME_MACHINE="${ARCH}"
276 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
277 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
279 MAKEOPTS_SAVE="${MAKEOPTS}"
280 MAKEOPTS="${MAKEOPTS_SAVE/-j?/-j1}"
282 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
283 compile_generic "modules_install" kernel
284 [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ] && MAKEOPTS="${MAKEOPTS_SAVE}"
290 [ "${KERNEL_MAKE}" = '' ] &&
291 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
293 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
294 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
295 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
297 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
298 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
300 if ! isTrue "${CMD_NOINSTALL}"
302 copy_image_with_preserve "kernel" \
304 "kernel-${KNAME}-${ARCH}-${KV}"
306 copy_image_with_preserve "System.map" \
308 "System.map-${KNAME}-${ARCH}-${KV}"
310 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
312 copy_image_with_preserve "kernelz" \
313 "${KERNEL_BINARY_2}" \
317 cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
318 gen_die "Could not copy the kernel binary to ${TMPDIR}!"
319 cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
320 gen_die "Could not copy System.map to ${TMPDIR}!"
321 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
323 cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
324 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
329 compile_unionfs_modules() {
330 if [ ! -f "${UNIONFS_MODULES_BINCACHE}" ]
332 [ -f "${UNIONFS_SRCTAR}" ] ||
333 gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
335 rm -rf ${UNIONFS_DIR} > /dev/null
336 rm -rf unionfs* > /dev/null
338 /bin/tar xzpf ${UNIONFS_SRCTAR} ||
339 gen_die 'Could not extract unionfs source tarball!'
340 [ -d "${UNIONFS_DIR}" ] ||
341 gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
343 print_info 1 'unionfs modules: >> Compiling...'
344 echo "LINUXSRC=${KERNEL_DIR}" >> fistdev.mk
345 echo 'TOPINC=-I$(LINUXSRC)/include' >> fistdev.mk
346 echo "MODDIR= /lib/modules/${KV}" >> fistdev.mk
347 echo "KVERS=${KV}" >> fistdev.mk
348 echo "KERNELVERSION=${KV}" >> fistdev.mk
349 # Fix for hardened/selinux systems to have extened attributes
350 # per r2d2's request. Also add -DUNIONFS_UNSUPPORTED for 2.6.16
351 echo "EXTRACFLAGS=-DUNIONFS_XATTR -DFIST_SETXATTR_CONSTVOID -DUNIONFS_UNSUPPORTED" \
353 # Here we do something really nasty and disable debugging, along with
354 # change our default CFLAGS
355 echo "UNIONFS_DEBUG_CFLAG=-DUNIONFS_NDEBUG" >> fistdev.mk
356 echo "UNIONFS_OPT_CFLAG= -O2 -pipe" >> fistdev.mk
358 if [ "${PAT}" -ge '6' ]
360 # ARCH is used by unionfs - and conflicts with genkernel
363 # Compile unionfs module within the unionfs
364 # environment not within the kernelsrc dir
365 make unionfs.ko || gen_die 'failed to compile unionfs'
368 gen_die 'unionfs is only supported on 2.6 targets'
370 print_info 1 'unionfs: >> Copying to cache...'
372 mkdir -p ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
376 cp -f unionfs.ko ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
378 cp -f unionfs.o ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
382 /bin/tar -cjf "${UNIONFS_MODULES_BINCACHE}" . ||
383 gen_die 'Could not create unionfs modules binary cache'
386 rm -rf "${UNIONFS_DIR}" > /dev/null
387 rm -rf unionfs > /dev/null
391 compile_unionfs_utils() {
392 if [ ! -f "${UNIONFS_BINCACHE}" ]
394 [ -f "${UNIONFS_SRCTAR}" ] ||
395 gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
397 rm -rf ${UNIONFS_DIR} > /dev/null
398 rm -rf unionfs* > /dev/null
399 mkdir -p unionfs/sbin
400 /bin/tar -zxpf ${UNIONFS_SRCTAR} ||
401 gen_die 'Could not extract unionfs source tarball!'
402 [ -d "${UNIONFS_DIR}" ] ||
403 gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
405 print_info 1 'unionfs tools: >> Compiling...'
406 sed -i utils/Makefile -e 's|${CC} -o|${CC} -static -o|g'
407 sed -i Makefile -e 's|${CC} -o|${CC} -static -o|g'
408 compile_generic utils utils
410 if [ ! -e "uniondbg" ]; then
413 print_info 1 'unionfs: >> Copying to cache...'
414 strip uniondbg unionctl
415 cp uniondbg ${TEMP}/unionfs/sbin/ ||
416 gen_die 'Could not copy the uniondbg binary to the tmp directory'
417 cp unionctl ${TEMP}/unionfs/sbin/ ||
418 gen_die 'Could not copy the unionctl binary to the tmp directory'
420 /bin/tar -cjf "${UNIONFS_BINCACHE}" . ||
421 gen_die 'Could not create unionfs tools binary cache'
424 rm -rf "${UNIONFS_DIR}" > /dev/null
425 rm -rf unionfs > /dev/null
430 [ -f "${BUSYBOX_SRCTAR}" ] ||
431 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
432 [ -f "${BUSYBOX_CONFIG}" ] ||
433 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
435 rm -rf "${BUSYBOX_DIR}" > /dev/null
436 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
437 gen_die 'Could not extract busybox source tarball!'
438 [ -d "${BUSYBOX_DIR}" ] ||
439 gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
440 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
441 sed -i ${BUSYBOX_DIR}/.config -e 's/#\? \?CONFIG_FEATURE_INSTALLER[ =].*/CONFIG_FEATURE_INSTALLER=y/g'
443 print_info 1 'busybox: >> Configuring...'
444 yes '' 2>/dev/null | compile_generic oldconfig utils
446 # Delete cache if stored config's MD5 does not match one to be used
447 if [ -f "${BUSYBOX_BINCACHE}" -a -f "${BUSYBOX_CONFIG}" ]
449 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config | md5sum)
450 newconfig_md5=$(md5sum < .config)
451 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
453 print_info 1 "busybox: >> Removing stale cache..."
454 rm -rf "${BUSYBOX_BINCACHE}"
456 print_info 1 "busybox: >> Using cache"
460 if [ ! -f "${BUSYBOX_BINCACHE}" ]
462 print_info 1 'busybox: >> Compiling...'
463 compile_generic all utils
464 print_info 1 'busybox: >> Copying to cache...'
465 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
466 gen_die 'Busybox executable does not exist!'
467 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
468 gen_die 'Could not strip busybox binary!'
469 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config ||
470 gen_die 'Could not create the busybox bincache!'
474 rm -rf "${BUSYBOX_DIR}" > /dev/null
478 compile_device_mapper
479 if [ ! -f "${LVM_BINCACHE}" ]
481 [ -f "${LVM_SRCTAR}" ] ||
482 gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
484 rm -rf ${LVM_DIR} > /dev/null
485 /bin/tar -zxpf ${LVM_SRCTAR} ||
486 gen_die 'Could not extract LVM source tarball!'
487 [ -d "${LVM_DIR}" ] ||
488 gen_die 'LVM directory ${LVM_DIR} is invalid!'
489 rm -rf "${TEMP}/device-mapper" > /dev/null
490 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
491 gen_die "Could not extract device-mapper binary cache!";
494 print_info 1 'lvm: >> Configuring...'
495 LDFLAGS="-L${TEMP}/device-mapper/lib" \
496 CFLAGS="-I${TEMP}/device-mapper/include" \
497 CPPFLAGS="-I${TEMP}/device-mapper/include" \
498 ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${DEBUGFILE} 2>&1 ||
499 gen_die 'Configure of lvm failed!'
500 print_info 1 'lvm: >> Compiling...'
501 compile_generic '' utils
502 compile_generic 'install' utils
505 print_info 1 ' >> Copying to bincache...'
506 strip "sbin/lvm.static" ||
507 gen_die 'Could not strip lvm.static!'
508 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static ||
509 gen_die 'Could not create binary cache'
512 rm -rf "${TEMP}/device-mapper" > /dev/null
513 rm -rf "${LVM_DIR}" lvm
518 compile_device_mapper
519 if [ ! -f "${DMRAID_BINCACHE}" ]
521 [ -f "${DMRAID_SRCTAR}" ] ||
522 gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
524 rm -rf ${DMRAID_DIR} > /dev/null
525 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
526 gen_die 'Could not extract DMRAID source tarball!'
527 [ -d "${DMRAID_DIR}" ] ||
528 gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
529 rm -rf "${TEMP}/device-mapper" > /dev/null
530 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
531 gen_die "Could not extract device-mapper binary cache!";
534 print_info 1 'dmraid: >> Configuring...'
536 LDFLAGS="-L${TEMP}/device-mapper/lib" \
537 CFLAGS="-I${TEMP}/device-mapper/include" \
538 CPPFLAGS="-I${TEMP}/device-mapper/include" \
539 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${DEBUGFILE} 2>&1 ||
540 gen_die 'Configure of dmraid failed!'
542 # We dont necessarily have selinux installed yet... look into
543 # selinux global support in the future.
544 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
545 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
546 mkdir -p "${TEMP}/dmraid"
547 print_info 1 'dmraid: >> Compiling...'
548 compile_generic '' utils
549 #compile_generic 'install' utils
550 mkdir ${TEMP}/dmraid/sbin
551 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
552 print_info 1 ' >> Copying to bincache...'
554 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
555 gen_die 'Could not create binary cache'
558 rm -rf "${TEMP}/device-mapper" > /dev/null
559 rm -rf "${DMRAID_DIR}" dmraid
565 if [ ! -f "${DEVFSD_BINCACHE}" ]
567 [ ! -f "${DEVFSD_SRCTAR}" ] &&
568 gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
570 rm -rf "${DEVFSD_DIR}"
571 /bin/tar -jxpf "${DEVFSD_SRCTAR}"
572 [ ! -d "${DEVFSD_DIR}" ] &&
573 gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
576 print_info 1 'devfsd: >> Compiling...'
577 compile_generic 'LDFLAGS=-static' utils
579 print_info 1 ' >> Copying to cache...'
580 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] || gen_die 'The devfsd executable does not exist after the compilation of devfsd!'
581 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Could not strip devfsd!'
582 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Compression of devfsd failed!'
583 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!'
584 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!'
587 rm -rf "${DEVFSD_DIR}" > /dev/null
591 compile_device_mapper() {
592 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
594 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
595 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!"
597 rm -rf "${DEVICE_MAPPER_DIR}"
598 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
599 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
600 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
601 cd "${DEVICE_MAPPER_DIR}"
602 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
603 --disable-selinux >> ${DEBUGFILE} 2>&1 ||
604 gen_die 'Configuring device-mapper failed!'
605 print_info 1 'device-mapper: >> Compiling...'
606 compile_generic '' utils
607 compile_generic 'install' utils
608 print_info 1 ' >> Copying to cache...'
610 rm -r "${TEMP}/device-mapper/man" ||
611 gen_die 'Could not remove manual pages!'
612 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
613 gen_die 'Could not strip dmsetup binary!'
614 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
615 gen_die 'Could not tar up the device-mapper binary!'
616 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
617 gen_die 'device-mapper cache not created!'
619 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
620 rm -rf "${TEMP}/device-mapper" > /dev/null
624 compile_e2fsprogs() {
625 if [ ! -f "${BLKID_BINCACHE}" ]
627 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
628 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
630 rm -rf "${E2FSPROGS_DIR}"
631 tar -zxpf "${E2FSPROGS_SRCTAR}"
632 [ ! -d "${E2FSPROGS_DIR}" ] &&
633 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
634 cd "${E2FSPROGS_DIR}"
635 print_info 1 'e2fsprogs: >> Configuring...'
636 ./configure --with-ldopts=-static >> ${DEBUGFILE} 2>&1 ||
637 gen_die 'Configuring e2fsprogs failed!'
638 print_info 1 'e2fsprogs: >> Compiling...'
639 MAKE=${UTILS_MAKE} compile_generic "" ""
640 print_info 1 'blkid: >> Copying to cache...'
641 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
642 gen_die 'Blkid executable does not exist!'
643 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
644 gen_die 'Could not strip blkid binary!'
645 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
646 gen_die 'bzip2 compression of blkid failed!'
647 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
648 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
651 rm -rf "${E2FSPROGS_DIR}" > /dev/null