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