#!/bin/sh VERSION=1.0 _cp() { local i if [ -n "$list_sources" ]; then for i in "$@"; do echo $i done return fi for i in "$@"; do local dest="$tmpdir"/${i%/*} mkdir -p "$dest" cp -flLpR "$i" "$dest" 2>/dev/null || cp -pR "$i" "$dest" done } feature_files() { local dir="$1" local glob file for f in $features; do if [ ! -f "$dir/$f" ]; then continue fi for glob in $(cat "$dir/$f"); do for file in $glob; do echo $glob done done done } initfs_base() { local i= dirs= glob= file= echo "==> initramfs: copying base files" >&2 for i in dev proc sys sbin bin .modloop lib/modules media/cdrom \ media/floppy media/usb newroot; do dirs="$dirs $tmpdir/$i" done [ -z "$list_sources" ] && mkdir -p $dirs for file in $(feature_files "$filelists_dir"); do _cp $file done # copy init if [ -z "$list_sources" ]; then cd $startdir install -m755 "$init" "$tmpdir"/init else echo "$init" fi } find_kmod_deps() { awk ' function recursedeps(k, j) { if (k in visited) return; visited[k] = 1; split(deps[k], dep, " "); for (j in dep) recursedeps(dep[j]); print(k); } BEGIN { if (modulesdep == "") modulesdep="modules.dep"; FS = ": "; while ( (getline < modulesdep) > 0) { deps[$1] = $2; } } { mod["/"$0] = 1; } END { for (i in mod) recursedeps(i); }' -v modulesdep="$basedir/lib/modules/$kernel/modules.dep" } initfs_kmods() { local glob= file= files= dirs= [ -z "$list_soruces" ] && rm -rf "$tmpdir"/lib/modules cd "$kerneldir" || return 1 echo "==> initramfs: copying kernel $kernel modules" >&2 files=$( for file in $(feature_files $modulelists_dir); do if ! [ -e ${file} ]; then echo "$file: No such file or directory" >&2 continue fi echo $file done | find_kmod_deps) for file in $files; do _cp "$basedir"/lib/modules/$kernel/$file done } initfs_cpio() { [ -n "$list_sources" ] && return echo "==> initramfs: creating $outfile" >&2 (cd "$tmpdir" && find . | cpio -o -H newc | gzip) > $outfile } usage() { cat <