3 # Copyright (C) Michal Sojka <sojkam1@fel.cvut.cz>
5 # Includes pieces from gen_initramfs_list.sh:
7 # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
8 # Copyright (C) 2006 Sam Ravnborg <sam@ravnborg.org>
10 # Released under the terms of the GNU GPL
12 # Usage: gen_cpio rootfs.cpio myapp->/bin/ start.sh->/etc/init.d/S90startmyapp
13 # gen_cpio --mkimage="-T ramdisk -A powerpc -O linux" ...
17 while [ $# -gt 0 ]; do
19 --mkimage=*) mkimage=${1#--mkimage=};;
25 if [ -n "$mkimage" ]; then
30 gen_cpio_from_list() {
31 [ "$cpio_list" ] || return 0
32 echo "$cpio_list" | LANG=C sort -u | gen_init_cpio -
39 # symlink test must come before file test
40 if [ -L "${argv1}" ]; then
42 elif [ -f "${argv1}" ]; then
44 elif [ -d "${argv1}" ]; then
46 elif [ -b "${argv1}" -o -c "${argv1}" ]; then
48 elif [ -p "${argv1}" ]; then
50 elif [ -S "${argv1}" ]; then
58 ends_with() { [ x"${1}" != x"${1#$2}" ]; }
64 if ends_with "$dst" "/"; then
65 dst="$dst$(basename $src)"
67 local dir=$(dirname $dst)
68 while [ -n "$dir" -a "$dir" != "." -a "$dir" != "/" ]; do
69 echo "dir $dir 0755 0 0"
72 echo "$(filetype $src) $dst $src $(find $src -printf '%m') 0 0"
75 while [ $# -gt 0 ]; do
78 if [ -f "$arg" ]; then
79 case "$(file $arg)" in
85 echo >&2 "Unsuported file format: $arg"
94 cpio_list="$cpio_list$(gen_list $src $dst)"
97 echo >&2 "No file: $arg"
105 if [ -n "$mkimage" ]; then
108 mkimage $mkimage -d $tmp $tmp2 >&2