Correct unionfs-fuse bincache path and clean up debugging code
[genkernel.git] / gen_initramfs.sh
1 #!/bin/bash
2
3 CPIO_ARGS="--quiet -o -H newc"
4
5 append_base_layout() {
6         if [ -d "${TEMP}/initramfs-base-temp" ]
7         then
8                 rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
9         fi
10         mkdir -p ${TEMP}/initramfs-base-temp/dev
11         mkdir -p ${TEMP}/initramfs-base-temp/bin
12         mkdir -p ${TEMP}/initramfs-base-temp/etc
13         mkdir -p ${TEMP}/initramfs-base-temp/usr
14         mkdir -p ${TEMP}/initramfs-base-temp/proc
15         mkdir -p ${TEMP}/initramfs-base-temp/temp
16         mkdir -p ${TEMP}/initramfs-base-temp/sys
17         mkdir -p ${TEMP}/initramfs-temp/.initrd
18         mkdir -p ${TEMP}/initramfs-base-temp/var/lock/dmraid
19         mkdir -p ${TEMP}/initramfs-base-temp/sbin
20         mkdir -p ${TEMP}/initramfs-base-temp/usr/bin
21         mkdir -p ${TEMP}/initramfs-base-temp/usr/sbin
22         ln -s  lib  ${TEMP}/initramfs-base-temp/lib64
23
24         echo "/dev/ram0     /           ext2    defaults        0 0" > ${TEMP}/initramfs-base-temp/etc/fstab
25         echo "proc          /proc       proc    defaults    0 0" >> ${TEMP}/initramfs-base-temp/etc/fstab
26         
27         cd ${TEMP}/initramfs-base-temp/dev
28         mknod -m 660 console c 5 1
29         mknod -m 660 null c 1 3
30         mknod -m 600 tty1 c 4 1
31         cd "${TEMP}/initramfs-base-temp/"
32         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
33         rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
34 }
35
36 append_busybox() {
37         if [ -d "${TEMP}/initramfs-busybox-temp" ]
38         then
39                 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
40         fi
41         mkdir -p "${TEMP}/initramfs-busybox-temp/bin/" 
42
43         cp "${GK_SHARE}/defaults/udhcpc.scripts" ${TEMP}/initramfs-busybox-temp/bin/
44         chmod +x "${TEMP}/initramfs-busybox-temp/bin/udhcpc.scripts"
45         tar -xjf "${BUSYBOX_BINCACHE}" -C "${TEMP}/initramfs-busybox-temp/bin" busybox ||
46                 gen_die 'Could not extract busybox bincache!'
47         chmod +x "${TEMP}/initramfs-busybox-temp/bin/busybox"
48
49         for i in '[' ash sh mount uname echo cut; do
50                 rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
51                 ln ${TEMP}/initramfs-busybox-temp/bin/busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
52                         gen_die "Busybox error: could not link ${i}!"
53         done
54         
55         cd "${TEMP}/initramfs-busybox-temp/"
56         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
57         rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
58 }
59
60 append_blkid(){
61         if [ -d "${TEMP}/initramfs-blkid-temp" ]
62         then
63                 rm -r "${TEMP}/initramfs-blkid-temp/"
64         fi
65         cd ${TEMP}
66         mkdir -p "${TEMP}/initramfs-blkid-temp/bin/"
67         [ "${DISKLABEL}" -eq '1' ] && { /bin/bzip2 -dc "${BLKID_BINCACHE}" > "${TEMP}/initramfs-blkid-temp/bin/blkid" ||
68                 gen_die "Could not extract blkid binary cache!"; }
69         chmod a+x "${TEMP}/initramfs-blkid-temp/bin/blkid"
70         cd "${TEMP}/initramfs-blkid-temp/"
71         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
72         rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null
73 }
74
75 append_fuse() {
76         if [ -d "${TEMP}/initramfs-fuse-temp" ]
77         then
78                 rm -r "${TEMP}/initramfs-fuse-temp"
79         fi
80         cd ${TEMP}
81         mkdir -p "${TEMP}/initramfs-fuse-temp/lib/"
82         tar -C "${TEMP}/initramfs-fuse-temp/lib/" -xjf "${FUSE_BINCACHE}"
83         cd "${TEMP}/initramfs-fuse-temp/"
84         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
85         rm -rf "${TEMP}/initramfs-fuse-temp" > /dev/null
86 }
87
88 append_unionfs_fuse() {
89         if [ -d "${TEMP}/initramfs-unionfs-fuse-temp" ]
90         then
91                 rm -r "${TEMP}/initramfs-unionfs-fuse-temp"
92         fi
93         cd ${TEMP}
94         mkdir -p "${TEMP}/initramfs-unionfs-fuse-temp/sbin/"
95         bzip2 -dc "${UNIONFS_FUSE_BINCACHE}" > "${TEMP}/initramfs-unionfs-fuse-temp/sbin/unionfs" ||
96                 gen_die 'Could not extract unionfs-fuse binary cache!'
97         cd "${TEMP}/initramfs-unionfs-fuse-temp/"
98         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
99         rm -rf "${TEMP}/initramfs-unionfs-fuse-temp" > /dev/null
100 }
101
102 #append_suspend(){
103 #       if [ -d "${TEMP}/initramfs-suspend-temp" ];
104 #       then
105 #               rm -r "${TEMP}/initramfs-suspend-temp/"
106 #       fi
107 #       print_info 1 'SUSPEND: Adding support (compiling binaries)...'
108 #       compile_suspend
109 #       mkdir -p "${TEMP}/initramfs-suspend-temp/"
110 #       /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" ||
111 #               gen_die "Could not extract suspend binary cache!"
112 #       mkdir -p "${TEMP}/initramfs-suspend-temp/etc"
113 #       cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" ||
114 #               gen_die 'Could not copy /etc/suspend.conf'
115 #       cd "${TEMP}/initramfs-suspend-temp/"
116 #       find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
117 #       rm -r "${TEMP}/initramfs-suspend-temp/"
118 #}
119
120 append_dmraid(){
121         if [ -d "${TEMP}/initramfs-dmraid-temp" ]
122         then
123                 rm -r "${TEMP}/initramfs-dmraid-temp/"
124         fi
125         print_info 1 'DMRAID: Adding support (compiling binaries)...'
126         compile_dmraid
127         mkdir -p "${TEMP}/initramfs-dmraid-temp/"
128         /bin/tar -jxpf "${DMRAID_BINCACHE}" -C "${TEMP}/initramfs-dmraid-temp" ||
129                 gen_die "Could not extract dmraid binary cache!";
130         cd "${TEMP}/initramfs-dmraid-temp/"
131         RAID456=`find . -type f -name raid456.ko`
132         if [ -n "${RAID456}" ]
133         then
134                 cd "${RAID456/raid456.ko/}"
135                 ln -sf raid456.kp raid45.ko
136                 cd "${TEMP}/initramfs-dmraid-temp/"
137         fi
138         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
139         rm -r "${TEMP}/initramfs-dmraid-temp/"
140 }
141
142 append_lvm(){
143         if [ -d "${TEMP}/initramfs-lvm-temp" ]
144         then
145                 rm -r "${TEMP}/initramfs-lvm-temp/"
146         fi
147         cd ${TEMP}
148         mkdir -p "${TEMP}/initramfs-lvm-temp/bin/"
149         mkdir -p "${TEMP}/initramfs-lvm-temp/etc/lvm/"
150         if [ -e '/sbin/lvm' ] && LC_ALL="C" ldd /sbin/lvm|grep -q 'not a dynamic executable'
151         then
152                 print_info 1 '          LVM: Adding support (using local static binaries)...'
153                 cp /sbin/lvm "${TEMP}/initramfs-lvm-temp/bin/lvm" ||
154                         gen_die 'Could not copy over lvm!'
155         else
156                 print_info 1 '          LVM: Adding support (compiling binaries)...'
157                 compile_lvm
158                 /bin/tar -jxpf "${LVM_BINCACHE}" -C "${TEMP}/initramfs-lvm-temp" ||
159                         gen_die "Could not extract lvm binary cache!";
160                 mv ${TEMP}/initramfs-lvm-temp/sbin/lvm.static ${TEMP}/initramfs-lvm-temp/bin/lvm ||
161                         gen_die 'LVM error: Could not move lvm.static to lvm!'
162         fi
163         if [ -x /sbin/lvm ]
164         then
165 #               lvm dumpconfig 2>&1 > /dev/null || gen_die 'Could not copy over lvm.conf!'
166 #               ret=$?
167 #               if [ ${ret} != 0 ]
168 #               then
169                         cp /etc/lvm/lvm.conf "${TEMP}/initramfs-lvm-temp/etc/lvm/" ||
170                                 gen_die 'Could not copy over lvm.conf!'
171 #               else
172 #                       gen_die 'Could not copy over lvm.conf!'
173 #               fi
174         fi
175         cd "${TEMP}/initramfs-lvm-temp/"
176         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
177         rm -r "${TEMP}/initramfs-lvm-temp/"
178 }
179
180 append_evms(){
181         if [ -d "${TEMP}/initramfs-evms-temp" ]
182         then
183                 rm -r "${TEMP}/initramfs-evms-temp/"
184         fi
185         mkdir -p "${TEMP}/initramfs-evms-temp/lib/evms"
186         mkdir -p "${TEMP}/initramfs-evms-temp/etc/"
187         mkdir -p "${TEMP}/initramfs-evms-temp/bin/"
188         mkdir -p "${TEMP}/initramfs-evms-temp/sbin/"
189         if [ "${EVMS}" -eq '1' ]
190         then
191                 print_info 1 '          EVMS: Adding support...'
192                 mkdir -p ${TEMP}/initramfs-evms-temp/lib
193                 cp -a /lib/ld-* "${TEMP}/initramfs-evms-temp/lib" \
194                         || gen_die 'Could not copy files for EVMS!'
195                 if [ -n "`ls /lib/libgcc_s*`" ]
196                 then
197                         cp -a /lib/libgcc_s* "${TEMP}/initramfs-evms-temp/lib" \
198                                 || gen_die 'Could not copy files for EVMS!'
199                 fi
200                 cp -a /lib/libc-* /lib/libc.* "${TEMP}/initramfs-evms-temp/lib" \
201                         || gen_die 'Could not copy files for EVMS!'
202                 cp -a /lib/libdl-* /lib/libdl.* "${TEMP}/initramfs-evms-temp/lib" \
203                         || gen_die 'Could not copy files for EVMS!'
204                 cp -a /lib/libpthread* "${TEMP}/initramfs-evms-temp/lib" \
205                         || gen_die 'Could not copy files for EVMS!'
206                 cp -a /lib/libuuid*so* "${TEMP}/initramfs-evms-temp/lib" \
207                         || gen_die 'Could not copy files for EVMS!'
208                 cp -a /lib/libevms*so* "${TEMP}/initramfs-evms-temp/lib" \
209                         || gen_die 'Could not copy files for EVMS!'
210                 cp -a /lib/evms "${TEMP}/initramfs-evms-temp/lib" \
211                         || gen_die 'Could not copy files for EVMS!'
212                 cp -a /lib/evms/* "${TEMP}/initramfs-evms-temp/lib/evms" \
213                         || gen_die 'Could not copy files for EVMS!'
214                 cp -a /etc/evms.conf "${TEMP}/initramfs-evms-temp/etc" \
215                         || gen_die 'Could not copy files for EVMS!'
216                 cp /sbin/evms_activate "${TEMP}/initramfs-evms-temp/sbin" \
217                         || gen_die 'Could not copy over evms_activate!'
218
219                 # Fix EVMS complaining that it can't find the swap utilities.
220                 # These are not required in the initramfs
221                 for swap_libs in "${TEMP}/initramfs-evms-temp/lib/evms/*/swap*.so"
222                 do
223                         rm ${swap_libs}
224                 done
225         fi
226         cd "${TEMP}/initramfs-evms-temp/"
227         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
228         rm -r "${TEMP}/initramfs-evms-temp/"
229 }
230
231 append_mdadm(){
232         if [ -d "${TEMP}/initramfs-mdadm-temp" ]
233         then
234                 rm -r "${TEMP}/initramfs-mdadm-temp/"
235         fi
236         cd ${TEMP}
237         mkdir -p "${TEMP}/initramfs-mdadm-temp/etc/"
238         if [ "${MDADM}" -eq '1' ]
239         then
240                 cp -a /etc/mdadm.conf "${TEMP}/initramfs-mdadm-temp/etc" \
241                         || gen_die "Could not copy mdadm.conf!"
242         fi
243         cd "${TEMP}/initramfs-mdadm-temp/"
244         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
245         rm -rf "${TEMP}/initramfs-mdadm-temp" > /dev/null
246 }
247
248 append_splash(){
249         splash_geninitramfs=`which splash_geninitramfs 2>/dev/null`
250         if [ -x "${splash_geninitramfs}" ]
251         then
252                 [ -z "${SPLASH_THEME}" ] && [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash
253                 [ -z "${SPLASH_THEME}" ] && SPLASH_THEME=default
254                 print_info 1 "  >> Installing splash [ using the ${SPLASH_THEME} theme ]..."
255                 if [ -d "${TEMP}/initramfs-splash-temp" ]
256                 then
257                         rm -r "${TEMP}/initramfs-splash-temp/"
258                 fi
259                 mkdir -p "${TEMP}/initramfs-splash-temp"
260                 cd /
261                 local tmp=""
262                 [ -n "${SPLASH_RES}" ] && tmp="-r ${SPLASH_RES}"
263                 splash_geninitramfs -c "${TEMP}/initramfs-splash-temp" ${tmp} ${SPLASH_THEME} || gen_die "Could not build splash cpio archive"
264                 if [ -e "/usr/share/splashutils/initrd.splash" ]; then
265                         mkdir -p "${TEMP}/initramfs-splash-temp/etc"
266                         cp -f "/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-splash-temp/etc"
267                 fi
268                 cd "${TEMP}/initramfs-splash-temp/"
269                 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
270                         || gen_die "compressing splash cpio"
271                 rm -r "${TEMP}/initramfs-splash-temp/"
272         else
273                 print_warning 1 '               >> No splash detected; skipping!'
274         fi
275 }
276
277 append_overlay(){
278         cd ${INITRAMFS_OVERLAY}
279         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
280 }
281
282 append_firmware() {
283         if [ -z "${FIRMWARE_FILES}" -a ! -d "${FIRMWARE_DIR}" ]
284         then
285                 gen_die "specified firmware directory (${FIRMWARE_DIR}) does not exist"
286         fi
287         if [ -d "${TEMP}/initramfs-firmware-temp" ]
288         then
289                 rm -r "${TEMP}/initramfs-firmware-temp/"
290         fi
291         mkdir -p "${TEMP}/initramfs-firmware-temp/lib/firmware"
292         cd "${TEMP}/initramfs-firmware-temp"
293         if [ -n "${FIRMWARE_FILES}" ]
294         then
295                 OLD_IFS=$IFS
296                 IFS=","
297                 for i in ${FIRMWARE_FILES}
298                 do
299                         cp -L "${i}" ${TEMP}/initramfs-firmware-temp/lib/firmware/
300                 done
301                 IFS=$OLD_IFS
302         else
303                 cp -a "${FIRMWARE_DIR}"/* ${TEMP}/initramfs-firmware-temp/lib/firmware/
304         fi
305         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
306                 || gen_die "appending firmware to cpio"
307         rm -r "${TEMP}/initramfs-firmware-temp/"
308 }
309
310 print_list()
311 {
312         local x
313         for x in ${*}
314         do
315                 echo ${x}
316         done
317 }
318
319 append_modules() {
320         local group
321         local group_modules
322         local MOD_EXT=".ko"
323
324         print_info 2 "initramfs: >> Searching for modules..."
325         if [ "${INSTALL_MOD_PATH}" != '' ]
326         then
327           cd ${INSTALL_MOD_PATH}
328         else
329           cd /
330         fi
331         
332         if [ -d "${TEMP}/initramfs-modules-${KV}-temp" ]
333         then
334                 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
335         fi
336         mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/lib/modules/${KV}"       
337         for i in `gen_dep_list`
338         do
339                 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" 2>/dev/null| head -n 1 `
340                 if [ -z "${mymod}" ]
341                 then
342                         print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
343                         continue;
344                 fi
345                 
346                 print_info 2 "initramfs: >> Copying ${i}${MOD_EXT}..."
347                 cp -ax --parents "${mymod}" "${TEMP}/initramfs-modules-${KV}-temp"
348         done
349         
350         cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initramfs-modules-${KV}-temp 2>/dev/null
351
352         mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/etc/modules"
353         for group_modules in ${!MODULES_*}; do
354                 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
355                 print_list ${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}"
356         done
357         cd "${TEMP}/initramfs-modules-${KV}-temp/"
358         find . | cpio ${CPIO_ARGS} --append -F "${CPIO}"
359         cd "${TEMP}"
360         rm -r "${TEMP}/initramfs-modules-${KV}-temp/"   
361 }
362
363 # check for static linked file with objdump
364 is_static() {
365         LANG="C" LC_ALL="C" objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
366         return $?
367 }
368
369 append_auxilary() {
370         if [ -d "${TEMP}/initramfs-aux-temp" ]
371         then
372                 rm -r "${TEMP}/initramfs-aux-temp/"
373         fi
374         mkdir -p "${TEMP}/initramfs-aux-temp/etc"       
375         mkdir -p "${TEMP}/initramfs-aux-temp/sbin"      
376         if [ -f "${CMD_LINUXRC}" ]
377         then
378                 cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init"
379                 print_info 2 "        >> Copying user specified linuxrc: ${CMD_LINUXRC} to init"
380         else    
381                 if [ -f "${GK_SHARE}/arch/${ARCH}/linuxrc" ]
382                 then
383                         cp "${GK_SHARE}/arch/${ARCH}/linuxrc" "${TEMP}/initramfs-aux-temp/init"
384                 else
385                         cp "${GK_SHARE}/defaults/linuxrc" "${TEMP}/initramfs-aux-temp/init"
386                 fi
387         fi
388
389         # Make sure it's executable
390         chmod 0755 "${TEMP}/initramfs-aux-temp/init"
391
392         # Make a symlink to init .. incase we are bundled inside the kernel as one
393         # big cpio.
394         cd ${TEMP}/initramfs-aux-temp
395         ln -s init linuxrc
396 #       ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc 
397
398         if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.scripts" ]
399         then
400                 cp "${GK_SHARE}/arch/${ARCH}/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
401         else    
402                 cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
403         fi
404
405         if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.defaults" ]
406         then
407                 cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
408         else
409                 cp "${GK_SHARE}/defaults/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
410         fi
411         
412         echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"  
413         for group_modules in ${!MODULES_*}; do
414                 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
415                 echo -n "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
416         done
417         echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"    
418
419         if [ -f "${GK_SHARE}/arch/${ARCH}/modprobe" ]
420         then
421                 cp "${GK_SHARE}/arch/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
422         else
423                 cp "${GK_SHARE}/defaults/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
424         fi
425         if isTrue $CMD_DOKEYMAPAUTO
426         then
427                 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
428         fi
429         if isTrue $CMD_KEYMAP
430         then
431                 mkdir -p "${TEMP}/initramfs-aux-temp/lib/keymaps"
432                 /bin/tar -C "${TEMP}/initramfs-aux-temp/lib/keymaps" -zxf "${GK_SHARE}/defaults/keymaps.tar.gz"
433         fi
434         if isTrue $CMD_SLOWUSB
435         then
436                 echo 'MY_HWOPTS="${MY_HWOPTS} slowusb"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
437         fi
438         if isTrue ${LUKS}
439         then
440                 if is_static /bin/cryptsetup
441                 then
442                         print_info 1 "Including LUKS support"
443                         rm -f ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
444                         cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
445                         chmod +x "${TEMP}/initramfs-aux-temp/sbin/cryptsetup"
446                 elif is_static /sbin/cryptsetup
447                 then
448                         print_info 1 "Including LUKS support"
449                         rm -f ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
450                         cp /sbin/cryptsetup ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
451                 chmod +x "${TEMP}/initramfs-aux-temp/sbin/cryptsetup"
452
453                 else
454                         print_info 1 "LUKS support requires static cryptsetup at /bin/cryptsetup or /sbin/cryptsetup"
455                         print_info 1 "Not including LUKS support"
456                 fi
457         fi
458
459         cd ${TEMP}/initramfs-aux-temp/sbin && ln -s ../init init
460         cd ${TEMP}
461         chmod +x "${TEMP}/initramfs-aux-temp/init"
462         chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
463         chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
464         chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
465         cd "${TEMP}/initramfs-aux-temp/"
466         find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
467         cd "${TEMP}"
468         rm -r "${TEMP}/initramfs-aux-temp/"     
469 }
470
471 append_data() {
472         local name=$1 var=$2
473         local func="append_${name}"
474
475         if [ $# -eq 1 ] || [ ${var} -eq 1 ]
476         then
477             print_info 1 "        >> Appending ${name} cpio data..."
478             ${func}
479         fi
480 }
481
482 create_initramfs() {
483         print_info 1 "initramfs: >> Initializing..."
484
485         # Create empty cpio
486         CPIO="${TMPDIR}/initramfs-${KV}"
487         echo | cpio ${CPIO_ARGS} -F "${CPIO}" 2>/dev/null \
488                 || gen_die "Could not create empty cpio at ${CPIO}"
489
490         append_data 'base_layout'
491         append_data 'auxilary'
492         append_data 'busybox' "${BUSYBOX}"
493         append_data 'lvm' "${LVM}"
494         append_data 'dmraid' "${DMRAID}"
495         append_data 'evms' "${EVMS}"
496         append_data 'mdadm' "${MDADM}"
497         
498         if [ "${NORAMDISKMODULES}" -eq '0' ]
499         then
500                 append_data 'modules'
501         else
502                 print_info 1 "initramfs: Not copying modules..."
503         fi
504
505         append_data 'blkid' "${DISKLABEL}"
506
507         append_data 'fuse'
508         append_data 'unionfs_fuse'
509
510         if isTrue "${SPLASH}"
511         then
512                 append_data 'splash' "${SPLASH}"
513         fi
514
515         if isTrue "${FIRMWARE}" && [ -n "${FIRMWARE_DIR}" ]
516         then
517                 append_data 'firmware'
518         fi
519
520         # This should always be appended last
521         if [ "${INITRAMFS_OVERLAY}" != '' ]
522         then
523                 append_data 'overlay'
524         fi
525
526         gzip -9 "${CPIO}"
527         mv -f "${CPIO}.gz" "${CPIO}"
528
529         if isTrue "${INTEGRATED_INITRAMFS}"
530         then
531 #               cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/usr/initramfs_data.cpio.gz
532                 mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio.gz
533 #               sed -i "s|^.*CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"|" ${KERNEL_DIR}/.config
534                 sed -i '/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' ${KERNEL_DIR}/.config
535                 echo -e "CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"\nCONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0" >> ${KERNEL_DIR}/.config
536         fi
537
538         if ! isTrue "${CMD_NOINSTALL}"
539         then
540                 if ! isTrue "${INTEGRATED_INITRAMFS}"
541                 then
542                         copy_image_with_preserve "initramfs" \
543                                 "${TMPDIR}/initramfs-${KV}" \
544                                 "initramfs-${KNAME}-${ARCH}-${KV}"
545                 fi
546         fi
547 }