summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ide-auto10
-rw-r--r--init10
-rw-r--r--mkinitcpio85
3 files changed, 77 insertions, 28 deletions
diff --git a/ide-auto b/ide-auto
index ce415af..eb728b1 100644
--- a/ide-auto
+++ b/ide-auto
@@ -15,16 +15,16 @@ run_hook ()
{
if [ -e /proc/ide ]; then
msg -n "Loading ide modules..."
- /bin/modprobe -q ide-generic 2>&1 >/dev/null
+ /bin/modprobe -q ide-generic >/dev/null 2>&1
for d in /proc/ide/*; do
unit=${d#/proc/ide/}
if [ -e "${d}/media" -a ! -d "/sys/block/${unit}" ]; then
read m < "${d}/media"
case "${m}" in
- disk) /bin/modprobe -q ide-disk 2>&1 >/dev/null ;;
- cdrom) /bin/modprobe -q ide-cd 2>&1 >/dev/null ;;
- tape) /bin/modprobe -q ide-tape 2>&1 >/dev/null ;;
- floppy) /bin/modprobe -q ide-floppy 2>&1 >/dev/null ;;
+ disk) /bin/modprobe -q ide-disk >/dev/null 2>&1;;
+ cdrom) /bin/modprobe -q ide-cd >/dev/null 2>&1;;
+ tape) /bin/modprobe -q ide-tape >/dev/null 2>&1;;
+ floppy) /bin/modprobe -q ide-floppy >/dev/null 2>&1;;
esac
fi
done
diff --git a/init b/init
index ca5c459..72452c1 100644
--- a/init
+++ b/init
@@ -17,6 +17,7 @@ for cmd in $CMDLINE; do
esac
done
+#this should be part of the 'base' hook
msg -n "Loading pci modules..."
/bin/modprobe -a -q $(/bin/cat /sys/bus/pci/devices/*/modalias) >/dev/null 2>&1 &
msg "done."
@@ -38,9 +39,11 @@ if [ -e "/hooks" ]; then
eval "TST=\$${h}"
if [ "${TST}" != "disabled" ]; then
run_hook () { msg "$h: no run function defined"; }
- . $h
- msg ":: Running Hook [${h##*/}]"
- run_hook
+ if [ -e "/hooks/$h" ]; then
+ . $h
+ msg ":: Running Hook [${h}]"
+ run_hook
+ fi
fi
done
fi
@@ -71,4 +74,5 @@ if [ "${break}" = "y" ]; then
fi
# Optimize fs type loop for mounting rootfs
+msg ":: End Initramfs - control passing to kinit"
exec /bin/kinit rootfstype=${FSTYPE} $CMDLINE < /dev/console > /dev/console
diff --git a/mkinitcpio b/mkinitcpio
index 50d3647..09adc25 100644
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -11,25 +11,35 @@
# incase of embedded spaces, quote all path names and string comaprissons
#
# TODO
-# sudo cp img /boot
-HOOKDIR="hooks"
# Settings
BASEDIR=""
KERNELVERSION="$(uname -r)"
CONFIG="mkinitcpio.conf"
+HOOKDIR="hooks"
SAVELIST=""
GENIMG=""
APPEND=""
+QUIET="n"
+
+APPNAME=$(basename "${0}")
usage ()
{
- echo "TODO usage..."
+ echo "${APPNAME}: usage"
+ echo " -c CONFIG Use CONFIG file. default: /etc/mkinitcpio.conf"
+ echo " -k KERNELVERSION Use KERNELVERSION. default: $(uname -r)"
+ echo " -s Save filelist. default: no"
+ echo " -b BASEDIR Use BASEDIR. default: /"
+ echo " -g IMAGE Generate a cpio image as IMAGE. default: no"
+ echo " -a Append to an existing filelist. default: no"
+ echo " -q Quiet output. Default: no"
+ echo " -h This message."
exit 1
}
-while getopts 'c:k:sb:g:a' arg; do
+while getopts 'c:k:sb:g:aqh' arg; do
case "$arg" in
c) CONFIG="$OPTARG" ;;
k) KERNELVERSION="$OPTARG" ;;
@@ -37,7 +47,8 @@ while getopts 'c:k:sb:g:a' arg; do
b) BASEDIR="$OPTARG" ;;
g) GENIMG="$OPTARG" ;;
a) APPEND="y" ;;
- ?) usage ;;
+ q) QUIET="y" ;;
+ h|?) usage ;;
*) echo "invalid argument '$arg'"; usage ;;
esac
done
@@ -77,7 +88,7 @@ else
touch "${FILELIST}"
fi
-# this function is a helper for the *-auto install functions
+# Helper functions, just to make syntax clearer
auto_modules ()
{
aliases=$(find /sys/devices/ -name modalias -exec cat {} \;)
@@ -85,33 +96,60 @@ auto_modules ()
sed "s|insmod \(.*\)|\1|" | sort -u
}
+all_modules ()
+{
+ find ${MODULEDIR} -name *.ko 2>/dev/null | sort -u
+}
+
+msg() { [ "${QUIET}" = "n" ] && echo "${@}"; }
+err() { [ echo "ERROR: ${@}" >2; }
+
add_dir()
{
local dir
- dir="${1}"
+ dir="$(dirname ${1})"
if [ "x${dir}" != "x" -a "${dir}" != "/" ]; then
dir="${dir}" #this got stripped off above... put it back
if ! grep "dir ${dir} " "${FILELIST}" 2>&1 > /dev/null; then
- add_dir $(dirname ${dir})
- echo " adding dir ${dir}"
+ add_dir "${dir}"
+ msg " adding dir ${dir}"
echo "dir ${dir} 755 0 0" >> "${FILELIST}"
fi
fi
}
+# add_devnode /dev/foo type major minor [permissions]
+add_devnode()
+{
+ if [ $# -ge 4 ]; then
+ local perms
+ perms="${5:-644}"
+ add_dir "${1}"
+ if ! grep "nod ${1}" "${FILELIST}" 2>&1 > /dev/null; then
+ msg " adding device node ${1}"
+ echo "nod ${1} ${perms} 0 0 ${2} ${3} ${4}" >> "${FILELIST}"
+ fi
+ else
+ err "invalid device node format: $@" >2
+ return 1
+ fi
+}
+
add_symlink ()
{
local fil dest dir
if [ -L ${1} ]; then
fil="${1}"
dest="${fil##$BASEDIR}"
- dir=$(dirname "${dest}")
- add_dir "${dir}"
+ add_dir "${dest}"
if ! grep "slink ${fil} " "${FILELIST}" 2>&1 > /dev/null; then
- echo " adding symlink ${dest}"
+ msg " adding symlink ${dest}"
echo "slink ${dest} ${fil} $(stat -c '%a %u %g' ${fil})" >> "${FILELIST}"
fi
+ else
+ err "ERROR: file '${1}' is not a symlink" >2
+ return 1
fi
}
@@ -131,13 +169,15 @@ add_file ()
dest="${fil##$BASEDIR}"
fi
- dir=$(dirname "${dest}")
- add_dir "${dir}"
+ add_dir "${dest}"
if ! grep "file ${fil} " "${FILELIST}" 2>&1 > /dev/null; then
- echo " adding file ${dest}"
+ msg " adding file ${dest}"
echo "file ${dest} ${fil} $(stat -c '%a %u %g' ${fil})" >> "${FILELIST}"
fi
+ else
+ err "file '${1}' does not exist" >2
+ return 1
fi
}
@@ -168,7 +208,7 @@ add_binary()
fi
if [ ! -f "${bin}" ]; then
- echo "add_binary: '${bin}' is not a file"
+ err "'${bin}' is not a file" >2
return 1
fi
@@ -193,7 +233,7 @@ add_binary()
done
;;
*)
- echo "add_binary: unknown type '${type}' for binary '${bin}'"
+ err "unknown type '${type}' for binary '${bin}'" >2
return 1
;;
esac
@@ -229,12 +269,13 @@ for hook in $HOOKS; do
unset MODULES
unset BINARIES
unset FILES
- install () { msg "$hook: no install function..."; }
+ install () { msg "${hook}: no install function..."; }
source "${HOOKDIR}/${hook}"
install
parse_hook
#quick test to check for existance... need a better way...
- if grep "run_hook" "${HOOKDIR}/${hook}" 2>&1>/dev/null; then
+ # note, this will only pick up valid run_hooks - a space is required
+ if grep "run_hook ()" "${HOOKDIR}/${hook}" 2>&1>/dev/null; then
add_file "${HOOKDIR}/${hook}" "/hooks/${hook}"
fi
done
@@ -246,8 +287,12 @@ if [ "${HAS_MODULES}" == "y" ]; then
fi
if [ "x$GENIMG" != "x" ]; then
- gen_init_cpio ${FILELIST} | gzip -9 > "${GENIMG}"
+ if ! gen_init_cpio ${FILELIST} | gzip -9 > "${GENIMG}"; then
+ err "ERROR: Failed to create '${GENIMG}' image" >2
+ fi
+
if [ "x${SAVELIST}" == "x" ]; then
rm ${FILELIST}
fi
fi
+#vim:set ft=sh ts=4 sw=4 noet: