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