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