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}\""
23 if [ -n "${KERNEL_ARCH}" ]
25 ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\""
36 if [ "${UTILS_ARCH}" != '' ]
38 ARGS="ARCH=\"${UTILS_ARCH}\""
40 if [ "${UTILS_CC}" != '' ]
42 ARGS="CC=\"${UTILS_CC}\""
44 if [ "${UTILS_LD}" != '' ]
46 ARGS="${ARGS} LD=\"${UTILS_LD}\""
48 if [ "${UTILS_AS}" != '' ]
50 ARGS="${ARGS} AS=\"${UTILS_AS}\""
59 if [ "${UTILS_ARCH}" != '' ]
61 export ARCH="${UTILS_ARCH}"
63 if [ "${UTILS_CC}" != '' ]
65 export CC="${UTILS_CC}"
67 if [ "${UTILS_LD}" != '' ]
69 export LD="${UTILS_LD}"
71 if [ "${UTILS_AS}" != '' ]
73 export AS="${UTILS_AS}"
79 if [ "${UTILS_ARCH}" != '' ]
83 if [ "${UTILS_CC}" != '' ]
87 if [ "${UTILS_LD}" != '' ]
91 if [ "${UTILS_AS}" != '' ]
100 if [ "${KERNEL_CC}" != '' ]
102 export CC="${KERNEL_CC}"
104 if [ "${KERNEL_LD}" != '' ]
106 export LD="${KERNEL_LD}"
108 if [ "${KERNEL_AS}" != '' ]
110 export AS="${KERNEL_AS}"
112 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
114 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
120 if [ "${KERNEL_CC}" != '' ]
124 if [ "${KERNEL_LD}" != '' ]
128 if [ "${KERNEL_AS}" != '' ]
132 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
139 if [ "${ARCH}" != '' ]
141 export ORIG_ARCH="${ARCH}"
145 export ORIG_CC="${CC}"
149 export ORIG_LD="${LD}"
153 export ORIG_AS="${AS}"
155 if [ "${CROSS_COMPILE}" != '' ]
157 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
162 if [ "${ORIG_ARCH}" != '' ]
164 export ARCH="${ORIG_ARCH}"
167 if [ "${ORIG_CC}" != '' ]
169 export CC="${ORIG_CC}"
172 if [ "${ORIG_LD}" != '' ]
174 export LD="${ORIG_LD}"
177 if [ "${ORIG_AS}" != '' ]
179 export AS="${ORIG_AS}"
182 if [ "${ORIG_CROSS_COMPILE}" != '' ]
184 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
185 unset ORIG_CROSS_COMPILE
193 if [ -d "${GK_SHARE}/patches/${util}/${version}" ]
195 print_info 1 "${util}: >> Applying patches..."
196 for i in ${GK_SHARE}/patches/${util}/${version}/*{diff,patch}
201 patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null
208 if [ ${patch_success} != 1 ]
210 gen_die "could not apply patch ${i} for ${util}-${version}"
219 gen_die 'compile_generic(): improper usage!'
223 if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
227 elif [ "${2}" = 'utils' ]
232 case "${argstype}" in
233 kernel) ARGS="`compile_kernel_args`" ;;
234 utils) ARGS="`compile_utils_args`" ;;
235 *) ARGS="" ;; # includes runtask
239 # the eval usage is needed in the next set of code
240 # as ARGS can contain spaces and quotes, eg:
241 # ARGS='CC="ccache gcc"'
242 if [ "${argstype}" == 'runtask' ]
244 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
245 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
247 elif [ "${LOGLEVEL}" -gt "1" ]
249 # Output to stdout and logfile
250 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
251 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
254 # Output to logfile only
255 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
256 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
259 [ "${RET}" -ne '0' ] &&
260 gen_die "Failed to compile the \"${target}\" target..."
264 if [ "${argstype}" = 'kernel' ]
267 elif [ "${argstype}" = 'utils' ]
274 print_info 1 " >> Compiling ${KV} modules..."
276 compile_generic modules kernel
277 export UNAME_MACHINE="${ARCH}"
278 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
279 compile_generic "modules_install" kernel
284 [ "${KERNEL_MAKE}" = '' ] &&
285 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
287 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
288 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
289 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
291 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
292 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
294 if ! isTrue "${CMD_NOINSTALL}"
296 copy_image_with_preserve "kernel" \
298 "kernel-${KNAME}-${ARCH}-${KV}"
300 copy_image_with_preserve "System.map" \
302 "System.map-${KNAME}-${ARCH}-${KV}"
304 if isTrue "${GENZIMAGE}"
306 copy_image_with_preserve "kernelz" \
307 "${KERNEL_BINARY_2}" \
311 cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
312 gen_die "Could not copy the kernel binary to ${TMPDIR}!"
313 cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
314 gen_die "Could not copy System.map to ${TMPDIR}!"
315 if isTrue "${GENZIMAGE}"
317 cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
318 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
324 [ -f "${BUSYBOX_SRCTAR}" ] ||
325 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
326 [ -f "${BUSYBOX_CONFIG}" ] ||
327 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
329 # Delete cache if stored config's MD5 does not match one to be used
330 if [ -f "${BUSYBOX_BINCACHE}" ]
332 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum)
333 newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}")
334 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
336 print_info 1 "busybox: >> Removing stale cache..."
337 rm -rf "${BUSYBOX_BINCACHE}"
339 print_info 1 "busybox: >> Using cache"
343 if [ ! -f "${BUSYBOX_BINCACHE}" ]
346 rm -rf "${BUSYBOX_DIR}" > /dev/null
347 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
348 gen_die 'Could not extract busybox source tarball!'
349 [ -d "${BUSYBOX_DIR}" ] ||
350 gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
351 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
352 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
354 apply_patches busybox ${BUSYBOX_VER}
355 print_info 1 'busybox: >> Configuring...'
356 yes '' 2>/dev/null | compile_generic oldconfig utils
358 print_info 1 'busybox: >> Compiling...'
359 compile_generic all utils
360 print_info 1 'busybox: >> Copying to cache...'
361 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
362 gen_die 'Busybox executable does not exist!'
363 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
364 gen_die 'Could not strip busybox binary!'
365 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
366 gen_die 'Could not create the busybox bincache!'
369 rm -rf "${BUSYBOX_DIR}" > /dev/null
374 compile_device_mapper
375 if [ ! -f "${LVM_BINCACHE}" ]
377 [ -f "${LVM_SRCTAR}" ] ||
378 gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
380 rm -rf ${LVM_DIR} > /dev/null
381 /bin/tar -zxpf ${LVM_SRCTAR} ||
382 gen_die 'Could not extract LVM source tarball!'
383 [ -d "${LVM_DIR}" ] ||
384 gen_die 'LVM directory ${LVM_DIR} is invalid!'
385 rm -rf "${TEMP}/device-mapper" > /dev/null
386 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
387 gen_die "Could not extract device-mapper binary cache!";
390 print_info 1 'lvm: >> Configuring...'
391 LDFLAGS="-L${TEMP}/device-mapper/lib" \
392 CFLAGS="-I${TEMP}/device-mapper/include" \
393 CPPFLAGS="-I${TEMP}/device-mapper/include" \
394 ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${LOGFILE} 2>&1 ||
395 gen_die 'Configure of lvm failed!'
396 print_info 1 'lvm: >> Compiling...'
397 compile_generic '' utils
398 compile_generic 'install' utils
401 print_info 1 ' >> Copying to bincache...'
402 strip "sbin/lvm.static" ||
403 gen_die 'Could not strip lvm.static!'
404 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static ||
405 gen_die 'Could not create binary cache'
408 rm -rf "${TEMP}/device-mapper" > /dev/null
409 rm -rf "${LVM_DIR}" lvm
414 compile_device_mapper
415 if [ ! -f "${DMRAID_BINCACHE}" ]
417 [ -f "${DMRAID_SRCTAR}" ] ||
418 gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
420 rm -rf ${DMRAID_DIR} > /dev/null
421 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
422 gen_die 'Could not extract DMRAID source tarball!'
423 [ -d "${DMRAID_DIR}" ] ||
424 gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
425 rm -rf "${TEMP}/device-mapper" > /dev/null
426 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
427 gen_die "Could not extract device-mapper binary cache!";
430 print_info 1 'dmraid: >> Configuring...'
432 LDFLAGS="-L${TEMP}/device-mapper/lib" \
433 CFLAGS="-I${TEMP}/device-mapper/include" \
434 CPPFLAGS="-I${TEMP}/device-mapper/include" \
435 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 ||
436 gen_die 'Configure of dmraid failed!'
438 # We dont necessarily have selinux installed yet... look into
439 # selinux global support in the future.
440 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
441 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
442 mkdir -p "${TEMP}/dmraid"
443 print_info 1 'dmraid: >> Compiling...'
444 # Force dmraid to be built with -j1 for bug #188273
445 MAKEOPTS=-j1 compile_generic '' utils
446 #compile_generic 'install' utils
447 mkdir ${TEMP}/dmraid/sbin
448 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
449 print_info 1 ' >> Copying to bincache...'
451 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
452 gen_die 'Could not create binary cache'
455 rm -rf "${TEMP}/device-mapper" > /dev/null
456 rm -rf "${DMRAID_DIR}" dmraid
460 compile_device_mapper() {
461 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
463 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
464 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!"
466 rm -rf "${DEVICE_MAPPER_DIR}"
467 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
468 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
469 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
470 cd "${DEVICE_MAPPER_DIR}"
471 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
472 --disable-selinux >> ${LOGFILE} 2>&1 ||
473 gen_die 'Configuring device-mapper failed!'
474 print_info 1 'device-mapper: >> Compiling...'
475 compile_generic '' utils
476 compile_generic 'install' utils
477 print_info 1 ' >> Copying to cache...'
479 rm -rf "${TEMP}/device-mapper/man" ||
480 gen_die 'Could not remove manual pages!'
481 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
482 gen_die 'Could not strip dmsetup binary!'
483 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
484 gen_die 'Could not tar up the device-mapper binary!'
485 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
486 gen_die 'device-mapper cache not created!'
488 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
489 rm -rf "${TEMP}/device-mapper" > /dev/null
493 compile_e2fsprogs() {
494 if [ ! -f "${BLKID_BINCACHE}" ]
496 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
497 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
499 rm -rf "${E2FSPROGS_DIR}"
500 tar -zxpf "${E2FSPROGS_SRCTAR}"
501 [ ! -d "${E2FSPROGS_DIR}" ] &&
502 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
503 cd "${E2FSPROGS_DIR}"
504 print_info 1 'e2fsprogs: >> Configuring...'
505 ./configure --with-ldopts=-static >> ${LOGFILE} 2>&1 ||
506 gen_die 'Configuring e2fsprogs failed!'
507 print_info 1 'e2fsprogs: >> Compiling...'
508 MAKE=${UTILS_MAKE} compile_generic "" ""
509 print_info 1 'blkid: >> Copying to cache...'
510 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
511 gen_die 'Blkid executable does not exist!'
512 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
513 gen_die 'Could not strip blkid binary!'
514 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
515 gen_die 'bzip2 compression of blkid failed!'
516 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
517 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
520 rm -rf "${E2FSPROGS_DIR}" > /dev/null
525 if [ ! -f "${FUSE_BINCACHE}" ]
527 [ ! -f "${FUSE_SRCTAR}" ] &&
528 gen_die "Could not find fuse source tarball: ${FUSE_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
531 tar -zxpf "${FUSE_SRCTAR}"
532 [ ! -d "${FUSE_DIR}" ] &&
533 gen_die "fuse directory ${FUSE_DIR} invalid"
535 print_info 1 'fuse: >> Configuring...'
536 ./configure --disable-kernel-module --disable-example >> ${LOGFILE} 2>&1 ||
537 gen_die 'Configuring fuse failed!'
538 print_info 1 'fuse: >> Compiling...'
539 MAKE=${UTILS_MAKE} compile_generic "" ""
540 print_info 1 'libfuse: >> Copying to cache...'
541 [ -f "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ] ||
542 gen_die 'libfuse.so does not exist!'
543 strip "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ||
544 gen_die 'Could not strip libfuse.so!'
545 cd "${TEMP}/${FUSE_DIR}/lib/.libs"
546 tar -cjf "${FUSE_BINCACHE}" libfuse*so* ||
547 gen_die 'Could not create fuse bincache!'
550 rm -rf "${FUSE_DIR}" > /dev/null
554 compile_unionfs_fuse() {
555 if [ ! -f "${UNIONFS_FUSE_BINCACHE}" ]
557 [ ! -f "${UNIONFS_FUSE_SRCTAR}" ] &&
558 gen_die "Could not find unionfs-fuse source tarball: ${UNIONFS_FUSE_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
560 rm -rf "${UNIONFS_FUSE_DIR}"
561 tar -jxpf "${UNIONFS_FUSE_SRCTAR}"
562 [ ! -d "${UNIONFS_FUSE_DIR}" ] &&
563 gen_die "unionfs-fuse directory ${UNIONFS_FUSE_DIR} invalid"
564 cd "${UNIONFS_FUSE_DIR}"
565 print_info 1 'unionfs-fuse: >> Compiling...'
566 MAKE=${UTILS_MAKE} compile_generic "" ""
567 print_info 1 'unionfs-fuse: >> Copying to cache...'
568 [ -f "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ] ||
569 gen_die 'unionfs binary does not exist!'
570 strip "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
571 gen_die 'Could not strip unionfs binary!'
572 bzip2 "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
573 gen_die 'bzip2 compression of unionfs binary failed!'
574 mv "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs.bz2" "${UNIONFS_FUSE_BINCACHE}" ||
575 gen_die 'Could not copy the unionfs binary to the package directory, does the directory exist?'
578 rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null