summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/example_hook_cpiogz84
-rwxr-xr-xhooks/kernelextras44
-rwxr-xr-xhooks/legacylvm28
-rwxr-xr-xhooks/udevhelper36
-rwxr-xr-xscripts/init-premount/blacklist25
-rwxr-xr-xscripts/init-premount/thermal37
-rwxr-xr-xscripts/init-top/framebuffer102
-rwxr-xr-xscripts/local-top/lvm74
8 files changed, 430 insertions, 0 deletions
diff --git a/docs/example_hook_cpiogz b/docs/example_hook_cpiogz
new file mode 100644
index 0000000..f3e44d9
--- /dev/null
+++ b/docs/example_hook_cpiogz
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+#
+# The environment contains at least:
+#
+# CONFDIR -- usually /etc/mkinitramfs, can be set on mkinitramfs
+# command line.
+#
+# DESTDIR -- The staging directory where we are building the image.
+#
+# TODO: Decide what environment variables are meaningful and defined
+# in this context, then document them as part of the interface.
+#
+# TODO: Write a common header for these examples or move this
+# documentation to a man page and reference it here. :-)
+#
+
+#
+# List the soft prerequisites here. This is a space separated list of
+# names, of scripts that are in the same directory as this one, that
+# must be run before this one can be.
+#
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+#
+# Source the 'hook-functions' scriptlet (for 'catenate_cpiogz'):
+#
+. /usr/share/initramfs-tools/hook-functions
+
+#
+# Lets pretend it has a conffile (think debconf), and we source it
+# here. Don't make debconf lookup calls here. The postinst for the
+# package owning this hook script should have done that and configured
+# the "/etc/default/conffile" already.
+#
+# TODO: How does the package ensure that it's installed BEFORE the
+# corresponding 'linux-image' package? Can it declare that, in
+# the case where it's an add-on that the 'linux-image' is not
+# aware of? This might be an apt and dpkg issue.
+#
+# * Eg. an optional usplash or suspend2ui_fbsplash package.
+#
+. /etc/default/mypackage-initramfs
+
+#
+# Also pretend that we only include our initramfs overlay if an opion
+# is not "no", and the 'linux-image' package we are generating this
+# initramfs for matches the version this script's package is designed
+# for. Just for example; pretend this example mkinitramfs hook script
+# is part of a 'linux-image' or 'xxx-modules' package.
+#
+if [ "$MYOPTION" != "no" -a "$version" = "2.6.12+ss2.1.9.1" ]; then
+ catenate_cpiogz /usr/lib/mypackage/initramfs.cpio.gz
+fi
+
+#
+# In this case, there does not have to be an (eg.):
+#
+# "/etc/mkinitramfs/init-top/mypackage"
+#
+# ... since that script is probably inside of the initramfs overlay
+# already. If it's a conffile though, it does not belong in there,
+# and should be placed in the appropriate location inside of
+# "/etc/mkinitramfs". Remember that if it needs access to the
+# settings in our "/etc/default/mypackage-initramfs", then that file
+# must also get copied into a location inside of ${DESTDIR} by this
+# hook script in order to make it available inside of the initramfs
+# environment.
+#
+
+exit 0
diff --git a/hooks/kernelextras b/hooks/kernelextras
new file mode 100755
index 0000000..714e9a9
--- /dev/null
+++ b/hooks/kernelextras
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# Hooks for loading extra kernel bits into the initramfs
+
+. /usr/share/initramfs-tools/hook-functions
+
+fbcon=n
+
+for x in ${MODULESDIR}/initrd/*; do
+ x=${x##*/}
+ x=${x%.*}
+ case ${x} in
+ '*')
+ break
+ ;;
+ *fb)
+ fbcon=y
+ ;;
+ esac
+
+ force_load ${x}
+done
+
+# And add vga16fb for usplash to use as well
+manual_add_modules vga16fb
+
+if [ ${fbcon} = "y" ]; then
+ force_load fbcon
+fi
diff --git a/hooks/legacylvm b/hooks/legacylvm
new file mode 100755
index 0000000..9121f90
--- /dev/null
+++ b/hooks/legacylvm
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# FIXME: Remove this hook after Lenny releases
+. /usr/share/initramfs-tools/hook-functions
+
+if [ -x /sbin/vgchange ] && [ -d /lib/lvm-200 ] \
+ && [ ! -f /usr/share/initramfs-tools/hooks/lvm2 ]; then
+ copy_exec /lib/lvm-200/vgchange /sbin
+ for x in dm_mod dm_snapshot dm_mirror; do
+ manual_add_modules ${x}
+ done
+fi
+exit 0
diff --git a/hooks/udevhelper b/hooks/udevhelper
new file mode 100755
index 0000000..f86e4af
--- /dev/null
+++ b/hooks/udevhelper
@@ -0,0 +1,36 @@
+#!/bin/sh
+# FIXME: kill after lenny release
+# needed for UUID root and partial etch upgrades
+#
+PREREQ="udev"
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+. /usr/share/initramfs-tools/hook-functions
+
+# should never happen
+if [ ! -e $DESTDIR/lib/udev/ ]; then
+ exit 0
+fi
+
+# fixed udev hook
+if [ -e $DESTDIR/lib/udev/ ] && [ -e $DESTDIR/lib/udev/hotplug.functions ]; then
+ exit 0
+fi
+
+cp /lib/udev/hotplug.functions $DESTDIR/lib/udev/
+for program in /lib/udev/*_id; do
+ copy_exec $program /lib/udev/
+done
+exit 0
diff --git a/scripts/init-premount/blacklist b/scripts/init-premount/blacklist
new file mode 100755
index 0000000..1dd9dbc
--- /dev/null
+++ b/scripts/init-premount/blacklist
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+# sanity check
+[ -z "${blacklist}" ] && exit 0
+
+# write blacklist to modprobe.d
+IFS=','
+for b in ${blacklist}; do
+ echo "blacklist $b" >> /etc/modprobe.d/initramfs
+done
diff --git a/scripts/init-premount/thermal b/scripts/init-premount/thermal
new file mode 100755
index 0000000..aa146ec
--- /dev/null
+++ b/scripts/init-premount/thermal
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+PREREQ=""
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+case "$DPKG_ARCH" in
+# load the right modules
+powerpc|ppc64)
+ modprobe i2c-powermac
+ modprobe therm_pm72
+ modprobe windfarm_cpufreq_clamp
+ modprobe windfarm_lm75_sensor
+ modprobe windfarm_max6690_sensor
+ modprobe windfarm_pm112
+ modprobe windfarm_pm81
+ modprobe windfarm_pm91
+ modprobe windfarm_smu_controls
+ modprobe windfarm_smu_sat
+ modprobe windfarm_smu_sensors
+ ;;
+i386|amd64|ia64)
+ modprobe fan
+ modprobe thermal
+ ;;
+esac
diff --git a/scripts/init-top/framebuffer b/scripts/init-top/framebuffer
new file mode 100755
index 0000000..0ed798e
--- /dev/null
+++ b/scripts/init-top/framebuffer
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+PREREQ=""
+prereqs()
+{
+ echo "$PREREQ"
+}
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+
+# The options part of the kernel "video=" argument (i.e. everyting
+# after "video=<fbdriver>:") has very inconsistent rules.
+#
+# Generally the following applies:
+# 1) options are comma-separated
+# 2) options can be in either of these three forms:
+# <arg>=<value>, <arg>:<value>, <boolean-arg>.
+# 3) the "mode" option has the form <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m]
+# and may or may not start with "mode="
+#
+# When the options are used with modules, they need to be space-separated
+# and the following conversions are needed:
+# <arg>:<value> -> <arg>=<value>
+# <boolean-arg> -> <boolean-arg>=1
+# <modevalue> -> mode=<modevalue>
+parse_video_opts()
+{
+ local OPTS="$1"
+ local IFS=","
+
+ # Must be a line like video=<fbdriver>:<opt1>,[opt2]...
+ if [ "${OPTS}" = "${OPTS%%:*}" ]; then
+ return
+ fi
+ OPTS="${OPTS#*:}"
+ for opt in ${OPTS}; do
+ # Already in the "<arg>=<value>" form
+ if [ "${opt}" != "${opt#*=}" ]; then
+ echo -n "$opt "
+ # In the "<arg>:<value>" form
+ elif [ "${opt}" != "${opt#*:}" ]; then
+ echo -n "${opt%:*}=${opt#*:} "
+ # Presumably a modevalue without the "mode=" prefix
+ elif [ "${opt}" != "${opt#[0-9]*x[0-9]}" ]; then
+ echo -n "mode=$opt "
+ # Presumably a boolean
+ else
+ echo -n "${opt}=1 "
+ fi
+ done
+}
+
+FB=""
+OPTS=""
+
+for x in $(cat /proc/cmdline); do
+ case ${x} in
+ vga=*)
+ FB="vesafb";
+ OPTS="";
+ ;;
+ video=*)
+ FB=${x#*=}
+ FB="${FB%%:*}"
+ OPTS="$(parse_video_opts "${x}")"
+ esac
+done
+
+# Map command line name to module name and other tweaks
+case ${FB} in
+matroxfb)
+ FB=matroxfb_base
+ ;;
+uvesafb)
+ # v86d requires /dev/zero and dev/mem, but udev haven't been started yet
+ [ -e /dev/zero ] || mknod -m 0666 /dev/zero c 1 5
+ [ -e /dev/mem ] || mknod -m 0640 /dev/mem c 1 1
+ ;;
+*)
+ ;;
+esac
+
+if [ -n "${FB}" ]; then
+ modprobe fbcon
+ modprobe ${FB} ${OPTS}
+fi
+
+if [ -e /proc/fb ]; then
+ while read fbno desc; do
+ if [ $(($fbno < 32)) ]; then
+ mknod -m 0640 /dev/fb${fbno} c 29 ${fbno}
+ fi
+ done < /proc/fb
+else
+ mknod -m 0640 /dev/fb0 c 29 0
+fi
diff --git a/scripts/local-top/lvm b/scripts/local-top/lvm
new file mode 100755
index 0000000..4cf48ad
--- /dev/null
+++ b/scripts/local-top/lvm
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+PREREQ="mdadm mdrun lvm2"
+
+prereqs()
+{
+ echo "$PREREQ"
+}
+
+case $1 in
+# get pre-requisites
+prereqs)
+ prereqs
+ exit 0
+ ;;
+esac
+
+activate_vg()
+{
+ local vg="$1"
+
+ # Make sure that we have a non-empty argument
+ if [ -z "${vg}" ]; then
+ return 1
+ fi
+
+ # Take care of lilo boot arg, risky activating of all vg
+ case $vg in
+ fe[0-9]*)
+ vgchange -ay
+ exit 0
+ ;;
+ # FIXME: check major
+ /dev/root)
+ vgchange -ay
+ exit 0
+ ;;
+ esac
+
+ # Make sure that we have a d-m path
+ vg=${vg#/dev/mapper/}
+ if [ "$vg" = "$1" ]; then
+ return 1
+ fi
+
+ # Make sure that the device includes at least one dash
+ if [ "$(echo -n "$vg" | tr -d -)" = "$vg" ]; then
+ return 1
+ fi
+
+ # Split volume group from logical volume.
+ vg=$(echo ${vg} | sed -e 's#\(.*\)\([^-]\)-[^-].*#\1\2#')
+ # Reduce padded --'s to -'s
+ vg=$(echo ${vg} | sed -e 's#--#-#g')
+
+ vgchange -ay ${vg}
+}
+
+if [ -e /scripts/local-top/lvm2 ]; then
+ exit 0
+fi
+
+if [ ! -e /sbin/vgchange ]; then
+ exit 0
+fi
+
+modprobe dm-mod
+modprobe dm-snapshot
+modprobe dm-mirror
+
+activate_vg "$ROOT"
+activate_vg "$resume"
+
+exit 0