3 create_base_layout_cpio() {
4 if [ -d "${TEMP}/initramfs-base-temp" ]
6 rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
8 mkdir -p ${TEMP}/initramfs-base-temp/dev
9 mkdir -p ${TEMP}/initramfs-base-temp/bin
10 mkdir -p ${TEMP}/initramfs-base-temp/etc
11 mkdir -p ${TEMP}/initramfs-base-temp/usr
12 mkdir -p ${TEMP}/initramfs-base-temp/proc
13 mkdir -p ${TEMP}/initramfs-base-temp/temp
14 mkdir -p ${TEMP}/initramfs-base-temp/sys
15 mkdir -p ${TEMP}/initramfs-temp/.initrd
16 mkdir -p ${TEMP}/initramfs-base-temp/var/lock/dmraid
17 mkdir -p ${TEMP}/initramfs-base-temp/sbin
18 mkdir -p ${TEMP}/initramfs-base-temp/usr/bin
19 mkdir -p ${TEMP}/initramfs-base-temp/usr/sbin
20 ln -s ../lib ${TEMP}/initramfs-base-temp/lib64
22 echo "/dev/ram0 / ext2 defaults 0 0" > ${TEMP}/initramfs-base-temp/etc/fstab
23 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initramfs-base-temp/etc/fstab
25 if [ "${DEVFS}" -eq '1' ]
27 echo "REGISTER .* MKOLDCOMPAT" > ${TEMP}/initramfs-base-temp/etc/devfsd.conf
28 echo "UNREGISTER .* RMOLDCOMPAT" >> ${TEMP}/initramfs-base-temp/etc/devfsd.conf
29 echo "REGISTER .* MKNEWCOMPAT" >> ${TEMP}/initramfs-base-temp/etc/devfsd.conf
30 echo "UNREGISTER .* RMNEWCOMPAT" >> ${TEMP}/initramfs-base-temp/etc/devfsd.conf
33 cd ${TEMP}/initramfs-base-temp/dev
34 mknod -m 660 console c 5 1
35 mknod -m 660 null c 1 3
36 mknod -m 600 tty1 c 4 1
37 cd "${TEMP}/initramfs-base-temp/"
38 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz
39 rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
42 create_busybox_cpio() {
43 if [ -d "${TEMP}/initramfs-busybox-temp" ]
45 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
47 mkdir -p "${TEMP}/initramfs-busybox-temp/bin/"
48 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initramfs-busybox-temp/bin/busybox.bz2" ||
49 gen_die 'Could not copy busybox from bincache!'
50 bunzip2 "${TEMP}/initramfs-busybox-temp/bin/busybox.bz2" ||
51 gen_die 'Could not uncompress busybox!'
52 chmod +x "${TEMP}/initramfs-busybox-temp/bin/busybox"
54 # down devfsd we use with dietlibc
55 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initramfs-temp/etc/devfsd.conf.bz2" ||
56 # gen_die "could not copy devfsd.conf from bincache"
57 # bunzip2 "${TEMP}/initramfs-temp/etc/devfsd.conf.bz2" ||
58 # gen_die "could not uncompress devfsd.conf"
59 for i in '[' ash sh mount uname echo cut; do
60 rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
61 ln ${TEMP}/initramfs-busybox-temp/bin/busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
62 gen_die "Busybox error: could not link ${i}!"
65 cd "${TEMP}/initramfs-busybox-temp/"
66 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz
67 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
70 create_insmod_cpio() {
71 if [ -d "${TEMP}/initramfs-insmod-temp" ]
73 rm -rf "${TEMP}/initramfs-insmod-temp" > /dev/null
75 mkdir -p "${TEMP}/initramfs-insmod-temp/bin/"
76 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initramfs-insmod-temp/bin/insmod.static.bz2" ||
77 gen_die 'Could not copy insmod.static from bincache!'
79 bunzip2 "${TEMP}/initramfs-insmod-temp/bin/insmod.static.bz2" ||
80 gen_die 'Could not uncompress insmod.static!'
81 mv "${TEMP}/initramfs-insmod-temp/bin/insmod.static" "${TEMP}/initramfs-insmod-temp/bin/insmod"
82 chmod +x "${TEMP}/initramfs-insmod-temp/bin/insmod"
84 cd "${TEMP}/initramfs-insmod-temp/"
85 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz
86 rm -rf "${TEMP}/initramfs-insmod-temp" > /dev/null
90 if [ -d "${TEMP}/initramfs-udev-temp" ]
92 rm -r "${TEMP}/initramfs-udev-temp/"
95 mkdir -p "${TEMP}/initramfs-udev-temp/bin/"
96 [ "${UDEV}" -eq '1' ] && { /bin/tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initramfs-udev-temp" ||
97 gen_die "Could not extract udev binary cache!"; }
98 cd "${TEMP}/initramfs-udev-temp/"
99 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz
100 rm -rf "${TEMP}/initramfs-udev-temp" > /dev/null
104 if [ -d "${TEMP}/initramfs-blkid-temp" ]
106 rm -r "${TEMP}/initramfs-blkid-temp/"
109 mkdir -p "${TEMP}/initramfs-blkid-temp/bin/"
110 [ "${DISKLABEL}" -eq '1' ] && { /bin/bzip2 -dc "${BLKID_BINCACHE}" > "${TEMP}/initramfs-blkid-temp/bin/blkid" ||
111 gen_die "Could not extract blkid binary cache!"; }
112 chmod a+x "${TEMP}/initramfs-blkid-temp/bin/blkid"
113 cd "${TEMP}/initramfs-blkid-temp/"
114 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz
115 rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null
119 if [ -d "${TEMP}/initramfs-devfs-temp" ]
121 rm -r "${TEMP}/initramfs-devfs-temp/"
124 print_info 1 'DEVFS: Adding support (compiling binaries)...'
126 mkdir -p "${TEMP}/initramfs-devfs-temp/bin/"
127 cp "${DEVFSD_BINCACHE}" "${TEMP}/initramfs-devfs-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
128 bunzip2 "${TEMP}/initramfs-devfs-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
129 chmod +x "${TEMP}/initramfs-devfs-temp/bin/devfsd"
130 cd "${TEMP}/initramfs-devfs-temp/"
131 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz
132 rm -rf "${TEMP}/initramfs-devfs-temp" > /dev/null
135 create_unionfs_modules_cpio(){
137 if [ "${UNIONFS}" -eq '1' ]
139 if [ -d "${TEMP}/initramfs-unionfs-modules-temp" ]
141 rm -r "${TEMP}/initramfs-unionfs-modules-temp/"
143 print_info 1 'UNIONFS MODULES: Adding support (compiling)...'
144 compile_unionfs_modules
145 mkdir -p "${TEMP}/initramfs-unionfs-modules-temp/"
146 /bin/tar -jxpf "${UNIONFS_MODULES_BINCACHE}" -C "${TEMP}/initramfs-unionfs-modules-temp" ||
147 gen_die "Could not extract unionfs modules binary cache!";
148 cd "${TEMP}/initramfs-unionfs-modules-temp/"
149 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz
150 rm -r "${TEMP}/initramfs-unionfs-modules-temp/"
154 create_unionfs_tools_cpio(){
156 if [ "${UNIONFS}" -eq '1' ]
158 if [ -d "${TEMP}/initramfs-unionfs-tools-temp" ]
160 rm -r "${TEMP}/initramfs-unionfs-tools-temp/"
162 print_info 1 'UNIONFS TOOLS: Adding support (compiling)...'
163 compile_unionfs_utils
164 mkdir -p "${TEMP}/initramfs-unionfs-tools-temp/bin/"
165 /bin/tar -jxpf "${UNIONFS_BINCACHE}" -C "${TEMP}/initramfs-unionfs-tools-temp" ||
166 gen_die "Could not extract unionfs tools binary cache!";
167 cd "${TEMP}/initramfs-unionfs-tools-temp/"
168 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz
169 rm -r "${TEMP}/initramfs-unionfs-tools-temp/"
173 create_dmraid_cpio(){
175 if [ "${DMRAID}" = '1' ]
177 if [ -d "${TEMP}/initramfs-dmraid-temp" ]
179 rm -r "${TEMP}/initramfs-dmraid-temp/"
181 print_info 1 'DMRAID: Adding support (compiling binaries)...'
183 mkdir -p "${TEMP}/initramfs-dmraid-temp/"
184 /bin/tar -jxpf "${DMRAID_BINCACHE}" -C "${TEMP}/initramfs-dmraid-temp" ||
185 gen_die "Could not extract dmraid binary cache!";
186 cd "${TEMP}/initramfs-dmraid-temp/"
187 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz
188 rm -r "${TEMP}/initramfs-dmraid-temp/"
194 if [ "${LVM2}" -eq '1' ]
196 if [ -d "${TEMP}/initramfs-lvm2-temp" ]
198 rm -r "${TEMP}/initramfs-lvm2-temp/"
201 mkdir -p "${TEMP}/initramfs-lvm2-temp/bin/"
202 mkdir -p "${TEMP}/initramfs-lvm2-temp/etc/lvm/"
203 if [ -e '/sbin/lvm' ] && ldd /sbin/lvm|grep -q 'not a dynamic executable';
205 print_info 1 ' LVM2: Adding support (using local static binaries)...'
206 cp /sbin/lvm "${TEMP}/initramfs-lvm2-temp/bin/lvm" ||
207 gen_die 'Could not copy over lvm!'
209 print_info 1 ' LVM2: Adding support (compiling binaries)...'
211 /bin/tar -jxpf "${LVM2_BINCACHE}" -C "${TEMP}/initramfs-lvm2-temp" ||
212 gen_die "Could not extract lvm2 binary cache!";
213 mv ${TEMP}/initramfs-lvm2-temp/sbin/lvm.static ${TEMP}/initramfs-lvm2-temp/bin/lvm ||
214 gen_die 'LVM2 error: Could not move lvm.static to lvm!'
216 cp /etc/lvm/lvm.conf "${TEMP}/initramfs-lvm2-temp/etc/lvm/lvm.conf" ||
217 gen_die 'Could not copy over lvm.conf!'
218 cd "${TEMP}/initramfs-lvm2-temp/"
219 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz
220 rm -r "${TEMP}/initramfs-lvm2-temp/"
221 else # Deprecation warning; remove in a few versions.
222 if [ -e '/sbin/lvm' ]
224 if ldd /sbin/lvm|grep -q 'not a dynamic executable';
226 print_warning 1 'LVM2: For support, use --lvm2!'
234 if [ -e '/sbin/evms_activate' ]
236 if [ -d "${TEMP}/initramfs-evms2-temp" ]
238 rm -r "${TEMP}/initramfs-evms2-temp/"
240 mkdir -p "${TEMP}/initramfs-evms2-temp/lib/evms"
241 mkdir -p "${TEMP}/initramfs-evms2-temp/etc/"
242 mkdir -p "${TEMP}/initramfs-evms2-temp/bin/"
243 mkdir -p "${TEMP}/initramfs-evms2-temp/sbin/"
244 if [ "${EVMS2}" -eq '1' ]
246 print_info 1 ' EVMS2: Adding support...'
247 mkdir -p ${TEMP}/initramfs-evms2-temp/lib
248 cp -a /lib/ld-* "${TEMP}/initramfs-evms2-temp/lib" \
249 || gen_die 'Could not copy files for EVMS2!'
250 if [ -n "`ls /lib/libgcc_s*`" ]
252 cp -a /lib/libgcc_s* "${TEMP}/initramfs-evms2-temp/lib" \
253 || gen_die 'Could not copy files for EVMS2!'
255 cp -a /lib/libc-* /lib/libc.* "${TEMP}/initramfs-evms2-temp/lib" \
256 || gen_die 'Could not copy files for EVMS2!'
257 cp -a /lib/libdl-* /lib/libdl.* "${TEMP}/initramfs-evms2-temp/lib" \
258 || gen_die 'Could not copy files for EVMS2!'
259 cp -a /lib/libpthread* "${TEMP}/initramfs-evms2-temp/lib" \
260 || gen_die 'Could not copy files for EVMS2!'
261 cp -a /lib/libuuid*so* "${TEMP}/initramfs-evms2-temp/lib" \
262 || gen_die 'Could not copy files for EVMS2!'
263 cp -a /lib/libevms*so* "${TEMP}/initramfs-evms2-temp/lib" \
264 || gen_die 'Could not copy files for EVMS2!'
265 cp -a /lib/evms "${TEMP}/initramfs-evms2-temp/lib" \
266 || gen_die 'Could not copy files for EVMS2!'
267 cp -a /lib/evms/* "${TEMP}/initramfs-evms2-temp/lib/evms" \
268 || gen_die 'Could not copy files for EVMS2!'
269 cp -a /etc/evms.conf "${TEMP}/initramfs-evms2-temp/etc" \
270 || gen_die 'Could not copy files for EVMS2!'
271 cp /sbin/evms_activate "${TEMP}/initramfs-evms2-temp/sbin" \
272 || gen_die 'Could not copy over evms_activate!'
274 # Fix EVMS2 complaining that it can't find the swap utilities.
275 # These are not required in the initramfs
276 for swap_libs in "${TEMP}/initramfs-evms2-temp/lib/evms/*/swap*.so"
281 cd "${TEMP}/initramfs-evms2-temp/"
282 find . -print | cpio --quiet -o -H newc \
283 | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz
284 rm -r "${TEMP}/initramfs-evms2-temp/"
289 if [ "${GENSPLASH}" -eq '1' ]
291 if [ -x /usr/bin/splash_geninitramfs ] || [ -x /sbin/splash_geninitramfs ]
293 [ -z "${GENSPLASH_THEME}" ] && [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash
294 [ -z "${GENSPLASH_THEME}" ] && GENSPLASH_THEME=default
295 print_info 1 " >> Installing gensplash [ using the ${GENSPLASH_THEME} theme ]..."
298 [ -n "${GENSPLASH_RES}" ] && tmp="-r ${GENSPLASH_RES}"
299 splash_geninitramfs -g ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz ${tmp} ${GENSPLASH_THEME} || gen_die "Could not build splash cpio archive"
300 if [ -e "/usr/share/splashutils/initrd.splash" ]; then
301 if [ -d "${TEMP}/initramfs-gensplash-temp" ]
303 rm -r "${TEMP}/initramfs-gensplash-temp/"
305 mkdir -p "${TEMP}/initramfs-gensplash-temp/etc"
306 cd "${TEMP}/initramfs-gensplash-temp/"
307 gunzip -c ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz | cpio -idm --quiet -H newc || gen_die "unpacking splash cpio"
308 cp -f "/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-gensplash-temp/etc"
309 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz || gen_die "compressing splash cpio"
310 rm -r "${TEMP}/initramfs-gensplash-temp/"
313 print_warning 1 ' >> No splash detected; skipping!'
318 create_initramfs_overlay_cpio(){
319 cd ${INITRAMFS_OVERLAY}
320 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz
331 create_initramfs_modules() {
337 print_info 2 "initramfs: >> Searching for modules..."
338 if [ "${INSTALL_MOD_PATH}" != '' ]
340 cd ${INSTALL_MOD_PATH}
345 if [ -d "${TEMP}/initramfs-modules-${KV}-temp" ]
347 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
349 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/lib/modules/${KV}"
350 for i in `gen_dep_list`
352 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" 2>/dev/null| head -n 1 `
355 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
359 print_info 2 "initramfs: >> Copying ${i}${MOD_EXT}..."
360 cp -ax --parents "${mymod}" "${TEMP}/initramfs-modules-${KV}-temp"
363 cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initramfs-modules-${KV}-temp 2>/dev/null
365 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/etc/modules"
366 for group_modules in ${!MODULES_*}; do
367 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
368 print_list ${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}"
370 cd "${TEMP}/initramfs-modules-${KV}-temp/"
371 find . | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz
372 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
375 # check for static linked file with objdump
377 objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
381 create_initramfs_aux() {
382 if [ -d "${TEMP}/initramfs-aux-temp" ]
384 rm -r "${TEMP}/initramfs-aux-temp/"
386 mkdir -p "${TEMP}/initramfs-aux-temp/etc"
387 mkdir -p "${TEMP}/initramfs-aux-temp/sbin"
388 if [ -f "${CMD_LINUXRC}" ]
390 cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init"
391 print_info 2 " >> Copying user specified linuxrc: ${CMD_LINUXRC} to init"
393 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
395 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initramfs-aux-temp/init"
397 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initramfs-aux-temp/init"
401 # Make sure it's executable
402 chmod 0755 "${TEMP}/initramfs-aux-temp/init"
404 # Make a symlink to init .. incase we are bundled inside the kernel as one
406 cd ${TEMP}/initramfs-aux-temp
408 # ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc
410 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
412 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
414 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
417 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
419 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
421 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
424 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
425 for group_modules in ${!MODULES_*}; do
426 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
427 echo -n "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
429 echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
431 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
433 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
435 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
437 if isTrue $CMD_DOKEYMAPAUTO
439 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
441 mkdir -p "${TEMP}/initramfs-aux-temp/lib/keymaps"
442 /bin/tar -C "${TEMP}/initramfs-aux-temp/lib/keymaps" -zxf "${GK_SHARE}/generic/keymaps.tar.gz"
443 if isTrue $CMD_SLOWUSB
445 echo 'MY_HWOPTS="${MY_HWOPTS} slowusb"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
449 if is_static /bin/cryptsetup
451 print_info "Including LUKS support"
452 rm -f ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
453 cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
454 chmod +x "${TEMP}/initramfs-aux-temp/sbin/cryptsetup"
456 print_info "LUKS support requires static cryptsetup at /bin/cryptsetup"
457 print_info "Not including LUKS support"
461 cd ${TEMP}/initramfs-aux-temp/sbin && ln -s ../init init
463 chmod +x "${TEMP}/initramfs-aux-temp/init"
464 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
465 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
466 chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
467 cd "${TEMP}/initramfs-aux-temp/"
468 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz
469 rm -r "${TEMP}/initramfs-aux-temp/"
472 merge_initramfs_cpio_archives(){
473 cd "${CACHE_CPIO_DIR}"
474 MERGE_LIST="initramfs-base-layout.cpio.gz initramfs-aux.cpio.gz"
475 if [ ! -e "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz" ]
477 gen_die "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz is missing."
479 if [ ! -e "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz" ]
481 gen_die "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz is missing."
484 if [ "${BUSYBOX}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz ]
486 MERGE_LIST="${MERGE_LIST} initramfs-busybox-${BUSYBOX_VER}.cpio.gz"
489 if [ "${NOINITRDMODULES}" = '' -a -e ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz ]
491 MERGE_LIST="${MERGE_LIST} initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz"
494 # if [ "${UDEV}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz ]
496 # MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz"
498 if [ "${DISKLABEL}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz ]
500 MERGE_LIST="${MERGE_LIST} initramfs-blkid-${E2FSPROGS_VER}.cpio.gz"
502 if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ]
504 MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz"
506 if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz ]
508 MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz"
510 if [ "${EVMS2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz" ]
512 MERGE_LIST="${MERGE_LIST} initramfs-evms2.cpio.gz"
514 if [ "${LVM2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz" ]
516 MERGE_LIST="${MERGE_LIST} initramfs-lvm2-${LVM2_VER}.cpio.gz"
518 if [ "${DEVFS}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz" ]
520 MERGE_LIST="${MERGE_LIST} initramfs-devfs-${DEVFSD_VER}.cpio.gz"
522 if [ "${DMRAID}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz ]
524 MERGE_LIST="${MERGE_LIST} initramfs-dmraid-${DMRAID_VER}.cpio.gz"
526 if [ "${NOINITRDMODULES}" = '' -a -e "${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz" ]
528 MERGE_LIST="${MERGE_LIST} initramfs-modules-${KV}.cpio.gz"
530 if [ "${GENSPLASH}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz" ]
532 MERGE_LIST="${MERGE_LIST} initramfs-splash-${KV}.cpio.gz"
534 # This should always be appended last
535 if [ "${INITRAMFS_OVERLAY}" != '' -a -e "${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz" ]
537 MERGE_LIST="${MERGE_LIST} initramfs-overlay.cpio.gz"
541 print_info 1 "Merging"
542 for i in ${MERGE_LIST}
547 cat ${MERGE_LIST} > ${TMPDIR}/initramfs-${KV}
549 # Pegasos hack for merging the initramfs into the kernel at compile time
550 [ "${KERNEL_MAKE_DIRECTIVE}" == 'zImage.initrd' -a "${GENERATE_Z_IMAGE}" = '1' ] ||
551 [ "${KERNEL_MAKE_DIRECTIVE_2}" == 'zImage.initrd' -a "${GENERATE_Z_IMAGE}" = '1' ] &&
552 cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/arch/powerpc/boot/ramdisk.image.gz &&
553 rm ${TMPDIR}/initramfs-${KV}
555 # Mips also mimics Pegasos to merge the initramfs into the kernel
556 if [ ${BUILD_INITRAMFS} -eq 1 ]; then
557 cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/initramfs.cpio.gz
558 gunzip -f ${KERNEL_DIR}/initramfs.cpio.gz
563 if [ "${CLEAR_CPIO_CACHE}" == 'yes' ]
566 if [ -d ${CACHE_CPIO_DIR} ]
568 print_info 1 " >> Clearing old cpio archives..."
569 rm -r ${CACHE_CPIO_DIR}
573 if [ ! -d ${CACHE_CPIO_DIR} ]
575 mkdir -p ${CACHE_CPIO_DIR}
582 print_info 1 "initramfs: >> Initializing..."
584 mkdir -p ${CACHE_CPIO_DIR}
585 print_info 1 " >> Creating base_layout cpio archive..."
586 create_base_layout_cpio
588 print_info 1 " >> Creating auxilary cpio archive..."
591 if [ "${BUSYBOX}" -eq '1' ]
593 print_info 1 " >> Creating busybox cpio archive..."
597 if [ "${DEVFS}" -eq '1' ]
599 print_info 1 " >> Creating devfs cpio archive..."
603 # if [ "${UDEV}" -eq '1' ]
605 # print_info 1 " >> Creating udev cpio archive..."
609 if [ "${UNIONFS}" -eq '1' ]
611 print_info 1 " >> Creating unionfs modules cpio archive..."
612 create_unionfs_modules_cpio
613 print_info 1 " >> Creating unionfs tools cpio archive..."
614 create_unionfs_tools_cpio
617 if [ "${LVM2}" -eq '1' ]
620 print_info 1 " >> Creating lvm2 cpio archive..."
624 if [ "${DMRAID}" -eq '1' ]
626 print_info 1 " >> Creating dmraid cpio archive..."
630 if [ "${EVMS2}" -eq '1' -a -e '/sbin/evms_activate' ]
632 print_info 1 " >> Creating evms2 cpio archive..."
636 if [ "${NOINITRDMODULES}" = '' ]
638 print_info 1 " >> Creating insmod cpio archive..."
640 print_info 1 " >> Creating modules cpio archive..."
641 create_initramfs_modules
643 print_info 1 "initramfs: Not copying modules..."
646 if [ "${DISKLABEL}" -eq '1' ]
648 print_info 1 " >> Creating blkid cpio archive..."
654 if [ "${INITRAMFS_OVERLAY}" != '' ]
656 print_info 1 " >> Creating initramfs_overlay cpio archive..."
657 create_initramfs_overlay_cpio
660 merge_initramfs_cpio_archives
662 if ! isTrue "${CMD_NOINSTALL}"
664 if [ "${GENERATE_Z_IMAGE}" != '1' ]
666 cp ${TMPDIR}/initramfs-${KV} ${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV} ||
667 gen_die 'Could not copy the initramfs to ${BOOTDIR}!'