2 # Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
3 # Released under the terms of the GNU GPL
5 # Generate a newline separated list of entries from the file/directory pointed
6 # out by the environment variable: CONFIG_INITRAMFS_SOURCE
8 # If CONFIG_INITRAMFS_SOURCE is non-existing then generate a small dummy file.
10 # The output is suitable for gen_init_cpio as found in usr/Makefile.
12 # TODO: Add support for symlinks, sockets and pipes when gen_init_cpio
17 # This is a very simple initramfs
20 nod /dev/console 0600 0 0 c 5 1
28 if [ -f "${argv1}" ]; then
30 elif [ -d "${argv1}" ]; then
32 elif [ -b "${argv1}" -o -c "${argv1}" ]; then
42 local name="${location/${srcdir}//}"
46 local ftype=$(filetype "${location}")
47 local str="${mode} ${uid} ${gid}"
49 [ "${ftype}" == "invalid" ] && return 0
50 [ "${location}" == "${srcdir}" ] && return 0
54 str="${ftype} ${name} ${location} ${str}"
58 local maj=$(LC_ALL=C ls -l "${location}" | \
59 gawk '{sub(/,/, "", $5); print $5}')
60 local min=$(LC_ALL=C ls -l "${location}" | \
63 if [ -b "${location}" ]; then
68 str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
71 str="${ftype} ${name} ${str}"
85 srcdir=$(echo "$1" | sed -e 's://*:/:g')
86 dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null)
88 # If $dirlist is only one line, then the directory is empty
89 if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then
95 # Failsafe in case directory is empty
99 echo " $0: Cannot open '$1' (CONFIG_INITRAMFS_SOURCE)" >&2