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}/*
201 patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null
208 if [ ${patch_success} != 1 ]
211 gen_die "could not apply patch ${i} for ${util}-${version}"
220 gen_die 'compile_generic(): improper usage!'
224 if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
228 elif [ "${2}" = 'utils' ]
233 case "${argstype}" in
234 kernel) ARGS="`compile_kernel_args`" ;;
235 utils) ARGS="`compile_utils_args`" ;;
236 *) ARGS="" ;; # includes runtask
240 # the eval usage is needed in the next set of code
241 # as ARGS can contain spaces and quotes, eg:
242 # ARGS='CC="ccache gcc"'
243 if [ "${argstype}" == 'runtask' ]
245 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
246 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
248 elif [ "${LOGLEVEL}" -gt "1" ]
250 # Output to stdout and logfile
251 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
252 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
255 # Output to logfile only
256 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
257 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
260 [ "${RET}" -ne '0' ] &&
261 gen_die "Failed to compile the \"${target}\" target..."
265 if [ "${argstype}" = 'kernel' ]
268 elif [ "${argstype}" = 'utils' ]
274 extract_dietlibc_bincache() {
276 rm -rf "${TEMP}/diet" > /dev/null
277 /bin/tar -jxpf "${DIETLIBC_BINCACHE}" ||
278 gen_die 'Could not extract dietlibc bincache!'
279 [ ! -d "${TEMP}/diet" ] &&
280 gen_die "${TEMP}/diet directory not found!"
284 clean_dietlibc_bincache() {
286 rm -rf "${TEMP}/diet" > /dev/null
291 # Only run ``make dep'' for 2.4 kernels
292 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
294 print_info 1 "kernel: >> Making dependencies..."
296 compile_generic dep kernel
301 print_info 1 " >> Compiling ${KV} modules..."
303 compile_generic modules kernel
304 export UNAME_MACHINE="${ARCH}"
305 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
306 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
308 MAKEOPTS_SAVE="${MAKEOPTS}"
309 MAKEOPTS="${MAKEOPTS_SAVE/-j?/-j1}"
311 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
312 compile_generic "modules_install" kernel
313 [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ] && MAKEOPTS="${MAKEOPTS_SAVE}"
319 [ "${KERNEL_MAKE}" = '' ] &&
320 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
322 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
323 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
324 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
326 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
327 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
329 if ! isTrue "${CMD_NOINSTALL}"
331 copy_image_with_preserve "kernel" \
333 "kernel-${KNAME}-${ARCH}-${KV}"
335 copy_image_with_preserve "System.map" \
337 "System.map-${KNAME}-${ARCH}-${KV}"
339 if isTrue "${GENZIMAGE}"
341 copy_image_with_preserve "kernelz" \
342 "${KERNEL_BINARY_2}" \
346 cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
347 gen_die "Could not copy the kernel binary to ${TMPDIR}!"
348 cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
349 gen_die "Could not copy System.map to ${TMPDIR}!"
350 if isTrue "${GENZIMAGE}"
352 cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
353 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
359 [ -f "${BUSYBOX_SRCTAR}" ] ||
360 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
361 [ -f "${BUSYBOX_CONFIG}" ] ||
362 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
364 # Delete cache if stored config's MD5 does not match one to be used
365 if [ -f "${BUSYBOX_BINCACHE}" ]
367 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum)
368 newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}")
369 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
371 print_info 1 "busybox: >> Removing stale cache..."
372 rm -rf "${BUSYBOX_BINCACHE}"
374 print_info 1 "busybox: >> Using cache"
378 if [ ! -f "${BUSYBOX_BINCACHE}" ]
381 rm -rf "${BUSYBOX_DIR}" > /dev/null
382 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
383 gen_die 'Could not extract busybox source tarball!'
384 [ -d "${BUSYBOX_DIR}" ] ||
385 gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
386 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
387 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
389 apply_patches busybox ${BUSYBOX_VER}
390 print_info 1 'busybox: >> Configuring...'
391 yes '' 2>/dev/null | compile_generic oldconfig utils
393 print_info 1 'busybox: >> Compiling...'
394 compile_generic all utils
395 print_info 1 'busybox: >> Copying to cache...'
396 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
397 gen_die 'Busybox executable does not exist!'
398 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
399 gen_die 'Could not strip busybox binary!'
400 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
401 gen_die 'Could not create the busybox bincache!'
404 rm -rf "${BUSYBOX_DIR}" > /dev/null
409 #compile_device_mapper
410 if [ ! -f "${LVM_BINCACHE}" ]
412 [ -f "${LVM_SRCTAR}" ] ||
413 gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
415 rm -rf ${LVM_DIR} > /dev/null
416 /bin/tar -zxpf ${LVM_SRCTAR} || gen_die 'Could not extract LVM source tarball!'
417 [ -d "${LVM_DIR}" ] || gen_die 'LVM directory ${LVM_DIR} is invalid!'
418 #rm -rf "${TEMP}/device-mapper" > /dev/null
419 #/bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" || gen_die "Could not extract device-mapper binary cache!";
422 print_info 1 'lvm: >> Configuring...'
423 #LDFLAGS="-L${TEMP}/device-mapper/lib" \
424 #CFLAGS="-I${TEMP}/device-mapper/include" \
425 #CPPFLAGS="-I${TEMP}/device-mapper/include" \
426 ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${LOGFILE} 2>&1 || gen_die 'Configure of lvm failed!'
427 print_info 1 'lvm: >> Compiling...'
428 compile_generic '' utils
429 compile_generic 'install' utils
432 print_info 1 ' >> Copying to bincache...'
433 strip "sbin/lvm.static" || gen_die 'Could not strip lvm.static!'
434 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static || gen_die 'Could not create binary cache'
437 #rm -rf "${TEMP}/device-mapper" > /dev/null
438 rm -rf "${LVM_DIR}" lvm
443 #compile_device_mapper
444 if [ ! -f "${DMRAID_BINCACHE}" ]
446 [ -f "${DMRAID_SRCTAR}" ] ||
447 gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
449 rm -rf ${DMRAID_DIR} > /dev/null
450 /bin/tar -jxpf ${DMRAID_SRCTAR} || gen_die 'Could not extract DMRAID source tarball!'
451 [ -d "${DMRAID_DIR}" ] || gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
452 #rm -rf "${TEMP}/device-mapper" > /dev/null
453 #/bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" || gen_die "Could not extract device-mapper binary cache!";
456 print_info 1 'dmraid: >> Configuring...'
458 #LDFLAGS="-L${TEMP}/device-mapper/lib" \
459 #CFLAGS="-I${TEMP}/device-mapper/include" \
460 #CPPFLAGS="-I${TEMP}/device-mapper/include" \
461 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 || gen_die 'Configure of dmraid failed!'
463 # We dont necessarily have selinux installed yet... look into
464 # selinux global support in the future.
465 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
466 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
467 mkdir -p "${TEMP}/dmraid"
468 print_info 1 'dmraid: >> Compiling...'
469 # Force dmraid to be built with -j1 for bug #188273
470 MAKEOPTS=-j1 compile_generic '' utils
471 #compile_generic 'install' utils
472 mkdir ${TEMP}/dmraid/sbin
473 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
474 print_info 1 ' >> Copying to bincache...'
476 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid || gen_die 'Could not create binary cache'
479 #rm -rf "${TEMP}/device-mapper" > /dev/null
480 rm -rf "${DMRAID_DIR}" dmraid
484 compile_device_mapper() {
485 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
487 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
488 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!"
490 rm -rf "${DEVICE_MAPPER_DIR}"
491 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
492 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
493 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
494 cd "${DEVICE_MAPPER_DIR}"
495 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
496 --disable-selinux >> ${LOGFILE} 2>&1 ||
497 gen_die 'Configuring device-mapper failed!'
498 print_info 1 'device-mapper: >> Compiling...'
499 compile_generic '' utils
500 compile_generic 'install' utils
501 print_info 1 ' >> Copying to cache...'
503 rm -rf "${TEMP}/device-mapper/man" ||
504 gen_die 'Could not remove manual pages!'
505 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
506 gen_die 'Could not strip dmsetup binary!'
507 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
508 gen_die 'Could not tar up the device-mapper binary!'
509 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
510 gen_die 'device-mapper cache not created!'
512 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
513 rm -rf "${TEMP}/device-mapper" > /dev/null
517 compile_e2fsprogs() {
518 if [ ! -f "${BLKID_BINCACHE}" ]
520 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
521 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
523 rm -rf "${E2FSPROGS_DIR}"
524 tar -zxpf "${E2FSPROGS_SRCTAR}"
525 [ ! -d "${E2FSPROGS_DIR}" ] &&
526 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
527 cd "${E2FSPROGS_DIR}"
528 print_info 1 'e2fsprogs: >> Configuring...'
529 ./configure --with-ldopts=-static >> ${LOGFILE} 2>&1 ||
530 gen_die 'Configuring e2fsprogs failed!'
531 print_info 1 'e2fsprogs: >> Compiling...'
532 MAKE=${UTILS_MAKE} compile_generic "" ""
533 print_info 1 'blkid: >> Copying to cache...'
534 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
535 gen_die 'Blkid executable does not exist!'
536 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
537 gen_die 'Could not strip blkid binary!'
538 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
539 gen_die 'bzip2 compression of blkid failed!'
540 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
541 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
544 rm -rf "${E2FSPROGS_DIR}" > /dev/null