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/"
49 cp "${GK_SHARE}/generic/udhcpc.scripts" ${TEMP}/initramfs-busybox-temp/bin/
50 chmod +x "${TEMP}/initramfs-busybox-temp/bin/udhcpc.scripts"
51 cp "${BUSYBOX_BINCACHE}" "${TEMP}/initramfs-busybox-temp/bin/busybox.bz2" ||
52 gen_die 'Could not copy busybox from bincache!'
53 bunzip2 "${TEMP}/initramfs-busybox-temp/bin/busybox.bz2" ||
54 gen_die 'Could not uncompress busybox!'
55 chmod +x "${TEMP}/initramfs-busybox-temp/bin/busybox"
57 # down devfsd we use with dietlibc
58 # cp "${DEVFSD_CONF_BINCACHE}" "${TEMP}/initramfs-temp/etc/devfsd.conf.bz2" ||
59 # gen_die "could not copy devfsd.conf from bincache"
60 # bunzip2 "${TEMP}/initramfs-temp/etc/devfsd.conf.bz2" ||
61 # gen_die "could not uncompress devfsd.conf"
62 for i in '[' ash sh mount uname echo cut; do
63 rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
64 ln ${TEMP}/initramfs-busybox-temp/bin/busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
65 gen_die "Busybox error: could not link ${i}!"
68 cd "${TEMP}/initramfs-busybox-temp/"
69 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz
70 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
73 create_insmod_cpio() {
74 if [ -d "${TEMP}/initramfs-insmod-temp" ]
76 rm -rf "${TEMP}/initramfs-insmod-temp" > /dev/null
78 mkdir -p "${TEMP}/initramfs-insmod-temp/bin/"
79 cp "${MODULE_INIT_TOOLS_BINCACHE}" "${TEMP}/initramfs-insmod-temp/bin/insmod.static.bz2" ||
80 gen_die 'Could not copy insmod.static from bincache!'
82 bunzip2 "${TEMP}/initramfs-insmod-temp/bin/insmod.static.bz2" ||
83 gen_die 'Could not uncompress insmod.static!'
84 mv "${TEMP}/initramfs-insmod-temp/bin/insmod.static" "${TEMP}/initramfs-insmod-temp/bin/insmod"
85 chmod +x "${TEMP}/initramfs-insmod-temp/bin/insmod"
87 cd "${TEMP}/initramfs-insmod-temp/"
88 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz
89 rm -rf "${TEMP}/initramfs-insmod-temp" > /dev/null
93 if [ -d "${TEMP}/initramfs-udev-temp" ]
95 rm -r "${TEMP}/initramfs-udev-temp/"
98 mkdir -p "${TEMP}/initramfs-udev-temp/bin/"
99 [ "${UDEV}" -eq '1' ] && { /bin/tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initramfs-udev-temp" ||
100 gen_die "Could not extract udev binary cache!"; }
101 cd "${TEMP}/initramfs-udev-temp/"
102 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz
103 rm -rf "${TEMP}/initramfs-udev-temp" > /dev/null
107 if [ -d "${TEMP}/initramfs-blkid-temp" ]
109 rm -r "${TEMP}/initramfs-blkid-temp/"
112 mkdir -p "${TEMP}/initramfs-blkid-temp/bin/"
113 [ "${DISKLABEL}" -eq '1' ] && { /bin/bzip2 -dc "${BLKID_BINCACHE}" > "${TEMP}/initramfs-blkid-temp/bin/blkid" ||
114 gen_die "Could not extract blkid binary cache!"; }
115 chmod a+x "${TEMP}/initramfs-blkid-temp/bin/blkid"
116 cd "${TEMP}/initramfs-blkid-temp/"
117 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz
118 rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null
122 if [ -d "${TEMP}/initramfs-devfs-temp" ]
124 rm -r "${TEMP}/initramfs-devfs-temp/"
127 print_info 1 'DEVFS: Adding support (compiling binaries)...'
129 mkdir -p "${TEMP}/initramfs-devfs-temp/bin/"
130 cp "${DEVFSD_BINCACHE}" "${TEMP}/initramfs-devfs-temp/bin/devfsd.bz2" || gen_die "could not copy devfsd executable from bincache"
131 bunzip2 "${TEMP}/initramfs-devfs-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd"
132 chmod +x "${TEMP}/initramfs-devfs-temp/bin/devfsd"
133 cd "${TEMP}/initramfs-devfs-temp/"
134 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz
135 rm -rf "${TEMP}/initramfs-devfs-temp" > /dev/null
138 create_unionfs_modules_cpio(){
140 if [ "${UNIONFS}" -eq '1' ]
142 if [ -d "${TEMP}/initramfs-unionfs-modules-temp" ]
144 rm -r "${TEMP}/initramfs-unionfs-modules-temp/"
146 print_info 1 'UNIONFS MODULES: Adding support (compiling)...'
147 compile_unionfs_modules
148 mkdir -p "${TEMP}/initramfs-unionfs-modules-temp/"
149 /bin/tar -jxpf "${UNIONFS_MODULES_BINCACHE}" -C "${TEMP}/initramfs-unionfs-modules-temp" ||
150 gen_die "Could not extract unionfs modules binary cache!";
151 cd "${TEMP}/initramfs-unionfs-modules-temp/"
152 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz
153 rm -r "${TEMP}/initramfs-unionfs-modules-temp/"
157 create_unionfs_tools_cpio(){
159 if [ "${UNIONFS}" -eq '1' ]
161 if [ -d "${TEMP}/initramfs-unionfs-tools-temp" ]
163 rm -r "${TEMP}/initramfs-unionfs-tools-temp/"
165 print_info 1 'UNIONFS TOOLS: Adding support (compiling)...'
166 compile_unionfs_utils
167 mkdir -p "${TEMP}/initramfs-unionfs-tools-temp/bin/"
168 /bin/tar -jxpf "${UNIONFS_BINCACHE}" -C "${TEMP}/initramfs-unionfs-tools-temp" ||
169 gen_die "Could not extract unionfs tools binary cache!";
170 cd "${TEMP}/initramfs-unionfs-tools-temp/"
171 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz
172 rm -r "${TEMP}/initramfs-unionfs-tools-temp/"
176 create_suspend_cpio(){
177 if [ -d "${TEMP}/initramfs-suspend-temp" ];
179 rm -r "${TEMP}/initramfs-suspend-temp/"
181 print_info 1 'SUSPEND: Adding support (compiling binaries)...'
183 mkdir -p "${TEMP}/initramfs-suspend-temp/"
184 /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" ||
185 gen_die "Could not extract suspend binary cache!"
186 mkdir -p "${TEMP}/initramfs-suspend-temp/etc"
187 cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" ||
188 gen_die 'Could not copy /etc/suspend.conf'
189 cd "${TEMP}/initramfs-suspend-temp/"
190 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-suspend-${SUSPEND_VER}.cpio.gz
193 create_dmraid_cpio(){
195 if [ "${DMRAID}" = '1' ]
197 if [ -d "${TEMP}/initramfs-dmraid-temp" ]
199 rm -r "${TEMP}/initramfs-dmraid-temp/"
201 print_info 1 'DMRAID: Adding support (compiling binaries)...'
203 mkdir -p "${TEMP}/initramfs-dmraid-temp/"
204 /bin/tar -jxpf "${DMRAID_BINCACHE}" -C "${TEMP}/initramfs-dmraid-temp" ||
205 gen_die "Could not extract dmraid binary cache!";
206 cd "${TEMP}/initramfs-dmraid-temp/"
207 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz
208 rm -r "${TEMP}/initramfs-dmraid-temp/"
214 if [ "${LVM2}" -eq '1' ]
216 if [ -d "${TEMP}/initramfs-lvm2-temp" ]
218 rm -r "${TEMP}/initramfs-lvm2-temp/"
221 mkdir -p "${TEMP}/initramfs-lvm2-temp/bin/"
222 mkdir -p "${TEMP}/initramfs-lvm2-temp/etc/lvm/"
223 if [ -e '/sbin/lvm' ] && ldd /sbin/lvm|grep -q 'not a dynamic executable';
225 print_info 1 ' LVM2: Adding support (using local static binaries)...'
226 cp /sbin/lvm "${TEMP}/initramfs-lvm2-temp/bin/lvm" ||
227 gen_die 'Could not copy over lvm!'
229 print_info 1 ' LVM2: Adding support (compiling binaries)...'
231 /bin/tar -jxpf "${LVM2_BINCACHE}" -C "${TEMP}/initramfs-lvm2-temp" ||
232 gen_die "Could not extract lvm2 binary cache!";
233 mv ${TEMP}/initramfs-lvm2-temp/sbin/lvm.static ${TEMP}/initramfs-lvm2-temp/bin/lvm ||
234 gen_die 'LVM2 error: Could not move lvm.static to lvm!'
236 cp /etc/lvm/lvm.conf "${TEMP}/initramfs-lvm2-temp/etc/lvm/lvm.conf" ||
237 gen_die 'Could not copy over lvm.conf!'
238 cd "${TEMP}/initramfs-lvm2-temp/"
239 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz
240 rm -r "${TEMP}/initramfs-lvm2-temp/"
241 else # Deprecation warning; remove in a few versions.
242 if [ -e '/sbin/lvm' ]
244 if ldd /sbin/lvm|grep -q 'not a dynamic executable';
246 print_warning 1 'LVM2: For support, use --lvm2!'
254 if [ -e '/sbin/evms_activate' ]
256 if [ -d "${TEMP}/initramfs-evms2-temp" ]
258 rm -r "${TEMP}/initramfs-evms2-temp/"
260 mkdir -p "${TEMP}/initramfs-evms2-temp/lib/evms"
261 mkdir -p "${TEMP}/initramfs-evms2-temp/etc/"
262 mkdir -p "${TEMP}/initramfs-evms2-temp/bin/"
263 mkdir -p "${TEMP}/initramfs-evms2-temp/sbin/"
264 if [ "${EVMS2}" -eq '1' ]
266 print_info 1 ' EVMS2: Adding support...'
267 mkdir -p ${TEMP}/initramfs-evms2-temp/lib
268 cp -a /lib/ld-* "${TEMP}/initramfs-evms2-temp/lib" \
269 || gen_die 'Could not copy files for EVMS2!'
270 if [ -n "`ls /lib/libgcc_s*`" ]
272 cp -a /lib/libgcc_s* "${TEMP}/initramfs-evms2-temp/lib" \
273 || gen_die 'Could not copy files for EVMS2!'
275 cp -a /lib/libc-* /lib/libc.* "${TEMP}/initramfs-evms2-temp/lib" \
276 || gen_die 'Could not copy files for EVMS2!'
277 cp -a /lib/libdl-* /lib/libdl.* "${TEMP}/initramfs-evms2-temp/lib" \
278 || gen_die 'Could not copy files for EVMS2!'
279 cp -a /lib/libpthread* "${TEMP}/initramfs-evms2-temp/lib" \
280 || gen_die 'Could not copy files for EVMS2!'
281 cp -a /lib/libuuid*so* "${TEMP}/initramfs-evms2-temp/lib" \
282 || gen_die 'Could not copy files for EVMS2!'
283 cp -a /lib/libevms*so* "${TEMP}/initramfs-evms2-temp/lib" \
284 || gen_die 'Could not copy files for EVMS2!'
285 cp -a /lib/evms "${TEMP}/initramfs-evms2-temp/lib" \
286 || gen_die 'Could not copy files for EVMS2!'
287 cp -a /lib/evms/* "${TEMP}/initramfs-evms2-temp/lib/evms" \
288 || gen_die 'Could not copy files for EVMS2!'
289 cp -a /etc/evms.conf "${TEMP}/initramfs-evms2-temp/etc" \
290 || gen_die 'Could not copy files for EVMS2!'
291 cp /sbin/evms_activate "${TEMP}/initramfs-evms2-temp/sbin" \
292 || gen_die 'Could not copy over evms_activate!'
294 # Fix EVMS2 complaining that it can't find the swap utilities.
295 # These are not required in the initramfs
296 for swap_libs in "${TEMP}/initramfs-evms2-temp/lib/evms/*/swap*.so"
301 cd "${TEMP}/initramfs-evms2-temp/"
302 find . -print | cpio --quiet -o -H newc \
303 | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz
304 rm -r "${TEMP}/initramfs-evms2-temp/"
309 if [ "${GENSPLASH}" -eq '1' ]
311 if [ -x /usr/bin/splash_geninitramfs ] || [ -x /sbin/splash_geninitramfs ]
313 [ -z "${GENSPLASH_THEME}" ] && [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash
314 [ -z "${GENSPLASH_THEME}" ] && GENSPLASH_THEME=default
315 print_info 1 " >> Installing gensplash [ using the ${GENSPLASH_THEME} theme ]..."
318 [ -n "${GENSPLASH_RES}" ] && tmp="-r ${GENSPLASH_RES}"
319 splash_geninitramfs -g ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz ${tmp} ${GENSPLASH_THEME} || gen_die "Could not build splash cpio archive"
320 if [ -e "/usr/share/splashutils/initrd.splash" ]; then
321 if [ -d "${TEMP}/initramfs-gensplash-temp" ]
323 rm -r "${TEMP}/initramfs-gensplash-temp/"
325 mkdir -p "${TEMP}/initramfs-gensplash-temp/etc"
326 cd "${TEMP}/initramfs-gensplash-temp/"
327 gunzip -c ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz | cpio -idm --quiet -H newc || gen_die "unpacking splash cpio"
328 cp -f "/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-gensplash-temp/etc"
329 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz || gen_die "compressing splash cpio"
330 rm -r "${TEMP}/initramfs-gensplash-temp/"
333 print_warning 1 ' >> No splash detected; skipping!'
338 create_initramfs_overlay_cpio(){
339 cd ${INITRAMFS_OVERLAY}
340 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz
351 create_initramfs_modules() {
357 print_info 2 "initramfs: >> Searching for modules..."
358 if [ "${INSTALL_MOD_PATH}" != '' ]
360 cd ${INSTALL_MOD_PATH}
365 if [ -d "${TEMP}/initramfs-modules-${KV}-temp" ]
367 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
369 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/lib/modules/${KV}"
370 for i in `gen_dep_list`
372 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" 2>/dev/null| head -n 1 `
375 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
379 print_info 2 "initramfs: >> Copying ${i}${MOD_EXT}..."
380 cp -ax --parents "${mymod}" "${TEMP}/initramfs-modules-${KV}-temp"
383 cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initramfs-modules-${KV}-temp 2>/dev/null
385 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/etc/modules"
386 for group_modules in ${!MODULES_*}; do
387 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
388 print_list ${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}"
390 cd "${TEMP}/initramfs-modules-${KV}-temp/"
391 find . | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz
392 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
395 # check for static linked file with objdump
397 objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
401 create_initramfs_aux() {
402 if [ -d "${TEMP}/initramfs-aux-temp" ]
404 rm -r "${TEMP}/initramfs-aux-temp/"
406 mkdir -p "${TEMP}/initramfs-aux-temp/etc"
407 mkdir -p "${TEMP}/initramfs-aux-temp/sbin"
408 if [ -f "${CMD_LINUXRC}" ]
410 cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init"
411 print_info 2 " >> Copying user specified linuxrc: ${CMD_LINUXRC} to init"
413 if [ -f "${GK_SHARE}/${ARCH}/linuxrc" ]
415 cp "${GK_SHARE}/${ARCH}/linuxrc" "${TEMP}/initramfs-aux-temp/init"
417 cp "${GK_SHARE}/generic/linuxrc" "${TEMP}/initramfs-aux-temp/init"
421 # Make sure it's executable
422 chmod 0755 "${TEMP}/initramfs-aux-temp/init"
424 # Make a symlink to init .. incase we are bundled inside the kernel as one
426 cd ${TEMP}/initramfs-aux-temp
428 # ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc
430 if [ -f "${GK_SHARE}/${ARCH}/initrd.scripts" ]
432 cp "${GK_SHARE}/${ARCH}/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
434 cp "${GK_SHARE}/generic/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
437 if [ -f "${GK_SHARE}/${ARCH}/initrd.defaults" ]
439 cp "${GK_SHARE}/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
441 cp "${GK_SHARE}/generic/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
444 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
445 for group_modules in ${!MODULES_*}; do
446 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
447 echo -n "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
449 echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
451 if [ -f "${GK_SHARE}/${ARCH}/modprobe" ]
453 cp "${GK_SHARE}/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
455 cp "${GK_SHARE}/generic/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
457 if isTrue $CMD_DOKEYMAPAUTO
459 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
461 mkdir -p "${TEMP}/initramfs-aux-temp/lib/keymaps"
462 /bin/tar -C "${TEMP}/initramfs-aux-temp/lib/keymaps" -zxf "${GK_SHARE}/generic/keymaps.tar.gz"
463 if isTrue $CMD_SLOWUSB
465 echo 'MY_HWOPTS="${MY_HWOPTS} slowusb"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
469 if is_static /bin/cryptsetup
471 print_info 1 "Including LUKS support"
472 rm -f ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
473 cp /bin/cryptsetup ${TEMP}/initramfs-aux-temp/sbin/cryptsetup
474 chmod +x "${TEMP}/initramfs-aux-temp/sbin/cryptsetup"
476 print_info 1 "LUKS support requires static cryptsetup at /bin/cryptsetup"
477 print_info 1 "Not including LUKS support"
481 cd ${TEMP}/initramfs-aux-temp/sbin && ln -s ../init init
483 chmod +x "${TEMP}/initramfs-aux-temp/init"
484 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
485 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
486 chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
487 cd "${TEMP}/initramfs-aux-temp/"
488 find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz
489 rm -r "${TEMP}/initramfs-aux-temp/"
492 merge_initramfs_cpio_archives(){
493 cd "${CACHE_CPIO_DIR}"
494 MERGE_LIST="initramfs-base-layout.cpio.gz initramfs-aux.cpio.gz"
495 if [ ! -e "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz" ]
497 gen_die "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz is missing."
499 if [ ! -e "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz" ]
501 gen_die "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz is missing."
504 if [ "${BUSYBOX}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz ]
506 MERGE_LIST="${MERGE_LIST} initramfs-busybox-${BUSYBOX_VER}.cpio.gz"
509 if [ "${NOINITRDMODULES}" = '' -a -e ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz ]
511 MERGE_LIST="${MERGE_LIST} initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz"
514 # if [ "${UDEV}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz ]
516 # MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz"
518 if [ "${DISKLABEL}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz ]
520 MERGE_LIST="${MERGE_LIST} initramfs-blkid-${E2FSPROGS_VER}.cpio.gz"
522 if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ]
524 MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz"
526 if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz ]
528 MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz"
530 if [ "${SUSPEND}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-suspend-${SUSPEND_VER}.cpio.gz" ]
532 MERGE_LIST="${MERGE_LIST} initramfs-suspend-${SUSPEND_VER}.cpio.gz"
534 if [ "${EVMS2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz" ]
536 MERGE_LIST="${MERGE_LIST} initramfs-evms2.cpio.gz"
538 if [ "${LVM2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz" ]
540 MERGE_LIST="${MERGE_LIST} initramfs-lvm2-${LVM2_VER}.cpio.gz"
542 if [ "${DEVFS}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz" ]
544 MERGE_LIST="${MERGE_LIST} initramfs-devfs-${DEVFSD_VER}.cpio.gz"
546 if [ "${DMRAID}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz ]
548 MERGE_LIST="${MERGE_LIST} initramfs-dmraid-${DMRAID_VER}.cpio.gz"
550 if [ "${NOINITRDMODULES}" = '' -a -e "${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz" ]
552 MERGE_LIST="${MERGE_LIST} initramfs-modules-${KV}.cpio.gz"
554 if [ "${GENSPLASH}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz" ]
556 MERGE_LIST="${MERGE_LIST} initramfs-splash-${KV}.cpio.gz"
558 # This should always be appended last
559 if [ "${INITRAMFS_OVERLAY}" != '' -a -e "${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz" ]
561 MERGE_LIST="${MERGE_LIST} initramfs-overlay.cpio.gz"
565 print_info 1 "Merging"
566 for i in ${MERGE_LIST}
571 cat ${MERGE_LIST} > ${TMPDIR}/initramfs-${KV}
573 # Pegasos hack for merging the initramfs into the kernel at compile time
574 [ "${KERNEL_MAKE_DIRECTIVE}" == 'zImage.initrd' -a "${GENERATE_Z_IMAGE}" = '1' ] ||
575 [ "${KERNEL_MAKE_DIRECTIVE_2}" == 'zImage.initrd' -a "${GENERATE_Z_IMAGE}" = '1' ] &&
576 cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/arch/powerpc/boot/ramdisk.image.gz &&
577 rm ${TMPDIR}/initramfs-${KV}
579 # Mips also mimics Pegasos to merge the initramfs into the kernel
580 if [ ${BUILD_INITRAMFS} -eq 1 ]; then
581 cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/initramfs.cpio.gz
582 gunzip -f ${KERNEL_DIR}/initramfs.cpio.gz
587 if [ "${CLEAR_CPIO_CACHE}" == 'yes' ]
590 if [ -d ${CACHE_CPIO_DIR} ]
592 print_info 1 " >> Clearing old cpio archives..."
593 rm -r ${CACHE_CPIO_DIR}
597 if [ ! -d ${CACHE_CPIO_DIR} ]
599 mkdir -p ${CACHE_CPIO_DIR}
606 print_info 1 "initramfs: >> Initializing..."
608 mkdir -p ${CACHE_CPIO_DIR}
609 print_info 1 " >> Creating base_layout cpio archive..."
610 create_base_layout_cpio
612 print_info 1 " >> Creating auxilary cpio archive..."
615 if [ "${BUSYBOX}" -eq '1' ]
617 print_info 1 " >> Creating busybox cpio archive..."
621 if [ "${DEVFS}" -eq '1' ]
623 print_info 1 " >> Creating devfs cpio archive..."
627 # if [ "${UDEV}" -eq '1' ]
629 # print_info 1 " >> Creating udev cpio archive..."
633 if [ "${UNIONFS}" -eq '1' ]
635 print_info 1 " >> Creating unionfs modules cpio archive..."
636 create_unionfs_modules_cpio
637 print_info 1 " >> Creating unionfs tools cpio archive..."
638 create_unionfs_tools_cpio
641 if [ "${SUSPEND}" -eq '1' ]
643 print_info 1 " >> Creating suspend cpio archive..."
647 if [ "${LVM2}" -eq '1' ]
650 print_info 1 " >> Creating lvm2 cpio archive..."
654 if [ "${DMRAID}" -eq '1' ]
656 print_info 1 " >> Creating dmraid cpio archive..."
660 if [ "${EVMS2}" -eq '1' -a -e '/sbin/evms_activate' ]
662 print_info 1 " >> Creating evms2 cpio archive..."
666 if [ "${NOINITRDMODULES}" = '' ]
668 print_info 1 " >> Creating insmod cpio archive..."
670 print_info 1 " >> Creating modules cpio archive..."
671 create_initramfs_modules
673 print_info 1 "initramfs: Not copying modules..."
676 if [ "${DISKLABEL}" -eq '1' ]
678 print_info 1 " >> Creating blkid cpio archive..."
684 if [ "${INITRAMFS_OVERLAY}" != '' ]
686 print_info 1 " >> Creating initramfs_overlay cpio archive..."
687 create_initramfs_overlay_cpio
690 merge_initramfs_cpio_archives
692 if ! isTrue "${CMD_NOINSTALL}"
694 if [ "${GENERATE_Z_IMAGE}" != '1' ]
696 cp ${TMPDIR}/initramfs-${KV} ${BOOTDIR}/initramfs-${KNAME}-${ARCH}-${KV} ||
697 gen_die 'Could not copy the initramfs to ${BOOTDIR}!'