Changed all instances of EVMS2/LVM2 to EVMS/LVM, respectively. This will keep everyt...
[genkernel.git] / gen_compile.sh
1 #!/bin/bash
2
3 compile_kernel_args()
4 {
5         local ARGS
6
7         ARGS=''
8         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
9         then
10                 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
11         else
12                 if [ "${KERNEL_CC}" != '' ]
13                 then
14                         ARGS="CC=\"${KERNEL_CC}\""
15                 fi
16                 if [ "${KERNEL_LD}" != '' ]
17                 then
18                         ARGS="${ARGS} LD=\"${KERNEL_LD}\""
19                 fi
20                 if [ "${KERNEL_AS}" != '' ]
21                 then
22                         ARGS="${ARGS} AS=\"${KERNEL_AS}\""
23                 fi
24         fi
25         echo -n "${ARGS}"
26 }
27
28 compile_utils_args()
29 {
30         local ARGS
31
32         ARGS=''
33         if [ "${UTILS_ARCH}" != '' ]
34         then
35                 ARGS="ARCH=\"${UTILS_ARCH}\""
36         fi
37         if [ "${UTILS_CC}" != '' ]
38         then
39                 ARGS="CC=\"${UTILS_CC}\""
40         fi
41         if [ "${UTILS_LD}" != '' ]
42         then
43                 ARGS="${ARGS} LD=\"${UTILS_LD}\""
44         fi
45         if [ "${UTILS_AS}" != '' ]
46         then
47                 ARGS="${ARGS} AS=\"${UTILS_AS}\""
48         fi
49
50         echo -n "${ARGS}"
51 }
52
53 export_utils_args()
54 {
55         save_args
56         if [ "${UTILS_ARCH}" != '' ]
57         then
58                 export ARCH="${UTILS_ARCH}"
59         fi
60         if [ "${UTILS_CC}" != '' ]
61         then
62                 export CC="${UTILS_CC}"
63         fi
64         if [ "${UTILS_LD}" != '' ]
65         then
66                 export LD="${UTILS_LD}"
67         fi
68         if [ "${UTILS_AS}" != '' ]
69         then
70                 export AS="${UTILS_AS}"
71         fi
72 }
73
74 unset_utils_args()
75 {
76         if [ "${UTILS_ARCH}" != '' ]
77         then
78                 unset ARCH
79         fi
80         if [ "${UTILS_CC}" != '' ]
81         then
82                 unset CC
83         fi
84         if [ "${UTILS_LD}" != '' ]
85         then
86                 unset LD
87         fi
88         if [ "${UTILS_AS}" != '' ]
89         then
90                 unset AS
91         fi
92         reset_args
93 }
94
95 export_kernel_args()
96 {
97         if [ "${KERNEL_CC}" != '' ]
98         then
99                 export CC="${KERNEL_CC}"
100         fi
101         if [ "${KERNEL_LD}" != '' ]
102         then
103                 export LD="${KERNEL_LD}"
104         fi
105         if [ "${KERNEL_AS}" != '' ]
106         then
107                 export AS="${KERNEL_AS}"
108         fi
109         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
110         then
111                 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
112         fi
113 }
114
115 unset_kernel_args()
116 {
117         if [ "${KERNEL_CC}" != '' ]
118         then
119                 unset CC
120         fi
121         if [ "${KERNEL_LD}" != '' ]
122         then
123                 unset LD
124         fi
125         if [ "${KERNEL_AS}" != '' ]
126         then
127                 unset AS
128         fi
129         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
130         then
131                 unset CROSS_COMPILE
132         fi
133 }
134 save_args()
135 {
136         if [ "${ARCH}" != '' ]
137         then
138                 export ORIG_ARCH="${ARCH}"
139         fi
140         if [ "${CC}" != '' ]
141         then
142                 export ORIG_CC="${CC}"
143         fi
144         if [ "${LD}" != '' ]
145         then
146                 export ORIG_LD="${LD}"
147         fi
148         if [ "${AS}" != '' ]
149         then
150                 export ORIG_AS="${AS}"
151         fi
152         if [ "${CROSS_COMPILE}" != '' ]
153         then
154                 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
155         fi
156 }
157 reset_args()
158 {
159         if [ "${ORIG_ARCH}" != '' ]
160         then
161                 export ARCH="${ORIG_ARCH}"
162                 unset ORIG_ARCH
163         fi
164         if [ "${ORIG_CC}" != '' ]
165         then
166                 export CC="${ORIG_CC}"
167                 unset ORIG_CC
168         fi
169         if [ "${ORIG_LD}" != '' ]
170         then
171                 export LD="${ORIG_LD}"
172                 unset ORIG_LD
173         fi
174         if [ "${ORIG_AS}" != '' ]
175         then
176                 export AS="${ORIG_AS}"
177                 unset ORIG_AS
178         fi
179         if [ "${ORIG_CROSS_COMPILE}" != '' ]
180         then
181                 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
182                 unset ORIG_CROSS_COMPILE
183         fi
184 }
185
186
187 compile_generic() {
188         local RET
189         [ "$#" -lt '2' ] &&
190                 gen_die 'compile_generic(): improper usage!'
191         local target=${1}
192         local argstype=${2}
193
194         if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
195         then
196                 export_kernel_args
197                 MAKE=${KERNEL_MAKE}
198         elif [ "${2}" = 'utils' ]
199         then
200                 export_utils_args
201                 MAKE=${UTILS_MAKE}
202         fi
203         case "${argstype}" in
204                 kernel) ARGS="`compile_kernel_args`" ;;
205                 utils) ARGS="`compile_utils_args`" ;;
206                 *) ARGS="" ;; # includes runtask
207         esac
208         shift 2
209
210
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' ]
215         then
216                 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
217                 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
218                 RET=$?
219         elif [ "${DEBUGLEVEL}" -gt "1" ]
220         then
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}
224                 RET=${PIPESTATUS[0]}
225         else
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
229                 RET=$?
230         fi
231         [ "${RET}" -ne '0' ] &&
232                 gen_die "Failed to compile the \"${target}\" target..."
233
234         unset MAKE
235         unset ARGS
236         if [ "${argstype}" = 'kernel' ]
237         then
238                 unset_kernel_args
239         elif [ "${argstype}" = 'utils' ]
240         then
241                 unset_utils_args
242         fi
243 }
244
245 extract_dietlibc_bincache() {
246         cd "${TEMP}"
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!"
252         cd - > /dev/null
253 }
254
255 clean_dietlibc_bincache() {
256         cd "${TEMP}"
257         rm -rf "${TEMP}/diet" > /dev/null
258         cd - > /dev/null
259 }
260
261 compile_dep() {
262         # Only run ``make dep'' for 2.4 kernels
263         if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
264         then
265                 print_info 1 "kernel: >> Making dependencies..."
266                 cd ${KERNEL_DIR}
267                 compile_generic dep kernel
268         fi
269 }
270
271 compile_modules() {
272         print_info 1 "        >> Compiling ${KV} modules..."
273         cd ${KERNEL_DIR}
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' ]
278         then
279                 MAKEOPTS_SAVE="${MAKEOPTS}"
280                 MAKEOPTS="${MAKEOPTS_SAVE/-j?/-j1}"
281         fi
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}"
285         export MAKEOPTS
286         unset UNAME_MACHINE
287 }
288
289 compile_kernel() {
290         [ "${KERNEL_MAKE}" = '' ] &&
291                 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
292         cd ${KERNEL_DIR}
293         print_info 1 "        >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
294         compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
295         if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
296         then
297                 print_info 1 "        >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
298                 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
299         fi
300         if ! isTrue "${CMD_NOINSTALL}"
301         then
302                 copy_image_with_preserve "kernel" \
303                         "${KERNEL_BINARY}" \
304                         "kernel-${KNAME}-${ARCH}-${KV}"
305
306                 copy_image_with_preserve "System.map" \
307                         "System.map" \
308                         "System.map-${KNAME}-${ARCH}-${KV}"
309
310                 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
311                 then
312                         copy_image_with_preserve "kernelz" \
313                                 "${KERNEL_BINARY_2}" \
314                                 "kernelz-${KV}"
315                 fi
316         else
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' ]
322                 then
323                         cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
324                                 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
325                 fi
326         fi
327 }
328
329 compile_unionfs_modules() {
330         if [ ! -f "${UNIONFS_MODULES_BINCACHE}" ]
331         then
332                 [ -f "${UNIONFS_SRCTAR}" ] ||
333                         gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
334                 cd "${TEMP}"
335                 rm -rf ${UNIONFS_DIR} > /dev/null
336                 rm -rf unionfs* > /dev/null
337                 mkdir unionfs
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!'
342                 cd "${UNIONFS_DIR}"
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" \
352                         >> fistdev.mk
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
357
358                 if [ "${PAT}" -ge '6' ]
359                 then
360                         # ARCH is used by unionfs - and conflicts with genkernel
361                         ARCH_PUSH=${ARCH}
362                         unset ARCH
363                         # Compile unionfs module within the unionfs
364                         # environment not within the kernelsrc dir
365                         make unionfs.ko || gen_die 'failed to compile unionfs'
366                         ARCH=${ARCH_PUSH}
367                 else
368                         gen_die 'unionfs is only supported on 2.6 targets'
369                 fi
370                 print_info 1 'unionfs: >> Copying to cache...'
371         
372                 mkdir -p ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
373                 
374                 if [ -f unionfs.ko ]
375                 then 
376                         cp -f unionfs.ko ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
377                 else
378                         cp -f unionfs.o ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
379                 fi
380         
381                 cd ${TEMP}/unionfs
382                 /bin/tar -cjf "${UNIONFS_MODULES_BINCACHE}" . ||
383                         gen_die 'Could not create unionfs modules binary cache'
384         
385                 cd "${TEMP}"
386                 rm -rf "${UNIONFS_DIR}" > /dev/null
387                 rm -rf unionfs > /dev/null
388         fi
389 }
390
391 compile_unionfs_utils() {
392         if [ ! -f "${UNIONFS_BINCACHE}" ]
393         then
394                 [ -f "${UNIONFS_SRCTAR}" ] ||
395                         gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
396                 cd "${TEMP}"
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!'
404                 cd "${UNIONFS_DIR}"
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
409
410                 if [ ! -e "uniondbg" ]; then
411                         cd utils
412                 fi
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'
419                 cd ${TEMP}/unionfs
420                 /bin/tar -cjf "${UNIONFS_BINCACHE}" . ||
421                         gen_die 'Could not create unionfs tools binary cache'
422                 
423                 cd "${TEMP}"
424                 rm -rf "${UNIONFS_DIR}" > /dev/null
425                 rm -rf unionfs > /dev/null
426         fi
427 }
428
429 compile_busybox() {
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}!"
434         cd "${TEMP}"
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'
442         cd "${BUSYBOX_DIR}"
443         print_info 1 'busybox: >> Configuring...'
444         yes '' 2>/dev/null | compile_generic oldconfig utils
445
446         # Delete cache if stored config's MD5 does not match one to be used
447         if [ -f "${BUSYBOX_BINCACHE}" -a -f "${BUSYBOX_CONFIG}" ]
448         then
449                 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config | md5sum)
450                 newconfig_md5=$(md5sum < .config)
451                 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
452                 then
453                         print_info 1 "busybox: >> Removing stale cache..."
454                         rm -rf "${BUSYBOX_BINCACHE}"
455                 else
456                         print_info 1 "busybox: >> Using cache"
457                 fi
458         fi
459
460         if [ ! -f "${BUSYBOX_BINCACHE}" ]
461         then
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!'
471         fi
472
473         cd "${TEMP}"
474         rm -rf "${BUSYBOX_DIR}" > /dev/null
475 }
476
477 compile_lvm() {
478         compile_device_mapper
479         if [ ! -f "${LVM_BINCACHE}" ]
480         then
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!"
483                 cd "${TEMP}"
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!";
492                 
493                 cd "${LVM_DIR}"
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
503
504                 cd "${TEMP}/lvm"
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'
510
511                 cd "${TEMP}"
512                 rm -rf "${TEMP}/device-mapper" > /dev/null
513                 rm -rf "${LVM_DIR}" lvm
514         fi
515 }
516
517 compile_dmraid() {
518         compile_device_mapper
519         if [ ! -f "${DMRAID_BINCACHE}" ]
520         then
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!"
523                 cd "${TEMP}"
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!";
532                 
533                 cd "${DMRAID_DIR}"
534                 print_info 1 'dmraid: >> Configuring...'
535                 
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!'
541                                 
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...'
553                 cd "${TEMP}/dmraid"
554                 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
555                         gen_die 'Could not create binary cache'
556
557                 cd "${TEMP}"
558                 rm -rf "${TEMP}/device-mapper" > /dev/null
559                 rm -rf "${DMRAID_DIR}" dmraid
560         fi
561 }
562
563 compile_devfsd() {
564         local ARGS
565         if [ ! -f "${DEVFSD_BINCACHE}" ]
566         then
567                 [ ! -f "${DEVFSD_SRCTAR}" ] &&
568                         gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
569                 cd "${TEMP}"
570                 rm -rf "${DEVFSD_DIR}"
571                 /bin/tar -jxpf "${DEVFSD_SRCTAR}"
572                 [ ! -d "${DEVFSD_DIR}" ] &&
573                         gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
574                 cd "${DEVFSD_DIR}"
575
576                 print_info 1 'devfsd: >> Compiling...'
577                 compile_generic 'LDFLAGS=-static' utils
578
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!'
585
586                 cd "${TEMP}"
587                 rm -rf "${DEVFSD_DIR}" > /dev/null
588         fi
589 }
590
591 compile_device_mapper() {
592         if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
593         then
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!"
596                 cd "${TEMP}"
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...'
609                 cd "${TEMP}"
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!'
618                 cd "${TEMP}"
619                 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
620                 rm -rf "${TEMP}/device-mapper" > /dev/null
621         fi
622 }
623
624 compile_e2fsprogs() {
625         if [ ! -f "${BLKID_BINCACHE}" ]
626         then
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!"
629                 cd "${TEMP}"
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?'
649
650                 cd "${TEMP}"
651                 rm -rf "${E2FSPROGS_DIR}" > /dev/null
652         fi
653 }