aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@nosferatu.za.org>2004-10-19 18:23:20 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-10-19 18:23:20 -0700
commit187ada2d0b0a75e5e3533dbfdbd0f5497d978b02 (patch)
treeec81c85afd9bfb2ff5ace21892abba940693ee30 /scripts
parent6fa95f2bbf236668a7a0c6305dcda20da5dafbb9 (diff)
downloadhistory-187ada2d0b0a75e5e3533dbfdbd0f5497d978b02.tar.gz
[PATCH] Select cpio_list or source directory for initramfs image
Attached is a patch that adds CONFIG_INITRAMFS_SOURCE, enabling you to either specify a file as cpio_list, or a directory to generate a list from. It depreciate the INITRAMFS_LIST environment variable introduced not long ago. There are some issues (suggestions/patches welcome) that I am not sure about: 1) I put the menu entry under block devices, but I am not sure if this is the correct location? 2) There might be a better (or more correct) way to do this with kbuild? 3) Variable names and especially help text needs some love. 4) I am not sure if I am duplicating work in progress? Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen_initramfs_list.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
new file mode 100644
index 00000000000000..59b810396c7b89
--- /dev/null
+++ b/scripts/gen_initramfs_list.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org>
+# Released under the terms of the GNU GPL
+#
+# A script to generate newline separated entries (to stdout) from a directory's
+# contents suitable for use as a cpio_list for gen_init_cpio.
+#
+# Arguements: $1 -- the source directory
+#
+# TODO: Add support for symlinks, sockets and pipes when gen_init_cpio
+# supports them.
+
+usage() {
+ echo "Usage: $0 initramfs-source-dir"
+ exit 1
+}
+
+srcdir=$(echo "$1" | sed -e 's://*:/:g')
+
+if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then
+ usage
+fi
+
+filetype() {
+ local argv1="$1"
+
+ if [ -f "${argv1}" ]; then
+ echo "file"
+ elif [ -d "${argv1}" ]; then
+ echo "dir"
+ elif [ -b "${argv1}" -o -c "${argv1}" ]; then
+ echo "nod"
+ else
+ echo "invalid"
+ fi
+ return 0
+}
+
+parse() {
+ local location="$1"
+ local name="${location/${srcdir}//}"
+ local mode="$2"
+ local uid="$3"
+ local gid="$4"
+ local ftype=$(filetype "${location}")
+ local str="${mode} ${uid} ${gid}"
+
+ [ "${ftype}" == "invalid" ] && return 0
+ [ "${location}" == "${srcdir}" ] && return 0
+
+ case "${ftype}" in
+ "file")
+ str="${ftype} ${name} ${location} ${str}"
+ ;;
+ "nod")
+ local dev_type=
+ local maj=$(LC_ALL=C ls -l "${location}" | \
+ gawk '{sub(/,/, "", $5); print $5}')
+ local min=$(LC_ALL=C ls -l "${location}" | \
+ gawk '{print $6}')
+
+ if [ -b "${location}" ]; then
+ dev_type="b"
+ else
+ dev_type="c"
+ fi
+ str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}"
+ ;;
+ *)
+ str="${ftype} ${name} ${str}"
+ ;;
+ esac
+
+ echo "${str}"
+
+ return 0
+}
+
+find "${srcdir}" -printf "%p %m %U %G\n" | \
+while read x; do
+ parse ${x}
+done
+
+exit 0