Switch search order so arch-specific is first for busy-config
[genkernel.git] / gen_compile.sh
1 #!/bin/bash
2
3 compile_kernel_args() {
4         local ARGS
5
6         ARGS=''
7         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
8         then
9                 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
10         else
11                 if [ "${KERNEL_CC}" != '' ]
12                 then
13                         ARGS="CC=\"${KERNEL_CC}\""
14                 fi
15                 if [ "${KERNEL_LD}" != '' ]
16                 then
17                         ARGS="${ARGS} LD=\"${KERNEL_LD}\""
18                 fi
19                 if [ "${KERNEL_AS}" != '' ]
20                 then
21                         ARGS="${ARGS} AS=\"${KERNEL_AS}\""
22                 fi
23                 if [ -n "${KERNEL_ARCH}" ]
24                 then
25                         ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\""
26                 fi
27         fi
28         echo -n "${ARGS}"
29 }
30
31 compile_utils_args()
32 {
33         local ARGS
34
35         ARGS=''
36         if [ "${UTILS_ARCH}" != '' ]
37         then
38                 ARGS="ARCH=\"${UTILS_ARCH}\""
39         fi
40         if [ "${UTILS_CC}" != '' ]
41         then
42                 ARGS="CC=\"${UTILS_CC}\""
43         fi
44         if [ "${UTILS_LD}" != '' ]
45         then
46                 ARGS="${ARGS} LD=\"${UTILS_LD}\""
47         fi
48         if [ "${UTILS_AS}" != '' ]
49         then
50                 ARGS="${ARGS} AS=\"${UTILS_AS}\""
51         fi
52
53         echo -n "${ARGS}"
54 }
55
56 export_utils_args()
57 {
58         save_args
59         if [ "${UTILS_ARCH}" != '' ]
60         then
61                 export ARCH="${UTILS_ARCH}"
62         fi
63         if [ "${UTILS_CC}" != '' ]
64         then
65                 export CC="${UTILS_CC}"
66         fi
67         if [ "${UTILS_LD}" != '' ]
68         then
69                 export LD="${UTILS_LD}"
70         fi
71         if [ "${UTILS_AS}" != '' ]
72         then
73                 export AS="${UTILS_AS}"
74         fi
75 }
76
77 unset_utils_args()
78 {
79         if [ "${UTILS_ARCH}" != '' ]
80         then
81                 unset ARCH
82         fi
83         if [ "${UTILS_CC}" != '' ]
84         then
85                 unset CC
86         fi
87         if [ "${UTILS_LD}" != '' ]
88         then
89                 unset LD
90         fi
91         if [ "${UTILS_AS}" != '' ]
92         then
93                 unset AS
94         fi
95         reset_args
96 }
97
98 export_kernel_args()
99 {
100         if [ "${KERNEL_CC}" != '' ]
101         then
102                 export CC="${KERNEL_CC}"
103         fi
104         if [ "${KERNEL_LD}" != '' ]
105         then
106                 export LD="${KERNEL_LD}"
107         fi
108         if [ "${KERNEL_AS}" != '' ]
109         then
110                 export AS="${KERNEL_AS}"
111         fi
112         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
113         then
114                 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
115         fi
116 }
117
118 unset_kernel_args()
119 {
120         if [ "${KERNEL_CC}" != '' ]
121         then
122                 unset CC
123         fi
124         if [ "${KERNEL_LD}" != '' ]
125         then
126                 unset LD
127         fi
128         if [ "${KERNEL_AS}" != '' ]
129         then
130                 unset AS
131         fi
132         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
133         then
134                 unset CROSS_COMPILE
135         fi
136 }
137 save_args()
138 {
139         if [ "${ARCH}" != '' ]
140         then
141                 export ORIG_ARCH="${ARCH}"
142         fi
143         if [ "${CC}" != '' ]
144         then
145                 export ORIG_CC="${CC}"
146         fi
147         if [ "${LD}" != '' ]
148         then
149                 export ORIG_LD="${LD}"
150         fi
151         if [ "${AS}" != '' ]
152         then
153                 export ORIG_AS="${AS}"
154         fi
155         if [ "${CROSS_COMPILE}" != '' ]
156         then
157                 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
158         fi
159 }
160 reset_args()
161 {
162         if [ "${ORIG_ARCH}" != '' ]
163         then
164                 export ARCH="${ORIG_ARCH}"
165                 unset ORIG_ARCH
166         fi
167         if [ "${ORIG_CC}" != '' ]
168         then
169                 export CC="${ORIG_CC}"
170                 unset ORIG_CC
171         fi
172         if [ "${ORIG_LD}" != '' ]
173         then
174                 export LD="${ORIG_LD}"
175                 unset ORIG_LD
176         fi
177         if [ "${ORIG_AS}" != '' ]
178         then
179                 export AS="${ORIG_AS}"
180                 unset ORIG_AS
181         fi
182         if [ "${ORIG_CROSS_COMPILE}" != '' ]
183         then
184                 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
185                 unset ORIG_CROSS_COMPILE
186         fi
187 }
188
189 apply_patches() {
190         util=$1
191         version=$2
192
193         if [ -d "${GK_SHARE}/patches/${util}/${version}" ]
194         then
195                 print_info 1 "${util}: >> Applying patches..."
196                 for i in ${GK_SHARE}/patches/${util}/${version}/*{diff,patch}
197                 do
198                         patch_success=0
199                         for j in `seq 0 5`
200                         do
201                                 patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null
202                                 if [ $? = 0 ]
203                                 then
204                                         patch_success=1
205                                         break
206                                 fi
207                         done
208                         if [ ${patch_success} != 1 ]
209                         then
210                                 gen_die "could not apply patch ${i} for ${util}-${version}"
211                         fi
212                 done
213         fi
214 }
215
216 compile_generic() {
217         local RET
218         [ "$#" -lt '2' ] &&
219                 gen_die 'compile_generic(): improper usage!'
220         local target=${1}
221         local argstype=${2}
222
223         if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
224         then
225                 export_kernel_args
226                 MAKE=${KERNEL_MAKE}
227         elif [ "${2}" = 'utils' ]
228         then
229                 export_utils_args
230                 MAKE=${UTILS_MAKE}
231         fi
232         case "${argstype}" in
233                 kernel) ARGS="`compile_kernel_args`" ;;
234                 utils) ARGS="`compile_utils_args`" ;;
235                 *) ARGS="" ;; # includes runtask
236         esac
237         shift 2
238
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' ]
243         then
244                 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
245                 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
246                 RET=$?
247         elif [ "${LOGLEVEL}" -gt "1" ]
248         then
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}
252                 RET=${PIPESTATUS[0]}
253         else
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
257                 RET=$?
258         fi
259         [ "${RET}" -ne '0' ] &&
260                 gen_die "Failed to compile the \"${target}\" target..."
261
262         unset MAKE
263         unset ARGS
264         if [ "${argstype}" = 'kernel' ]
265         then
266                 unset_kernel_args
267         elif [ "${argstype}" = 'utils' ]
268         then
269                 unset_utils_args
270         fi
271 }
272
273 compile_modules() {
274         print_info 1 "        >> Compiling ${KV} modules..."
275         cd ${KERNEL_DIR}
276         compile_generic modules kernel
277         export UNAME_MACHINE="${ARCH}"
278         [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
279         compile_generic "modules_install" kernel
280         unset UNAME_MACHINE
281 }
282
283 compile_kernel() {
284         [ "${KERNEL_MAKE}" = '' ] &&
285                 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
286         cd ${KERNEL_DIR}
287         print_info 1 "        >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
288         compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
289         if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
290         then
291                 print_info 1 "        >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
292                 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
293         fi
294         if ! isTrue "${CMD_NOINSTALL}"
295         then
296                 copy_image_with_preserve "kernel" \
297                         "${KERNEL_BINARY}" \
298                         "kernel-${KNAME}-${ARCH}-${KV}"
299
300                 copy_image_with_preserve "System.map" \
301                         "System.map" \
302                         "System.map-${KNAME}-${ARCH}-${KV}"
303
304                 if isTrue "${GENZIMAGE}"
305                 then
306                         copy_image_with_preserve "kernelz" \
307                                 "${KERNEL_BINARY_2}" \
308                                 "kernelz-${KV}"
309                 fi
310         else
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}"
316                 then
317                         cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
318                                 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
319                 fi
320         fi
321 }
322
323 compile_busybox() {
324         [ -f "${BUSYBOX_SRCTAR}" ] ||
325                 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
326
327         if [ -n "${BUSYBOX_CONFIG}" ]
328         then
329                 [ -f "${BUSYBOX_CONFIG}" ] ||
330                         gen_die "Could not find busybox config file: ${BUSYBOX_CONFIG}"
331         elif [ -f "$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")" ]
332         then
333                 BUSYBOX_CONFIG="$(arch_replace "${GK_SHARE}/arch/%%ARCH%%/busy-config")"
334         elif [ -f "${GK_SHARE}/defaults/busy-config" ]
335         then
336                 BUSYBOX_CONFIG="${GK_SHARE}/defaults/busy-config"
337         else
338                 gendie "Could not find a busybox config file"
339         fi
340
341         # Delete cache if stored config's MD5 does not match one to be used
342         if [ -f "${BUSYBOX_BINCACHE}" ]
343         then
344                 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum)
345                 newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}")
346                 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
347                 then
348                         print_info 1 "busybox: >> Removing stale cache..."
349                         rm -rf "${BUSYBOX_BINCACHE}"
350                 else
351                         print_info 1 "busybox: >> Using cache"
352                 fi
353         fi
354
355         if [ ! -f "${BUSYBOX_BINCACHE}" ]
356         then
357                 cd "${TEMP}"
358                 rm -rf "${BUSYBOX_DIR}" > /dev/null
359                 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
360                         gen_die 'Could not extract busybox source tarball!'
361                 [ -d "${BUSYBOX_DIR}" ] ||
362                         gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
363                 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
364                 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
365                 cd "${BUSYBOX_DIR}"
366                 apply_patches busybox ${BUSYBOX_VER}
367                 print_info 1 'busybox: >> Configuring...'
368                 yes '' 2>/dev/null | compile_generic oldconfig utils
369
370                 print_info 1 'busybox: >> Compiling...'
371                 compile_generic all utils
372                 print_info 1 'busybox: >> Copying to cache...'
373                 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
374                         gen_die 'Busybox executable does not exist!'
375                 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
376                         gen_die 'Could not strip busybox binary!'
377                 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
378                         gen_die 'Could not create the busybox bincache!'
379
380                 cd "${TEMP}"
381                 rm -rf "${BUSYBOX_DIR}" > /dev/null
382         fi
383 }
384
385 compile_lvm() {
386         compile_device_mapper
387         if [ ! -f "${LVM_BINCACHE}" ]
388         then
389                 [ -f "${LVM_SRCTAR}" ] ||
390                         gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
391                 cd "${TEMP}"
392                 rm -rf ${LVM_DIR} > /dev/null
393                 /bin/tar -zxpf ${LVM_SRCTAR} ||
394                         gen_die 'Could not extract LVM source tarball!'
395                 [ -d "${LVM_DIR}" ] ||
396                         gen_die 'LVM directory ${LVM_DIR} is invalid!'
397                 rm -rf "${TEMP}/device-mapper" > /dev/null
398                 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
399                         gen_die "Could not extract device-mapper binary cache!";
400                 
401                 cd "${LVM_DIR}"
402                 print_info 1 'lvm: >> Configuring...'
403                         LDFLAGS="-L${TEMP}/device-mapper/lib" \
404                         CFLAGS="-I${TEMP}/device-mapper/include" \
405                         CPPFLAGS="-I${TEMP}/device-mapper/include" \
406                         ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${LOGFILE} 2>&1 ||
407                                 gen_die 'Configure of lvm failed!'
408                 print_info 1 'lvm: >> Compiling...'
409                         compile_generic '' utils
410                         compile_generic 'install' utils
411
412                 cd "${TEMP}/lvm"
413                 print_info 1 '      >> Copying to bincache...'
414                 strip "sbin/lvm.static" ||
415                         gen_die 'Could not strip lvm.static!'
416                 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static ||
417                         gen_die 'Could not create binary cache'
418
419                 cd "${TEMP}"
420                 rm -rf "${TEMP}/device-mapper" > /dev/null
421                 rm -rf "${LVM_DIR}" lvm
422         fi
423 }
424
425 compile_dmraid() {
426         compile_device_mapper
427         if [ ! -f "${DMRAID_BINCACHE}" ]
428         then
429                 [ -f "${DMRAID_SRCTAR}" ] ||
430                         gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
431                 cd "${TEMP}"
432                 rm -rf ${DMRAID_DIR} > /dev/null
433                 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
434                         gen_die 'Could not extract DMRAID source tarball!'
435                 [ -d "${DMRAID_DIR}" ] ||
436                         gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
437                 rm -rf "${TEMP}/device-mapper" > /dev/null
438                 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
439                         gen_die "Could not extract device-mapper binary cache!";
440                 
441                 cd "${DMRAID_DIR}"
442                 print_info 1 'dmraid: >> Configuring...'
443                 
444                 LDFLAGS="-L${TEMP}/device-mapper/lib" \
445                 CFLAGS="-I${TEMP}/device-mapper/include" \
446                 CPPFLAGS="-I${TEMP}/device-mapper/include" \
447                 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 ||
448                         gen_die 'Configure of dmraid failed!'
449
450                 # We dont necessarily have selinux installed yet... look into
451                 # selinux global support in the future.
452                 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
453                 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
454                 mkdir -p "${TEMP}/dmraid"
455                 print_info 1 'dmraid: >> Compiling...'
456                 # Force dmraid to be built with -j1 for bug #188273
457                 MAKEOPTS=-j1 compile_generic '' utils
458                 #compile_generic 'install' utils
459                 mkdir ${TEMP}/dmraid/sbin
460                 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
461                 print_info 1 '      >> Copying to bincache...'
462                 cd "${TEMP}/dmraid"
463                 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
464                         gen_die 'Could not create binary cache'
465
466                 cd "${TEMP}"
467                 rm -rf "${TEMP}/device-mapper" > /dev/null
468                 rm -rf "${DMRAID_DIR}" dmraid
469         fi
470 }
471
472 compile_device_mapper() {
473         if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
474         then
475                 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
476                         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!"
477                 cd "${TEMP}"
478                 rm -rf "${DEVICE_MAPPER_DIR}"
479                 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
480                 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
481                         gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
482                 cd "${DEVICE_MAPPER_DIR}"
483                 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
484                         --disable-selinux >> ${LOGFILE} 2>&1 ||
485                         gen_die 'Configuring device-mapper failed!'
486                 print_info 1 'device-mapper: >> Compiling...'
487                 compile_generic '' utils
488                 compile_generic 'install' utils
489                 print_info 1 '        >> Copying to cache...'
490                 cd "${TEMP}"
491                 rm -rf "${TEMP}/device-mapper/man" ||
492                         gen_die 'Could not remove manual pages!'
493                 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
494                         gen_die 'Could not strip dmsetup binary!'
495                 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
496                         gen_die 'Could not tar up the device-mapper binary!'
497                 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
498                         gen_die 'device-mapper cache not created!'
499                 cd "${TEMP}"
500                 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
501                 rm -rf "${TEMP}/device-mapper" > /dev/null
502         fi
503 }
504
505 compile_e2fsprogs() {
506         if [ ! -f "${BLKID_BINCACHE}" ]
507         then
508                 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
509                         gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
510                 cd "${TEMP}"
511                 rm -rf "${E2FSPROGS_DIR}"
512                 tar -zxpf "${E2FSPROGS_SRCTAR}"
513                 [ ! -d "${E2FSPROGS_DIR}" ] &&
514                         gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
515                 cd "${E2FSPROGS_DIR}"
516                 print_info 1 'e2fsprogs: >> Configuring...'
517                 ./configure  --with-ldopts=-static >> ${LOGFILE} 2>&1 ||
518                         gen_die 'Configuring e2fsprogs failed!'
519                 print_info 1 'e2fsprogs: >> Compiling...'
520                 MAKE=${UTILS_MAKE} compile_generic "" ""
521                 print_info 1 'blkid: >> Copying to cache...'
522                 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
523                         gen_die 'Blkid executable does not exist!'
524                 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
525                         gen_die 'Could not strip blkid binary!'
526                 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
527                         gen_die 'bzip2 compression of blkid failed!'
528                 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
529                         gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
530
531                 cd "${TEMP}"
532                 rm -rf "${E2FSPROGS_DIR}" > /dev/null
533         fi
534 }
535
536 compile_fuse() {
537         if [ ! -f "${FUSE_BINCACHE}" ]
538         then
539                 [ ! -f "${FUSE_SRCTAR}" ] &&
540                         gen_die "Could not find fuse source tarball: ${FUSE_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
541                 cd "${TEMP}"
542                 rm -rf "${FUSE_DIR}"
543                 tar -zxpf "${FUSE_SRCTAR}"
544                 [ ! -d "${FUSE_DIR}" ] &&
545                         gen_die "fuse directory ${FUSE_DIR} invalid"
546                 cd "${FUSE_DIR}"
547                 print_info 1 'fuse: >> Configuring...'
548                 ./configure  --disable-kernel-module --disable-example >> ${LOGFILE} 2>&1 ||
549                         gen_die 'Configuring fuse failed!'
550                 print_info 1 'fuse: >> Compiling...'
551                 MAKE=${UTILS_MAKE} compile_generic "" ""
552
553                 # Since we're linking statically against libfuse, we don't need to cache the .so
554 #               print_info 1 'libfuse: >> Copying to cache...'
555 #               [ -f "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ] ||
556 #                       gen_die 'libfuse.so does not exist!'
557 #               strip "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ||
558 #                       gen_die 'Could not strip libfuse.so!'
559 #               cd "${TEMP}/${FUSE_DIR}/lib/.libs"
560 #               tar -cjf "${FUSE_BINCACHE}" libfuse*so* ||
561 #                       gen_die 'Could not create fuse bincache!'
562
563                 cd "${TEMP}"
564 #               rm -rf "${FUSE_DIR}" > /dev/null
565         fi
566 }
567
568 compile_unionfs_fuse() {
569         if [ ! -f "${UNIONFS_FUSE_BINCACHE}" ]
570         then
571
572                 # We'll call compile_fuse() from here, since it's not needed directly by anything else
573                 compile_fuse
574
575                 [ ! -f "${UNIONFS_FUSE_SRCTAR}" ] &&
576                         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!"
577                 cd "${TEMP}"
578                 rm -rf "${UNIONFS_FUSE_DIR}"
579                 tar -jxpf "${UNIONFS_FUSE_SRCTAR}"
580                 [ ! -d "${UNIONFS_FUSE_DIR}" ] &&
581                         gen_die "unionfs-fuse directory ${UNIONFS_FUSE_DIR} invalid"
582                 cd "${UNIONFS_FUSE_DIR}"
583                 print_info 1 'unionfs-fuse: >> Compiling...'
584                 sed -i "/^\(CFLAGS\|CPPFLAGS\)/s:^\\(.*\\)$:\\1 -static -I${TEMP}/${FUSE_DIR}/include -L${TEMP}/${FUSE_DIR}/lib/.libs:" Makefile src/Makefile
585                 sed -i "/^LIB = /s:^LIB = \(.*\)$:LIB = -static -L${TEMP}/${FUSE_DIR}/lib/.libs \1 -ldl -lrt:" Makefile src/Makefile
586                 MAKE=${UTILS_MAKE} compile_generic "" ""
587                 print_info 1 'unionfs-fuse: >> Copying to cache...'
588                 [ -f "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ] ||
589                         gen_die 'unionfs binary does not exist!'
590                 strip "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
591                         gen_die 'Could not strip unionfs binary!'
592                 bzip2 "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
593                         gen_die 'bzip2 compression of unionfs binary failed!'
594                 mv "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs.bz2" "${UNIONFS_FUSE_BINCACHE}" ||
595                         gen_die 'Could not copy the unionfs binary to the package directory, does the directory exist?'
596
597                 cd "${TEMP}"
598                 rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null
599         fi
600 }