4 CPIO_ARGS
="--quiet -o -H newc"
6 # The copy_binaries function is explicitly released under the CC0 license to
7 # encourage wide adoption and re-use. That means:
8 # - You may use the code of copy_binaries() as CC0 outside of genkernel
9 # - Contributions to this function are licensed under CC0 as well.
10 # - If you change it outside of genkernel, please consider sending your
11 # modifications back to genkernel@gentoo.org.
13 # On a side note: "Both public domain works and the simple license provided by
14 # CC0 are compatible with the GNU GPL."
15 # (from https://www.gnu.org/licenses/license-list.html#CC0)
18 # - Sebastian Pipping <sebastian@pipping.org> (error checking)
19 # - Robin H. Johnson <robbat2@gentoo.org> (complete rewrite)
20 # - Richard Yao <ryao@cs.stonybrook.edu> (original concept)
22 # copy_binaries DESTDIR BINARIES...
27 for binary
in "$@"; do
28 [[ -e
"${binary}" ]] \
29 || gen_die
"Binary ${binary} could not be found"
31 if LC_ALL
=C lddtree
"${binary}" 2>&1 | fgrep
-q
'not found'; then
32 gen_die
"Binary ${binary} is linked to missing libraries and may need to be re-built"
35 # This must be OUTSIDE the for loop, we only want to run lddtree etc ONCE.
38 |
awk '/=>/{ if($3 ~ /^\//){print $3}}' \
41 |
cpio -p
--make-directories
--dereference
--quiet
"${destdir}" \
42 || gen_die
"Binary ${f} or some of its library dependencies could not be copied"
45 log_future_cpio_content
() {
46 if [[ "${LOGLEVEL}" -gt
1 ]]; then
47 echo =================================================================
48 echo "About to add these files from '${PWD}' to cpio archive:"
49 find . |
xargs ls -ald
50 echo =================================================================
54 append_base_layout
() {
55 if [ -d
"${TEMP}/initramfs-base-temp" ]
57 rm -rf
"${TEMP}/initramfs-base-temp" > /dev
/null
60 mkdir
-p
${TEMP}/initramfs
-base
-temp
/dev
61 mkdir
-p
${TEMP}/initramfs
-base
-temp
/bin
62 mkdir
-p
${TEMP}/initramfs
-base
-temp
/etc
63 mkdir
-p
${TEMP}/initramfs
-base
-temp
/usr
64 mkdir
-p
${TEMP}/initramfs
-base
-temp
/lib
65 mkdir
-p
${TEMP}/initramfs
-base
-temp
/mnt
66 mkdir
-p
${TEMP}/initramfs
-base
-temp
/run
67 mkdir
-p
${TEMP}/initramfs
-base
-temp
/sbin
68 mkdir
-p
${TEMP}/initramfs
-base
-temp
/proc
69 mkdir
-p
${TEMP}/initramfs
-base
-temp
/temp
70 mkdir
-p
${TEMP}/initramfs
-base
-temp
/tmp
71 mkdir
-p
${TEMP}/initramfs
-base
-temp
/sys
72 mkdir
-p
${TEMP}/initramfs
-temp
/.initrd
73 mkdir
-p
${TEMP}/initramfs
-base
-temp
/var
/lock
/dmraid
74 mkdir
-p
${TEMP}/initramfs
-base
-temp
/sbin
75 mkdir
-p
${TEMP}/initramfs
-base
-temp
/usr
/bin
76 mkdir
-p
${TEMP}/initramfs
-base
-temp
/usr
/sbin
77 ln -s lib
${TEMP}/initramfs
-base
-temp
/lib64
79 echo "/dev/ram0 / ext2 defaults 0 0" > ${TEMP}/initramfs
-base
-temp
/etc
/fstab
80 echo "proc /proc proc defaults 0 0" >> ${TEMP}/initramfs
-base
-temp
/etc
/fstab
82 cd ${TEMP}/initramfs
-base
-temp
/dev
83 mknod
-m
660 console c
5 1
84 mknod
-m
660 null c
1 3
85 mknod
-m
660 zero c
1 5
86 mknod
-m
600 tty0 c
4 0
87 mknod
-m
600 tty1 c
4 1
88 mknod
-m
600 ttyS0 c
4 64
90 date -u
'+%Y%m%d-%H%M%S' > ${TEMP}/initramfs
-base
-temp
/etc
/build_date
92 cd "${TEMP}/initramfs-base-temp/"
93 log_future_cpio_content
94 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
95 || gen_die
"compressing baselayout cpio"
97 rm -rf
"${TEMP}/initramfs-base-temp" > /dev
/null
101 if [ -d
"${TEMP}/initramfs-busybox-temp" ]
103 rm -rf
"${TEMP}/initramfs-busybox-temp" > /dev
/null
106 mkdir
-p
"${TEMP}/initramfs-busybox-temp/bin/"
107 tar -xjf
"${BUSYBOX_BINCACHE}" -C
"${TEMP}/initramfs-busybox-temp/bin" busybox ||
108 gen_die
'Could not extract busybox bincache!'
109 chmod +x
"${TEMP}/initramfs-busybox-temp/bin/busybox"
111 mkdir
-p
"${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/"
112 cp "${GK_SHARE}/defaults/udhcpc.scripts" ${TEMP}/initramfs
-busybox
-temp
/usr
/share
/udhcpc
/default.
script
113 chmod +x
"${TEMP}/initramfs-busybox-temp/usr/share/udhcpc/default.script"
115 # Set up a few default symlinks
116 for i
in ${BUSYBOX_APPLETS:-[ ash sh mount uname echo cut cat}; do
117 rm -f
${TEMP}/initramfs
-busybox
-temp
/bin
/$i > /dev
/null
118 ln -s busybox
${TEMP}/initramfs
-busybox
-temp
/bin
/$i ||
119 gen_die
"Busybox error: could not link ${i}!"
122 cd "${TEMP}/initramfs-busybox-temp/"
123 log_future_cpio_content
124 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
125 || gen_die
"compressing busybox cpio"
127 rm -rf
"${TEMP}/initramfs-busybox-temp" > /dev
/null
131 if [ -d
"${TEMP}/initramfs-blkid-temp" ]
133 rm -r
"${TEMP}/initramfs-blkid-temp/"
136 mkdir
-p
"${TEMP}/initramfs-blkid-temp/"
138 if [[ "${DISKLABEL}" = "1" ]]; then
139 copy_binaries
"${TEMP}"/initramfs
-blkid
-temp
/ /sbin
/blkid
142 cd "${TEMP}/initramfs-blkid-temp/"
143 log_future_cpio_content
144 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
145 || gen_die
"compressing blkid cpio"
147 rm -rf
"${TEMP}/initramfs-blkid-temp" > /dev
/null
151 # if [ -d "${TEMP}/initramfs-fuse-temp" ]
153 # rm -r "${TEMP}/initramfs-fuse-temp"
156 # mkdir -p "${TEMP}/initramfs-fuse-temp/lib/"
157 # tar -C "${TEMP}/initramfs-fuse-temp/lib/" -xjf "${FUSE_BINCACHE}"
158 # cd "${TEMP}/initramfs-fuse-temp/"
159 # find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
160 # || gen_die "compressing fuse cpio"
161 # rm -rf "${TEMP}/initramfs-fuse-temp" > /dev/null
164 append_unionfs_fuse
() {
165 if [ -d
"${TEMP}/initramfs-unionfs-fuse-temp" ]
167 rm -r
"${TEMP}/initramfs-unionfs-fuse-temp"
170 mkdir
-p
"${TEMP}/initramfs-unionfs-fuse-temp/sbin/"
171 bzip2 -dc "${UNIONFS_FUSE_BINCACHE}" > "${TEMP}/initramfs-unionfs-fuse-temp/sbin/unionfs" ||
172 gen_die
'Could not extract unionfs-fuse binary cache!'
173 chmod a
+x
"${TEMP}/initramfs-unionfs-fuse-temp/sbin/unionfs"
174 cd "${TEMP}/initramfs-unionfs-fuse-temp/"
175 log_future_cpio_content
176 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
177 || gen_die
"compressing unionfs fuse cpio"
179 rm -rf
"${TEMP}/initramfs-unionfs-fuse-temp" > /dev
/null
183 # if [ -d "${TEMP}/initramfs-suspend-temp" ];
185 # rm -r "${TEMP}/initramfs-suspend-temp/"
187 # print_info 1 'SUSPEND: Adding support (compiling binaries)...'
189 # mkdir -p "${TEMP}/initramfs-suspend-temp/"
190 # /bin/tar -jxpf "${SUSPEND_BINCACHE}" -C "${TEMP}/initramfs-suspend-temp" ||
191 # gen_die "Could not extract suspend binary cache!"
192 # mkdir -p "${TEMP}/initramfs-suspend-temp/etc"
193 # cp -f /etc/suspend.conf "${TEMP}/initramfs-suspend-temp/etc" ||
194 # gen_die 'Could not copy /etc/suspend.conf'
195 # cd "${TEMP}/initramfs-suspend-temp/"
196 # log_future_cpio_content
197 # find . -print | cpio ${CPIO_ARGS} --append -F "${CPIO}" \
198 # || gen_die "compressing suspend cpio"
199 # rm -r "${TEMP}/initramfs-suspend-temp/"
203 if [ -d
"${TEMP}/initramfs-multipath-temp" ]
205 rm -r
"${TEMP}/initramfs-multipath-temp"
207 print_info
1 ' Multipath support being added'
208 mkdir
-p
"${TEMP}"/initramfs
-multipath
-temp
/{bin
,etc
,sbin
,lib
}/
211 copy_binaries
"${TEMP}/initramfs-multipath-temp" /sbin
/{multipath
,kpartx
,mpath_prio_
*,devmap_name
,dmsetup
} /lib64
/udev
/scsi_id
/bin
/mountpoint
213 if [ -x
/sbin
/multipath
]
215 cp /etc
/multipath.conf
"${TEMP}/initramfs-multipath-temp/etc/" || gen_die
'could not copy /etc/multipath.conf please check this'
217 # /etc/scsi_id.config does not exist in newer udevs
218 # copy it optionally.
219 if [ -x
/sbin
/scsi_id
-a
-f
/etc
/scsi_id.config
]
221 cp /etc
/scsi_id.config
"${TEMP}/initramfs-multipath-temp/etc/" || gen_die
'could not copy scsi_id.config'
223 cd "${TEMP}/initramfs-multipath-temp"
224 log_future_cpio_content
225 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
226 || gen_die
"compressing multipath cpio"
228 rm -r
"${TEMP}/initramfs-multipath-temp/"
232 if [ -d
"${TEMP}/initramfs-dmraid-temp" ]
234 rm -r
"${TEMP}/initramfs-dmraid-temp/"
236 print_info
1 'DMRAID: Adding support (compiling binaries)...'
238 mkdir
-p
"${TEMP}/initramfs-dmraid-temp/"
239 /bin
/tar -jxpf
"${DMRAID_BINCACHE}" -C
"${TEMP}/initramfs-dmraid-temp" ||
240 gen_die
"Could not extract dmraid binary cache!";
241 cd "${TEMP}/initramfs-dmraid-temp/"
242 RAID456
=`find . -type f -name raid456.ko`
243 if [ -n
"${RAID456}" ]
245 cd "${RAID456/raid456.ko/}"
246 ln -sf raid456.kp raid45.ko
247 cd "${TEMP}/initramfs-dmraid-temp/"
249 log_future_cpio_content
250 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
251 || gen_die
"compressing dmraid cpio"
253 rm -r
"${TEMP}/initramfs-dmraid-temp/"
257 if [ -d
"${TEMP}/initramfs-iscsi-temp" ]
259 rm -r
"${TEMP}/initramfs-iscsi-temp/"
261 print_info
1 'iSCSI: Adding support (compiling binaries)...'
264 mkdir
-p
"${TEMP}/initramfs-iscsi-temp/bin/"
265 /bin
/bzip2 -dc "${ISCSI_BINCACHE}" > "${TEMP}/initramfs-iscsi-temp/bin/iscsistart" ||
266 gen_die
"Could not extract iscsi binary cache!"
267 chmod a
+x
"${TEMP}/initramfs-iscsi-temp/bin/iscsistart"
268 cd "${TEMP}/initramfs-iscsi-temp/"
269 log_future_cpio_content
270 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
271 || gen_die
"compressing iscsi cpio"
273 rm -rf
"${TEMP}/initramfs-iscsi-temp" > /dev
/null
277 if [ -d
"${TEMP}/initramfs-lvm-temp" ]
279 rm -r
"${TEMP}/initramfs-lvm-temp/"
282 mkdir
-p
"${TEMP}/initramfs-lvm-temp/bin/"
283 mkdir
-p
"${TEMP}/initramfs-lvm-temp/etc/lvm/"
284 if false
&& [ -e
'/sbin/lvm.static' ]
286 print_info
1 ' LVM: Adding support (using local static binary /sbin/lvm.static)...'
287 cp /sbin
/lvm.static
"${TEMP}/initramfs-lvm-temp/bin/lvm" ||
288 gen_die
'Could not copy over lvm!'
290 if [ -e
'/sbin/dmsetup.static' ]
292 cp /sbin
/dmsetup.static
"${TEMP}/initramfs-lvm-temp/bin/dmsetup"
294 elif false
&& [ -e
'/sbin/lvm' ] && LC_ALL
="C" ldd
/sbin
/lvm|
grep -q
'not a dynamic executable'
296 print_info
1 ' LVM: Adding support (using local static binary /sbin/lvm)...'
297 cp /sbin
/lvm
"${TEMP}/initramfs-lvm-temp/bin/lvm" ||
298 gen_die
'Could not copy over lvm!'
300 if [ -e
'/sbin/dmsetup' ] && LC_ALL
="C" ldd
/sbin
/dmsetup |
grep -q
'not a dynamic executable'
302 cp /sbin
/dmsetup
"${TEMP}/initramfs-lvm-temp/bin/dmsetup"
305 print_info
1 ' LVM: Adding support (compiling binaries)...'
307 /bin
/tar -jxpf
"${LVM_BINCACHE}" -C
"${TEMP}/initramfs-lvm-temp" ||
308 gen_die
"Could not extract lvm binary cache!";
309 mv ${TEMP}/initramfs
-lvm
-temp
/sbin
/lvm.static
${TEMP}/initramfs
-lvm
-temp
/bin
/lvm ||
310 gen_die
'LVM error: Could not move lvm.static to lvm!'
312 mv ${TEMP}/initramfs
-lvm
-temp
/sbin
/dmsetup.static
${TEMP}/initramfs
-lvm
-temp
/bin
/dmsetup ||
313 gen_die
'LVM error: Could not move dmsetup.static to dmsetup!'
314 rm -rf
${TEMP}/initramfs
-lvm
-temp
/{lib
,share
,man
,include
,sbin
/{lvm
,dmsetup
}}
316 if [ -x
/sbin
/lvm
-o
-x
/bin
/lvm
]
318 # lvm dumpconfig 2>&1 > /dev/null || gen_die 'Could not copy over lvm.conf!'
322 cp /etc
/lvm
/lvm.conf
"${TEMP}/initramfs-lvm-temp/etc/lvm/" ||
323 gen_die
'Could not copy over lvm.conf!'
325 # gen_die 'Could not copy over lvm.conf!'
328 cd "${TEMP}/initramfs-lvm-temp/"
329 log_future_cpio_content
330 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
331 || gen_die
"compressing lvm cpio"
333 rm -r
"${TEMP}/initramfs-lvm-temp/"
337 if [ -d
"${TEMP}/initramfs-mdadm-temp" ]
339 rm -r
"${TEMP}/initramfs-mdadm-temp/"
342 mkdir
-p
"${TEMP}/initramfs-mdadm-temp/etc/"
343 mkdir
-p
"${TEMP}/initramfs-mdadm-temp/sbin/"
344 if [ "${MDADM}" = '1' ]
346 if [ -n
"${MDADM_CONFIG}" ]
348 if [ -f
"${MDADM_CONFIG}" ]
350 cp -a
"${MDADM_CONFIG}" "${TEMP}/initramfs-mdadm-temp/etc/mdadm.conf" \
351 || gen_die
"Could not copy mdadm.conf!"
353 gen_die
'sl${MDADM_CONFIG} does not exist!'
356 print_info
1 ' MDADM: Skipping inclusion of mdadm.conf'
359 if [ -e
'/sbin/mdadm' ] && LC_ALL
="C" ldd
/sbin
/mdadm |
grep -q
'not a dynamic executable' \
360 && [ -e
'/sbin/mdmon' ] && LC_ALL
="C" ldd
/sbin
/mdmon |
grep -q
'not a dynamic executable'
362 print_info
1 ' MDADM: Adding support (using local static binaries /sbin/mdadm and /sbin/mdmon)...'
363 cp /sbin
/mdadm
/sbin
/mdmon
"${TEMP}/initramfs-mdadm-temp/sbin/" ||
364 gen_die
'Could not copy over mdadm!'
366 print_info
1 ' MDADM: Adding support (compiling binaries)...'
368 /bin
/tar -jxpf
"${MDADM_BINCACHE}" -C
"${TEMP}/initramfs-mdadm-temp" ||
369 gen_die
"Could not extract mdadm binary cache!";
372 cd "${TEMP}/initramfs-mdadm-temp/"
373 log_future_cpio_content
374 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
375 || gen_die
"compressing mdadm cpio"
377 rm -rf
"${TEMP}/initramfs-mdadm-temp" > /dev
/null
381 if [ -d
"${TEMP}/initramfs-zfs-temp" ]
383 rm -r
"${TEMP}/initramfs-zfs-temp"
386 mkdir
-p
"${TEMP}/initramfs-zfs-temp/etc/zfs/"
388 # Copy files to /etc/zfs
389 for i
in /etc
/zfs
/{zdev.conf
,zpool.cache
}
391 cp -a
"${i}" "${TEMP}/initramfs-zfs-temp/etc/zfs" \
392 || gen_die
"Could not copy file ${i} for ZFS"
396 copy_binaries
"${TEMP}/initramfs-zfs-temp" /sbin
/{mount.zfs
,zfs
,zpool
}
398 cd "${TEMP}/initramfs-zfs-temp/"
399 log_future_cpio_content
400 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
401 || gen_die
"compressing zfs cpio"
403 rm -rf
"${TEMP}/initramfs-zfs-temp" > /dev
/null
407 splash_geninitramfs
=`which splash_geninitramfs 2>/dev/null`
408 if [ -x
"${splash_geninitramfs}" ]
410 [ -z
"${SPLASH_THEME}" ] && [ -e
/etc
/conf.d
/splash
] && source /etc
/conf.d
/splash
411 [ -z
"${SPLASH_THEME}" ] && SPLASH_THEME
=default
412 print_info
1 " >> Installing splash [ using the ${SPLASH_THEME} theme ]..."
413 if [ -d
"${TEMP}/initramfs-splash-temp" ]
415 rm -r
"${TEMP}/initramfs-splash-temp/"
417 mkdir
-p
"${TEMP}/initramfs-splash-temp"
420 [ -n
"${SPLASH_RES}" ] && tmp
="-r ${SPLASH_RES}"
421 splash_geninitramfs
-c
"${TEMP}/initramfs-splash-temp" ${tmp} ${SPLASH_THEME} || gen_die
"Could not build splash cpio archive"
422 if [ -e
"/usr/share/splashutils/initrd.splash" ]; then
423 mkdir
-p
"${TEMP}/initramfs-splash-temp/etc"
424 cp -f
"/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-splash-temp/etc"
426 cd "${TEMP}/initramfs-splash-temp/"
427 log_future_cpio_content
428 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
429 || gen_die
"compressing splash cpio"
431 rm -r
"${TEMP}/initramfs-splash-temp/"
433 print_warning
1 ' >> No splash detected; skipping!'
438 cd ${INITRAMFS_OVERLAY}
439 log_future_cpio_content
440 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
441 || gen_die
"compressing overlay cpio"
445 local _luks_error_format
="LUKS support cannot be included: %s. Please emerge sys-fs/cryptsetup[static]."
446 local _luks_source
=/sbin
/cryptsetup
447 local _luks_dest
=/sbin
/cryptsetup
449 if [ -d
"${TEMP}/initramfs-luks-temp" ]
451 rm -r
"${TEMP}/initramfs-luks-temp/"
454 mkdir
-p
"${TEMP}/initramfs-luks-temp/lib/luks/"
455 mkdir
-p
"${TEMP}/initramfs-luks-temp/sbin"
456 cd "${TEMP}/initramfs-luks-temp"
460 [ -x
"${_luks_source}" ] \
461 || gen_die
"$(printf "${_luks_error_format}" "no
file ${_luks_source}")"
463 print_info
1 "Including LUKS support"
464 copy_binaries
"${TEMP}/initramfs-luks-temp/" /sbin
/cryptsetup
467 log_future_cpio_content
468 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
469 || gen_die
"appending cryptsetup to cpio"
472 rm -r
"${TEMP}/initramfs-luks-temp/"
476 if [ -z
"${FIRMWARE_FILES}" -a
! -d
"${FIRMWARE_DIR}" ]
478 gen_die
"specified firmware directory (${FIRMWARE_DIR}) does not exist"
480 if [ -d
"${TEMP}/initramfs-firmware-temp" ]
482 rm -r
"${TEMP}/initramfs-firmware-temp/"
484 mkdir
-p
"${TEMP}/initramfs-firmware-temp/lib/firmware"
485 cd "${TEMP}/initramfs-firmware-temp"
486 if [ -n
"${FIRMWARE_FILES}" ]
490 for i
in ${FIRMWARE_FILES}
492 cp -L
"${i}" ${TEMP}/initramfs
-firmware
-temp
/lib
/firmware
/
496 cp -a
"${FIRMWARE_DIR}"/* ${TEMP}/initramfs
-firmware
-temp
/lib
/firmware
/
498 log_future_cpio_content
499 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
500 || gen_die
"appending firmware to cpio"
502 rm -r
"${TEMP}/initramfs-firmware-temp/"
506 if [ -d
"${TEMP}/initramfs-gpg-temp" ]
508 rm -r
"${TEMP}/initramfs-gpg-temp"
511 mkdir
-p
"${TEMP}/initramfs-gpg-temp/sbin/"
512 if [ ! -e
${GPG_BINCACHE} ] ; then
513 print_info
1 ' GPG: Adding support (compiling binaries)...'
516 bzip2 -dc "${GPG_BINCACHE}" > "${TEMP}/initramfs-gpg-temp/sbin/gpg" ||
517 gen_die
'Could not extract gpg binary cache!'
518 chmod a
+x
"${TEMP}/initramfs-gpg-temp/sbin/gpg"
519 cd "${TEMP}/initramfs-gpg-temp/"
520 log_future_cpio_content
521 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}"
522 rm -rf
"${TEMP}/initramfs-gpg-temp" > /dev
/null
539 print_info
2 "initramfs: >> Searching for modules..."
540 if [ "${INSTALL_MOD_PATH}" != '' ]
542 cd ${INSTALL_MOD_PATH}
547 if [ -d
"${TEMP}/initramfs-modules-${KV}-temp" ]
549 rm -r
"${TEMP}/initramfs-modules-${KV}-temp/"
551 mkdir
-p
"${TEMP}/initramfs-modules-${KV}-temp/lib/modules/${KV}"
552 for i
in `gen_dep_list`
554 mymod
=`find ./lib/modules/${KV} -name "${i}${MOD_EXT}" 2>/dev/null| head -n 1 `
557 print_warning
2 "Warning :: ${i}${MOD_EXT} not found; skipping..."
561 print_info
2 "initramfs: >> Copying ${i}${MOD_EXT}..."
562 cp -ax
--parents
"${mymod}" "${TEMP}/initramfs-modules-${KV}-temp"
565 cp -ax
--parents .
/lib
/modules
/${KV}/modules
* ${TEMP}/initramfs
-modules
-${KV}-temp
2>/dev
/null
567 mkdir
-p
"${TEMP}/initramfs-modules-${KV}-temp/etc/modules"
568 for group_modules
in ${!MODULES_*}; do
569 group
="$(echo $group_modules | cut -d_ -f2 | tr "[:upper
:]" "[:lower
:]")"
570 print_list
${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}"
572 cd "${TEMP}/initramfs-modules-${KV}-temp/"
573 log_future_cpio_content
574 find . |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
575 || gen_die
"compressing modules cpio"
577 rm -r
"${TEMP}/initramfs-modules-${KV}-temp/"
580 # check for static linked file with objdump
582 LANG
="C" LC_ALL
="C" objdump
-T
$1 2>&1 |
grep "not a dynamic object" > /dev
/null
587 if [ -d
"${TEMP}/initramfs-aux-temp" ]
589 rm -r
"${TEMP}/initramfs-aux-temp/"
591 mkdir
-p
"${TEMP}/initramfs-aux-temp/etc"
592 mkdir
-p
"${TEMP}/initramfs-aux-temp/sbin"
593 if [ -f
"${CMD_LINUXRC}" ]
595 cp "${CMD_LINUXRC}" "${TEMP}/initramfs-aux-temp/init"
596 print_info
2 " >> Copying user specified linuxrc: ${CMD_LINUXRC} to init"
600 cp "${GK_SHARE}/netboot/linuxrc.x" "${TEMP}/initramfs-aux-temp/init"
602 if [ -f
"${GK_SHARE}/arch/${ARCH}/linuxrc" ]
604 cp "${GK_SHARE}/arch/${ARCH}/linuxrc" "${TEMP}/initramfs-aux-temp/init"
606 cp "${GK_SHARE}/defaults/linuxrc" "${TEMP}/initramfs-aux-temp/init"
611 # Make sure it's executable
612 chmod 0755 "${TEMP}/initramfs-aux-temp/init"
614 # Make a symlink to init .. incase we are bundled inside the kernel as one
616 cd ${TEMP}/initramfs
-aux
-temp
618 # ln ${TEMP}/initramfs-aux-temp/init ${TEMP}/initramfs-aux-temp/linuxrc
620 if [ -f
"${GK_SHARE}/arch/${ARCH}/initrd.scripts" ]
622 cp "${GK_SHARE}/arch/${ARCH}/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
624 cp "${GK_SHARE}/defaults/initrd.scripts" "${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
627 if [ -f
"${GK_SHARE}/arch/${ARCH}/initrd.defaults" ]
629 cp "${GK_SHARE}/arch/${ARCH}/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
631 cp "${GK_SHARE}/defaults/initrd.defaults" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
634 if [ -n
"${REAL_ROOT}" ]
636 sed -i
"s:^REAL_ROOT=.*$:REAL_ROOT='${REAL_ROOT}':" "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
639 echo -n
'HWOPTS="$HWOPTS ' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
640 for group_modules
in ${!MODULES_*}; do
641 group
="$(echo $group_modules | cut -d_ -f2 | tr "[:upper
:]" "[:lower
:]")"
642 echo -n
"${group} " >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
644 echo '"' >> "${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
646 if [ -f
"${GK_SHARE}/arch/${ARCH}/modprobe" ]
648 cp "${GK_SHARE}/arch/${ARCH}/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
650 cp "${GK_SHARE}/defaults/modprobe" "${TEMP}/initramfs-aux-temp/sbin/modprobe"
652 if isTrue
$CMD_DOKEYMAPAUTO
654 echo 'MY_HWOPTS="${MY_HWOPTS} keymap"' >> ${TEMP}/initramfs
-aux
-temp
/etc
/initrd.defaults
656 if isTrue
$CMD_KEYMAP
658 print_info
1 " >> Copying keymaps"
659 mkdir
-p
"${TEMP}/initramfs-aux-temp/lib/"
660 cp -R
"${GK_SHARE}/defaults/keymaps" "${TEMP}/initramfs-aux-temp/lib/" \
661 || gen_die
"Error while copying keymaps"
664 cd ${TEMP}/initramfs
-aux
-temp
/sbin
&& ln -s ..
/init init
666 chmod +x
"${TEMP}/initramfs-aux-temp/init"
667 chmod +x
"${TEMP}/initramfs-aux-temp/etc/initrd.scripts"
668 chmod +x
"${TEMP}/initramfs-aux-temp/etc/initrd.defaults"
669 chmod +x
"${TEMP}/initramfs-aux-temp/sbin/modprobe"
673 cd "${GK_SHARE}/netboot/misc"
674 cp -pPRf
* "${TEMP}/initramfs-aux-temp/"
677 cd "${TEMP}/initramfs-aux-temp/"
678 log_future_cpio_content
679 find .
-print |
cpio ${CPIO_ARGS} --append
-F
"${CPIO}" \
680 || gen_die
"compressing auxilary cpio"
682 rm -r
"${TEMP}/initramfs-aux-temp/"
687 local func
="append_${name}"
689 [ $# -eq
0 ] && gen_die
"append_data() called with zero arguments"
690 if [ $# -eq
1 ] || isTrue
${var}
692 print_info
1 " >> Appending ${name} cpio data..."
693 ${func} || gen_die
"${func}() failed"
698 local compress_ext
=""
699 print_info
1 "initramfs: >> Initializing..."
702 CPIO
="${TMPDIR}/initramfs-${KV}"
703 echo |
cpio ${CPIO_ARGS} -F
"${CPIO}" 2>/dev
/null \
704 || gen_die
"Could not create empty cpio at ${CPIO}"
706 append_data
'base_layout'
707 append_data
'auxilary' "${BUSYBOX}"
708 append_data
'busybox' "${BUSYBOX}"
709 append_data
'lvm' "${LVM}"
710 append_data
'dmraid' "${DMRAID}"
711 append_data
'iscsi' "${ISCSI}"
712 append_data
'mdadm' "${MDADM}"
713 append_data
'luks' "${LUKS}"
714 append_data
'multipath' "${MULTIPATH}"
715 append_data
'gpg' "${GPG}"
717 if [ "${RAMDISKMODULES}" = '1' ]
719 append_data
'modules'
721 print_info
1 "initramfs: Not copying modules..."
724 append_data
'zfs' "${ZFS}"
726 append_data
'blkid' "${DISKLABEL}"
728 append_data
'unionfs_fuse' "${UNIONFS}"
730 append_data
'splash' "${SPLASH}"
732 if isTrue
"${FIRMWARE}" && [ -n
"${FIRMWARE_DIR}" ]
734 append_data
'firmware'
737 # This should always be appended last
738 if [ "${INITRAMFS_OVERLAY}" != '' ]
740 append_data
'overlay'
743 if isTrue
"${INTEGRATED_INITRAMFS}"
745 # Explicitly do not compress if we are integrating into the kernel.
746 # The kernel will do a better job of it than us.
747 mv ${TMPDIR}/initramfs
-${KV} ${TMPDIR}/initramfs
-${KV}.
cpio
748 sed -i
'/^.*CONFIG_INITRAMFS_SOURCE=.*$/d' ${KERNEL_DIR}/.config
749 cat >>${KERNEL_DIR}/.config
<<-EOF
750 CONFIG_INITRAMFS_SOURCE
="${TMPDIR}/initramfs-${KV}.cpio${compress_ext}"
751 CONFIG_INITRAMFS_ROOT_UID
=0
752 CONFIG_INITRAMFS_ROOT_GID
=0
755 if isTrue
"${COMPRESS_INITRD}"
758 cmd_lzma
=$
(type -p lzma
)
759 cmd_bzip2
=$
(type -p
bzip2)
760 cmd_gzip
=$
(type -p
gzip)
761 cmd_lzop
=$
(type -p lzop
)
762 pkg_xz
='app-arch/xz-utils'
763 pkg_lzma
='app-arch/xz-utils'
764 pkg_bzip2
='app-arch/bzip2'
765 pkg_gzip
='app-arch/gzip'
766 pkg_lzop
='app-arch/lzop'
768 case ${COMPRESS_INITRD_TYPE} in
769 xz|lzma|
bzip2|
gzip|lzop
) compression
=${COMPRESS_INITRD_TYPE} ;;
770 lzo
) compression
=lzop
;;
773 'CONFIG_RD_XZ cmd_xz xz' \
774 'CONFIG_RD_LZMA cmd_lzma lzma' \
775 'CONFIG_RD_BZIP2 cmd_bzip2 bzip' \
776 'CONFIG_RD_GZIP cmd_gzip gzip' \
777 'CONFIG_RD_LZO cmd_lzop lzop'; do
781 if grep -sq "^${kernel_option}=y" ${KERNEL_DIR}/.config
&& test -n
"${!cmd_variable_name}" ; then
783 [[ ${COMPRESS_INITRD_TYPE} == best
]] && break
788 gen_die
"Compression '${COMPRESS_INITRD_TYPE}' unknown"
792 # Check for actual availability
793 cmd_variable_name
=cmd_
${compression}
794 pkg_variable_name
=pkg_
${compression}
795 [[ -z
"${!cmd_variable_name}" ]] && gen_die
"Compression '${compression}' is not available. Please install package '${!pkg_variable_name}'."
798 xz
) compress_ext
='.xz' compress_cmd
="${cmd_xz} -e --check=none -z -f -9" ;;
799 lzma
) compress_ext
='.lzma' compress_cmd
="${cmd_lzma} -z -f -9" ;;
800 bzip2) compress_ext
='.bz2' compress_cmd
="${cmd_bzip2} -z -f -9" ;;
801 gzip) compress_ext
='.gz' compress_cmd
="${cmd_gzip} -f -9" ;;
802 lzop
) compress_ext
='.lzo' compress_cmd
="${cmd_lzop} -f -9" ;;
805 if [ -n
"${compression}" ]; then
806 print_info
1 " >> Compressing cpio data (${compress_ext})..."
807 ${compress_cmd} "${CPIO}" || gen_die
"Compression (${compress_cmd}) failed"
808 mv -f
"${CPIO}${compress_ext}" "${CPIO}" || gen_die
"Rename failed"
810 print_info
1 " >> Not compressing cpio data ..."
815 if isTrue
"${CMD_INSTALL}"
817 if ! isTrue
"${INTEGRATED_INITRAMFS}"
819 copy_image_with_preserve
"initramfs" \
820 "${TMPDIR}/initramfs-${KV}" \
821 "initramfs-${KNAME}-${ARCH}-${KV}"