4 CPIO_ARGS="--quiet -o -H newc"
8 local destdir=$1 files=$2
11 lddtree $files | tr ')(' '\n' |awk '/=>/{ if($3 ~ /^\//){print $3}}' | sort | uniq | cpio -p --make-directories --dereference --quiet $destdir
15 append_base_layout() {
16 if [ -d "${TEMP}/initramfs-base-temp" ]
18 rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
21 mkdir -p ${TEMP}/initramfs-base-temp/dev
22 mkdir -p ${TEMP}/initramfs-base-temp/bin
23 mkdir -p ${TEMP}/initramfs-base-temp/etc
24 mkdir -p ${TEMP}/initramfs-base-temp/usr
25 mkdir -p ${TEMP}/initramfs-base-temp/lib
26 mkdir -p ${TEMP}/initramfs-base-temp/mnt
27 mkdir -p ${TEMP}/initramfs-base-temp/run
28 mkdir -p ${TEMP}/initramfs-base-temp/sbin
29 mkdir -p ${TEMP}/initramfs-base-temp/proc
30 mkdir -p ${TEMP}/initramfs-base-temp/temp
31 mkdir -p ${TEMP}/initramfs-base-temp/tmp
32 mkdir -p ${TEMP}/initramfs-base-temp/sys
33 mkdir -p ${TEMP}/initramfs-temp/.initrd
34 mkdir -p ${TEMP}/initramfs-base-temp/var/lock/dmraid
35 mkdir -p ${TEMP}/initramfs-base-temp/sbin
36 mkdir -p ${TEMP}/initramfs-base-temp/usr/bin
37 mkdir -p ${TEMP}/initramfs-base-temp/usr/sbin
38 ln -s lib ${TEMP}/initramfs-base-temp/lib64
40 echo "/dev/ram0 / ext2 defaults 0 0" > ${TEMP}/initramfs-base-temp/etc/fstab
41 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initramfs-base-temp/etc/fstab
43 cd ${TEMP}/initramfs-base-temp/dev
44 mknod -m 660 console c 5 1
45 mknod -m 660 null c 1 3
46 mknod -m 660 zero c 1 5
47 mknod -m 600 tty0 c 4 0
48 mknod -m 600 tty1 c 4 1
49 mknod -m 600 ttyS0 c 4 64
51 date -u '+%Y%m%d-%H%M%S' > ${TEMP}/initramfs-base-temp/etc/build_date
53 cd "${TEMP}/initramfs-base-temp/"
54 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
55 || gen_die "compressing baselayout cpio"
57 rm -rf "${TEMP}/initramfs-base-temp" > /dev/null
61 if [ -d "${TEMP}/initramfs-busybox-temp" ]
63 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
66 mkdir -p "${TEMP}/initramfs-busybox-temp/bin/"
67 tar -xjf "${BUSYBOX_BINCACHE}" -C "${TEMP}/initramfs-busybox-temp/bin" busybox ||
68 gen_die 'Could not extract busybox bincache!'
69 chmod +x "${TEMP}/initramfs-busybox-temp/bin/busybox"
71 mkdir -p "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/"
72 cp "${GK_SHARE}/defaults/udhcpc.scripts" ${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script
73 chmod +x "${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script"
75 # Set up a few default symlinks
76 for i in ${BUSYBOX_APPLETS:-[ ash sh mount uname echo cut cat}; do
77 rm -f ${TEMP}/initramfs-busybox-temp/bin/$i > /dev/null
78 ln -s busybox ${TEMP}/initramfs-busybox-temp/bin/$i ||
79 gen_die "Busybox error: could not link ${i}!"
82 cd "${TEMP}/initramfs-busybox-temp/"
83 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
84 || gen_die "compressing busybox cpio"
86 rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null
90 if [ -d "${TEMP}/initramfs-blkid-temp" ]
92 rm -r "${TEMP}/initramfs-blkid-temp/"
95 mkdir -p "${TEMP}/initramfs-blkid-temp/sbin/"
96 [ "${DISKLABEL}" = '1' ] && { /bin/bzip2 -dc "${BLKID_BINCACHE}" > "${TEMP}/initramfs-blkid-temp/sbin/blkid" ||
97 gen_die "Could not extract blkid binary cache!"; }
98 chmod a+x "${TEMP}/initramfs-blkid-temp/sbin/blkid"
99 cd "${TEMP}/initramfs-blkid-temp/"
100 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
101 || gen_die "compressing blkid cpio"
103 rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null
107 # if [ -d "${TEMP}/initramfs-fuse-temp" ]
109 # rm -r "${TEMP}/initramfs-fuse-temp"
112 # mkdir -p "${TEMP}/initramfs-fuse-temp/lib/"
113 # tar -C "${TEMP}/initramfs-fuse-temp/lib/" -xjf "${FUSE_BINCACHE}"
114 # cd "${TEMP}/initramfs-fuse-temp/"
115 # find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
116 # || gen_die "compressing fuse cpio"
117 # rm -rf "${TEMP}/initramfs-fuse-temp" > /dev/null
120 append_unionfs_fuse() {
121 if [ -d "${TEMP}/initramfs-unionfs-fuse-temp" ]
123 rm -r "${TEMP}/initramfs-unionfs-fuse-temp"
126 mkdir -p "${TEMP}/initramfs-unionfs-fuse-temp/sbin/"
127 bzip2 -dc "${UNIONFS_FUSE_BINCACHE}" > "${TEMP}/initramfs-unionfs-fuse-temp/sbin/unionfs" ||
128 gen_die 'Could not extract unionfs-fuse binary cache!'
129 chmod a+x "${TEMP}/initramfs-unionfs-fuse-temp/sbin/unionfs"
130 cd "${TEMP}/initramfs-unionfs-fuse-temp/"
131 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
132 || gen_die "compressing unionfs fuse cpio"
134 rm -rf "${TEMP}/initramfs-unionfs-fuse-temp" > /dev/null
138 # if [ -d "${TEMP}/initramfs-suspend-temp" ];
140 # rm -r "${TEMP}/initramfs-suspend-temp/"
142 # print_info 1 'SUSPEND: Adding support (compiling binaries)...'
144 # mkdir -p "${TEMP}/initramfs-suspend-temp/"
145 # /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" ||
146 # gen_die "Could not extract suspend binary cache!"
147 # mkdir -p "${TEMP}/initramfs-suspend-temp/etc"
148 # cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" ||
149 # gen_die 'Could not copy /etc/suspend.conf'
150 # cd "${TEMP}/initramfs-suspend-temp/"
151 # find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
152 # || gen_die "compressing suspend cpio"
153 # rm -r "${TEMP}/initramfs-suspend-temp/"
157 if [ -d "${TEMP}/initramfs-multipath-temp" ]
159 rm -r "${TEMP}/initramfs-multipath-temp"
161 print_info 1 ' Multipath support being added'
162 mkdir -p "${TEMP}/initramfs-multipath-temp/bin/"
163 mkdir -p "${TEMP}/initramfs-multipath-temp/etc/"
164 mkdir -p "${TEMP}/initramfs-multipath-temp/sbin/"
165 mkdir -p "${TEMP}/initramfs-multipath-temp/lib/"
168 copy_binaries "${TEMP}/initramfs-multipath-temp" "$(echo /sbin/{multipath,kpartx,mpath_prio_*,devmap_name,dmsetup} /lib64/udev/scsi_id /bin/mountpoint)"
170 if [ -x /sbin/multipath ]
172 cp /etc/multipath.conf "${TEMP}/initramfs-multipath-temp/etc/" || gen_die 'could not copy /etc/multipath.conf please check this'
174 # /etc/scsi_id.config does not exist in newer udevs
175 # copy it optionally.
176 if [ -x /sbin/scsi_id -a -f /etc/scsi_id.config ]
178 cp /etc/scsi_id.config "${TEMP}/initramfs-multipath-temp/etc/" || gen_die 'could not copy scsi_id.config'
180 cd "${TEMP}/initramfs-multipath-temp"
181 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
182 || gen_die "compressing multipath cpio"
184 rm -r "${TEMP}/initramfs-multipath-temp/"
188 if [ -d "${TEMP}/initramfs-dmraid-temp" ]
190 rm -r "${TEMP}/initramfs-dmraid-temp/"
192 print_info 1 'DMRAID: Adding support (compiling binaries)...'
194 mkdir -p "${TEMP}/initramfs-dmraid-temp/"
195 /bin/tar -jxpf "${DMRAID_BINCACHE}" -C "${TEMP}/initramfs-dmraid-temp" ||
196 gen_die "Could not extract dmraid binary cache!";
197 cd "${TEMP}/initramfs-dmraid-temp/"
198 RAID456=`find . -type f -name raid456.ko`
199 if [ -n "${RAID456}" ]
201 cd "${RAID456/raid456.ko/}"
202 ln -sf raid456.kp raid45.ko
203 cd "${TEMP}/initramfs-dmraid-temp/"
205 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
206 || gen_die "compressing dmraid cpio"
208 rm -r "${TEMP}/initramfs-dmraid-temp/"
212 if [ -d "${TEMP}/initramfs-iscsi-temp" ]
214 rm -r "${TEMP}/initramfs-iscsi-temp/"
216 print_info 1 'iSCSI: Adding support (compiling binaries)...'
219 mkdir -p "${TEMP}/initramfs-iscsi-temp/bin/"
220 /bin/bzip2 -dc "${ISCSI_BINCACHE}" > "${TEMP}/initramfs-iscsi-temp/bin/iscsistart" ||
221 gen_die "Could not extract iscsi binary cache!"
222 chmod a+x "${TEMP}/initramfs-iscsi-temp/bin/iscsistart"
223 cd "${TEMP}/initramfs-iscsi-temp/"
224 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
225 || gen_die "compressing iscsi cpio"
227 rm -rf "${TEMP}/initramfs-iscsi-temp" > /dev/null
231 if [ -d "${TEMP}/initramfs-lvm-temp" ]
233 rm -r "${TEMP}/initramfs-lvm-temp/"
236 mkdir -p "${TEMP}/initramfs-lvm-temp/bin/"
237 mkdir -p "${TEMP}/initramfs-lvm-temp/etc/lvm/"
238 if [ -e '/sbin/lvm.static' ]
240 print_info 1 ' LVM: Adding support (using local static binary /sbin/lvm.static)...'
241 cp /sbin/lvm.static "${TEMP}/initramfs-lvm-temp/bin/lvm" ||
242 gen_die 'Could not copy over lvm!'
244 if [ -e '/sbin/dmsetup.static' ]
246 cp /sbin/dmsetup.static "${TEMP}/initramfs-lvm-temp/bin/dmsetup"
248 elif [ -e '/sbin/lvm' ] && LC_ALL="C" ldd /sbin/lvm|grep -q 'not a dynamic executable'
250 print_info 1 ' LVM: Adding support (using local static binary /sbin/lvm)...'
251 cp /sbin/lvm "${TEMP}/initramfs-lvm-temp/bin/lvm" ||
252 gen_die 'Could not copy over lvm!'
254 if [ -e '/sbin/dmsetup' ] && LC_ALL="C" ldd /sbin/dmsetup | grep -q 'not a dynamic executable'
256 cp /sbin/dmsetup "${TEMP}/initramfs-lvm-temp/bin/dmsetup"
259 print_info 1 ' LVM: Adding support (compiling binaries)...'
261 /bin/tar -jxpf "${LVM_BINCACHE}" -C "${TEMP}/initramfs-lvm-temp" ||
262 gen_die "Could not extract lvm binary cache!";
263 mv ${TEMP}/initramfs-lvm-temp/sbin/lvm.static ${TEMP}/initramfs-lvm-temp/bin/lvm ||
264 gen_die 'LVM error: Could not move lvm.static to lvm!'
266 mv ${TEMP}/initramfs-lvm-temp/sbin/dmsetup.static ${TEMP}/initramfs-lvm-temp/bin/dmsetup ||
267 gen_die 'LVM error: Could not move dmsetup.static to dmsetup!'
271 # lvm dumpconfig 2>&1 > /dev/null || gen_die 'Could not copy over lvm.conf!'
275 cp /etc/lvm/lvm.conf "${TEMP}/initramfs-lvm-temp/etc/lvm/" ||
276 gen_die 'Could not copy over lvm.conf!'
278 # gen_die 'Could not copy over lvm.conf!'
281 cd "${TEMP}/initramfs-lvm-temp/"
282 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
283 || gen_die "compressing lvm cpio"
285 rm -r "${TEMP}/initramfs-lvm-temp/"
289 if [ -d "${TEMP}/initramfs-mdadm-temp" ]
291 rm -r "${TEMP}/initramfs-mdadm-temp/"
294 mkdir -p "${TEMP}/initramfs-mdadm-temp/etc/"
295 mkdir -p "${TEMP}/initramfs-mdadm-temp/sbin/"
296 if [ "${MDADM}" = '1' ]
298 if [ -n "${MDADM_CONFIG}" ]
300 if [ -f "${MDADM_CONFIG}" ]
302 cp -a "${MDADM_CONFIG}" "${TEMP}/initramfs-mdadm-temp/etc/mdadm.conf" \
303 || gen_die "Could not copy mdadm.conf!"
305 gen_die 'sl${MDADM_CONFIG} does not exist!'
308 print_info 1 ' MDADM: Skipping inclusion of mdadm.conf'
311 if [ -e '/sbin/mdadm' ] && LC_ALL="C" ldd /sbin/mdadm | grep -q 'not a dynamic executable' \
312 && [ -e '/sbin/mdmon' ] && LC_ALL="C" ldd /sbin/mdmon | grep -q 'not a dynamic executable'
314 print_info 1 ' MDADM: Adding support (using local static binaries /sbin/mdadm and /sbin/mdmon)...'
315 cp /sbin/mdadm /sbin/mdmon "${TEMP}/initramfs-mdadm-temp/sbin/" ||
316 gen_die 'Could not copy over mdadm!'
318 print_info 1 ' MDADM: Adding support (compiling binaries)...'
320 /bin/tar -jxpf "${MDADM_BINCACHE}" -C "${TEMP}/initramfs-mdadm-temp" ||
321 gen_die "Could not extract mdadm binary cache!";
324 cd "${TEMP}/initramfs-mdadm-temp/"
325 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
326 || gen_die "compressing mdadm cpio"
328 rm -rf "${TEMP}/initramfs-mdadm-temp" > /dev/null
332 splash_geninitramfs=`which splash_geninitramfs 2>/dev/null`
333 if [ -x "${splash_geninitramfs}" ]
335 [ -z "${SPLASH_THEME}" ] && [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash
336 [ -z "${SPLASH_THEME}" ] && SPLASH_THEME=default
337 print_info 1 " >> Installing splash [ using the ${SPLASH_THEME} theme ]..."
338 if [ -d "${TEMP}/initramfs-splash-temp" ]
340 rm -r "${TEMP}/initramfs-splash-temp/"
342 mkdir -p "${TEMP}/initramfs-splash-temp"
345 [ -n "${SPLASH_RES}" ] && tmp="-r ${SPLASH_RES}"
346 splash_geninitramfs -c "${TEMP}/initramfs-splash-temp" ${tmp} ${SPLASH_THEME} || gen_die "Could not build splash cpio archive"
347 if [ -e "/usr/share/splashutils/initrd.splash" ]; then
348 mkdir -p "${TEMP}/initramfs-splash-temp/etc"
349 cp -f "/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-splash-temp/etc"
351 cd "${TEMP}/initramfs-splash-temp/"
352 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
353 || gen_die "compressing splash cpio"
355 rm -r "${TEMP}/initramfs-splash-temp/"
357 print_warning 1 ' >> No splash detected; skipping!'
362 cd ${INITRAMFS_OVERLAY}
363 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
364 || gen_die "compressing overlay cpio"
368 if [ -d "${TEMP}/initramfs-luks-temp" ]
370 rm -r "${TEMP}/initramfs-luks-temp/"
373 mkdir -p "${TEMP}/initramfs-luks-temp/lib/luks/"
374 mkdir -p "${TEMP}/initramfs-luks-temp/sbin"
375 cd "${TEMP}/initramfs-luks-temp"
379 if is_static /bin/cryptsetup
381 print_info 1 "Including LUKS support"
382 cp /bin/cryptsetup ${TEMP}/initramfs-luks-temp/sbin/cryptsetup
383 chmod +x "${TEMP}/initramfs-luks-temp/sbin/cryptsetup"
384 elif is_static /sbin/cryptsetup
386 print_info 1 "Including LUKS support"
387 cp /sbin/cryptsetup ${TEMP}/initramfs-luks-temp/sbin/cryptsetup
388 chmod +x "${TEMP}/initramfs-luks-temp/sbin/cryptsetup"
390 print_info 1 "LUKS support requires static cryptsetup at /bin/cryptsetup or /sbin/cryptsetup"
391 print_info 1 "Not including LUKS support"
395 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
396 || gen_die "appending cryptsetup to cpio"
399 rm -r "${TEMP}/initramfs-luks-temp/"
403 if [ -z "${FIRMWARE_FILES}" -a ! -d "${FIRMWARE_DIR}" ]
405 gen_die "specified firmware directory (${FIRMWARE_DIR}) does not exist"
407 if [ -d "${TEMP}/initramfs-firmware-temp" ]
409 rm -r "${TEMP}/initramfs-firmware-temp/"
411 mkdir -p "${TEMP}/initramfs-firmware-temp/lib/firmware"
412 cd "${TEMP}/initramfs-firmware-temp"
413 if [ -n "${FIRMWARE_FILES}" ]
417 for i in ${FIRMWARE_FILES}
419 cp -L "${i}" ${TEMP}/initramfs-firmware-temp/lib/firmware/
423 cp -a "${FIRMWARE_DIR}"/* ${TEMP}/initramfs-firmware-temp/lib/firmware/
425 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
426 || gen_die "appending firmware to cpio"
428 rm -r "${TEMP}/initramfs-firmware-temp/"
432 if [ -d "${TEMP}/initramfs-gpg-temp" ]
434 rm -r "${TEMP}/initramfs-gpg-temp"
437 mkdir -p "${TEMP}/initramfs-gpg-temp/sbin/"
438 if [ ! -e ${GPG_BINCACHE} ] ; then
439 print_info 1 ' GPG: Adding support (compiling binaries)...'
442 bzip2 -dc "${GPG_BINCACHE}" > "${TEMP}/initramfs-gpg-temp/sbin/gpg" ||
443 gen_die 'Could not extract gpg binary cache!'
444 chmod a+x "${TEMP}/initramfs-gpg-temp/sbin/gpg"
445 cd "${TEMP}/initramfs-gpg-temp/"
446 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}"
447 rm -rf "${TEMP}/initramfs-gpg-temp" > /dev/null
464 print_info 2 "initramfs: >> Searching for modules..."
465 if [ "${INSTALL_MOD_PATH}" != '' ]
467 cd ${INSTALL_MOD_PATH}
472 if [ -d "${TEMP}/initramfs-modules-${KV}-temp" ]
474 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
476 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/lib/modules/${KV}"
477 for i in `gen_dep_list`
479 mymod=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" 2>/dev/null| head -n 1 `
482 print_warning 2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
486 print_info 2 "initramfs: >> Copying ${i}${MOD_EXT}..."
487 cp -ax --parents "${mymod}" "${TEMP}/initramfs-modules-${KV}-temp"
490 cp -ax --parents ./lib/modules/${KV}/modules* ${TEMP}/initramfs-modules-${KV}-temp 2>/dev/null
492 mkdir -p "${TEMP}/initramfs-modules-${KV}-temp/etc/modules"
493 for group_modules in ${!MODULES_*}; do
494 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
495 print_list ${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}"
497 cd "${TEMP}/initramfs-modules-${KV}-temp/"
498 find . | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
499 || gen_die "compressing modules cpio"
501 rm -r "${TEMP}/initramfs-modules-${KV}-temp/"
504 # check for static linked file with objdump
506 LANG="C" LC_ALL="C" objdump -T $1 2>&1 | grep "not a dynamic object" > /dev/null
511 if [ -d "${TEMP}/initramfs-aux-temp" ]
513 rm -r "${TEMP}/initramfs-aux-temp/"
515 mkdir -p "${TEMP}/initramfs-aux-temp/etc"
516 mkdir -p "${TEMP}/initramfs-aux-temp/sbin"
517 if [ -f "${CMD_LINUXRC}" ]
519 cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init"
520 print_info 2 " >> Copying user specified linuxrc: ${CMD_LINUXRC} to init"
524 cp "${GK_SHARE}/netboot/linuxrc.x" "${TEMP}/initramfs-aux-temp/init"
526 if [ -f "${GK_SHARE}/arch/${ARCH}/linuxrc" ]
528 cp "${GK_SHARE}/arch/${ARCH}/linuxrc" "${TEMP}/initramfs-aux-temp/init"
530 cp "${GK_SHARE}/defaults/linuxrc" "${TEMP}/initramfs-aux-temp/init"
535 # Make sure it's executable
536 chmod 0755 "${TEMP}/initramfs-aux-temp/init"
538 # Make a symlink to init .. incase we are bundled inside the kernel as one
540 cd ${TEMP}/initramfs-aux-temp
542 # ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc
544 if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.scripts" ]
546 cp "${GK_SHARE}/arch/${ARCH}/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
548 cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
551 if [ -f "${GK_SHARE}/arch/${ARCH}/initrd.defaults" ]
553 cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
555 cp "${GK_SHARE}/defaults/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
558 if [ -n "${REAL_ROOT}" ]
560 sed -i "s:^REAL_ROOT=.*$:REAL_ROOT='${REAL_ROOT}':" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
563 echo -n 'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
564 for group_modules in ${!MODULES_*}; do
565 group="$(echo $group_modules | cut -d_ -f2 | tr "[:upper:]" "[:lower:]")"
566 echo -n "${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
568 echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
570 if [ -f "${GK_SHARE}/arch/${ARCH}/modprobe" ]
572 cp "${GK_SHARE}/arch/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
574 cp "${GK_SHARE}/defaults/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
576 if isTrue $CMD_DOKEYMAPAUTO
578 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs-aux-temp/etc/initrd.defaults
580 if isTrue $CMD_KEYMAP
582 mkdir -p "${TEMP}/initramfs-aux-temp/lib/keymaps"
583 /bin/tar -C "${TEMP}/initramfs-aux-temp/lib/keymaps" -zxf "${GK_SHARE}/defaults/keymaps.tar.gz"
586 cd ${TEMP}/initramfs-aux-temp/sbin && ln -s ../init init
588 chmod +x "${TEMP}/initramfs-aux-temp/init"
589 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
590 chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
591 chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe"
595 cd "${GK_SHARE}/netboot/misc"
596 cp -pPRf * "${TEMP}/initramfs-aux-temp/"
599 cd "${TEMP}/initramfs-aux-temp/"
600 find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
601 || gen_die "compressing auxilary cpio"
603 rm -r "${TEMP}/initramfs-aux-temp/"
608 local func="append_${name}"
610 [ $# -eq 0 ] && gen_die "append_data() called with zero arguments"
611 if [ $# -eq 1 ] || isTrue ${var}
613 print_info 1 " >> Appending ${name} cpio data..."
614 ${func} || gen_die "${func}() failed"
619 local compress_ext=""
620 print_info 1 "initramfs: >> Initializing..."
623 CPIO="${TMPDIR}/initramfs-${KV}"
624 echo | cpio ${CPIO_ARGS} -F "${CPIO}" 2>/dev/null \
625 || gen_die "Could not create empty cpio at ${CPIO}"
627 append_data 'base_layout'
628 append_data 'auxilary' "${BUSYBOX}"
629 append_data 'busybox' "${BUSYBOX}"
630 append_data 'lvm' "${LVM}"
631 append_data 'dmraid' "${DMRAID}"
632 append_data 'iscsi' "${ISCSI}"
633 append_data 'mdadm' "${MDADM}"
634 append_data 'luks' "${LUKS}"
635 append_data 'multipath' "${MULTIPATH}"
636 append_data 'gpg' "${GPG}"
638 if [ "${RAMDISKMODULES}" = '1' ]
640 append_data 'modules'
642 print_info 1 "initramfs: Not copying modules..."
645 append_data 'blkid' "${DISKLABEL}"
647 append_data 'unionfs_fuse' "${UNIONFS}"
649 append_data 'splash' "${SPLASH}"
651 if isTrue "${FIRMWARE}" && [ -n "${FIRMWARE_DIR}" ]
653 append_data 'firmware'
656 # This should always be appended last
657 if [ "${INITRAMFS_OVERLAY}" != '' ]
659 append_data 'overlay'
662 # Implement support for disabling compression
663 if isTrue "${COMPRESS_INITRD}"
666 print_info 1 " >> Compressing cpio data..."
667 gzip -9 "${CPIO}" || gen_die "Compression failed"
668 mv -f "${CPIO}.gz" "${CPIO}" || gen_die "Rename failed"
672 if isTrue "${INTEGRATED_INITRAMFS}"
674 # cp ${TMPDIR}/initramfs-${KV} ${KERNEL_DIR}/usr/initramfs_data.cpio.gz
675 mv ${TMPDIR}/initramfs-${KV} ${TMPDIR}/initramfs-${KV}.cpio${compress_ext}
676 # sed -i "s|^.*CONFIG_INITRAMFS_SOURCE=.*$|CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio.gz\"|" ${KERNEL_DIR}/.config
677 sed -i '/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' ${KERNEL_DIR}/.config
678 echo -e "CONFIG_INITRAMFS_SOURCE=\"${TMPDIR}/initramfs-${KV}.cpio${compress_ext}\"\nCONFIG_INITRAMFS_ROOT_UID=0\nCONFIG_INITRAMFS_ROOT_GID=0" >> ${KERNEL_DIR}/.config
681 if isTrue "${CMD_INSTALL}"
683 if ! isTrue "${INTEGRATED_INITRAMFS}"
685 copy_image_with_preserve "initramfs" \
686 "${TMPDIR}/initramfs-${KV}" \
687 "initramfs-${KNAME}-${ARCH}-${KV}"