diff options
author | Jeff Bailey <jbailey@ubuntu.com> | 2005-06-30 00:05:01 +0000 |
---|---|---|
committer | Jeff Bailey <jbailey@ubuntu.com> | 2005-06-30 00:05:01 +0000 |
commit | 2c72958bfc090b046e21e9eaad9134235095ad30 (patch) | |
tree | 572afb10c1ad810995fbaf51584bde090dd9288d | |
parent | 8e6c20991ba676ce4c5b46094806c0317afd525a (diff) | |
download | initramfs-tools-2c72958bfc090b046e21e9eaad9134235095ad30.tar.gz initramfs-tools-2c72958bfc090b046e21e9eaad9134235095ad30.zip |
* Use detailed logging now for debian/changelog. We have at least
three people hacking now, and details would probably be useful.
* debian/TODO: Update
* debian/dirs: Sort and add usr/share/initramfs-tools/hooks
* debian/initramfs-tools.examples: Add docs/example_hook and
docs/example_hook_cpiogz
* debian/initramfs-tools.install: Pretty Print.
* debian/rules: Ensure that mkinitramfs is executable
* docs/example_script: New file
* init: Add concept of 'quiet', be verbose if not specified
* mkinitramfs: Do not load script functions until needed
Clear up comments / documentation
Use DESTDIR instead of TMPDIR
Add ability to link in extra hunks into the cpio file
Cosmetic cleanups
* scripts/functions: Add lsb stype log_FOO_msg functions
* scripts/local: Add logging
* scripts/nfs: Add logging
-rw-r--r-- | debian/TODO | 2 | ||||
-rw-r--r-- | debian/changelog | 39 | ||||
-rw-r--r-- | debian/dirs | 9 | ||||
-rw-r--r-- | debian/initramfs-tools.examples | 2 | ||||
-rw-r--r-- | debian/initramfs-tools.install | 8 | ||||
-rw-r--r-- | debian/rules | 2 | ||||
-rw-r--r-- | docs/example_script | 73 | ||||
-rw-r--r-- | mkinitramfs | 106 | ||||
-rw-r--r-- | scripts/functions | 39 | ||||
-rw-r--r-- | scripts/local | 8 | ||||
-rw-r--r-- | scripts/nfs | 10 |
11 files changed, 240 insertions, 58 deletions
diff --git a/debian/TODO b/debian/TODO index bf7e07d..d080de3 100644 --- a/debian/TODO +++ b/debian/TODO @@ -1,6 +1,8 @@ TODO ==== + o Grep for TODO and FIXME and do those. =) + o Get udev compiled against klibc o Integrate hotplug-ng diff --git a/debian/changelog b/debian/changelog index 54d3fcd..6c37206 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,42 @@ +initramfs-tools (0.13) breezy; urgency=low + + "We live in age when unnecessary things are our only necessities." + - Oscar Wilde + + * Use detailed logging now for debian/changelog. We have at least + three people hacking now, and details would probably be useful. + + * debian/TODO: Update + + * debian/dirs: Sort and add usr/share/initramfs-tools/hooks + + * debian/initramfs-tools.examples: Add docs/example_hook and + docs/example_hook_cpiogz + + * debian/initramfs-tools.install: Pretty Print. + + * debian/rules: Ensure that mkinitramfs is executable + + * docs/example_script: New file + + * init: Add concept of 'quiet', be verbose if not specified + + * mkinitramfs: Do not load script functions until needed + Clear up comments / documentation + Use DESTDIR instead of TMPDIR + Add ability to link in extra hunks into the cpio file + Cosmetic cleanups + + * scripts/functions: Add lsb stype log_FOO_msg functions + + * scripts/local: Add logging + + * scripts/nfs: Add logging + + Thanks to Karl Hegbloom for most of these patches! + + -- Jeff Bailey <jbailey@ubuntu.com> Wed, 29 Jun 2005 23:50:56 +0000 + initramfs-tools (0.12) breezy; urgency=low "I am not young enough to know everything." - Oscar Wilde diff --git a/debian/dirs b/debian/dirs index 94484bb..ac6210e 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,9 +1,10 @@ etc/mkinitramfs/init-bottom etc/mkinitramfs/init-top -etc/mkinitramfs/local-top -etc/mkinitramfs/local-premount etc/mkinitramfs/local-bottom -etc/mkinitramfs/nfs-top -etc/mkinitramfs/nfs-premount +etc/mkinitramfs/local-premount +etc/mkinitramfs/local-top etc/mkinitramfs/nfs-bottom +etc/mkinitramfs/nfs-premount +etc/mkinitramfs/nfs-top +usr/share/initramfs-tools/hooks usr/share/initramfs-tools/modules.d diff --git a/debian/initramfs-tools.examples b/debian/initramfs-tools.examples index 0e8472b..9f67297 100644 --- a/debian/initramfs-tools.examples +++ b/debian/initramfs-tools.examples @@ -1,2 +1,4 @@ conf/modules docs/example_script +docs/example_hook +docs/example_hook_cpiogz diff --git a/debian/initramfs-tools.install b/debian/initramfs-tools.install index e76186f..a2a78f5 100644 --- a/debian/initramfs-tools.install +++ b/debian/initramfs-tools.install @@ -1,4 +1,4 @@ -mkinitramfs usr/sbin -init usr/share/initramfs-tools -scripts usr/share/initramfs-tools -conf/initramfs.conf etc/mkinitramfs +mkinitramfs usr/sbin +init usr/share/initramfs-tools +scripts usr/share/initramfs-tools +conf/initramfs.conf etc/mkinitramfs diff --git a/debian/rules b/debian/rules index 0a1575f..a1b8695 100644 --- a/debian/rules +++ b/debian/rules @@ -3,4 +3,4 @@ include /usr/share/cdbs/1/rules/debhelper.mk common-build-arch:: - chmod +x init + chmod +x init mkinitramfs diff --git a/docs/example_script b/docs/example_script index 111b0d8..221c888 100644 --- a/docs/example_script +++ b/docs/example_script @@ -1,7 +1,52 @@ #!/bin/sh -# List the soft prerequisites here. So if there's something you know -# should be run first iff it exists. +# +# This script is run inside of the initramfs environment during the +# system boot process. It is installed there by 'mkinitramfs'. The +# package that owns it may opt to install it in either an appropriate +# location under "/usr/share/initramfs-tools/scripts/", or a similar +# location under "/etc/mkinitramfs/scripts/", depending upon whether +# it should be considered to be a user modifiable conffile or not. +# +# TODO: How do we deal with the case where the package that installed +# this has been removed but not purged, if we always arbitrarily +# copy all of these scripts into the initramfs? +# +# * The available toolset is limited inside this environment... +# +# TODO: document that toolset in the man page. +# +# * /dev, /proc, and /sys are already mounted. / is a ?? ro/rw +# filesystem... etc. more documentation. +# +# * It is expected that /proc and /sys will be umounted before +# changing over to the real root file system, so you must not keep +# any files open on them beyond these scripts. +# +# * You may like to strip these documentation comments from this +# example if you take it for a template, to save a little space in +# the initramfs, since nobody will ever read it from inside of +# there anyhow. +# + +# +# The environment contains at least the following variables: +# +# TODO: Decide what environment variables are meaningful and defined +# in this context, then document them as part of the interface. +# +# Because this script will be run as a full separate process, rather +# than sourced inside the context of the driver script, if it needs to +# pass information to another script that may run after it, it must do +# so by writing data to a file location known to both scripts. Simply +# setting an environment variable will not work. +# + +# +# 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() @@ -18,4 +63,28 @@ prereqs) esac # Do the work here. + echo "Got here!" + +# Handle an error: + +if [ -n "$an_error_occured" ]; +then + # + # TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this? + # I think we ultimately do, and that they need to be in their own + # well-documented location so that an overlay can override them. + # Think 'usplash' progress updates. + # + echo "An error occured in $0: $an_error_occured" >&2 + exit 1 + # + # TODO: Decide if different error codes are meaningful, what they + # mean, and what the semantics of them are wrt 'init' pass + # or panic. Consider naming the error values with mnemonic + # symbols rather than magic numbers. + # +fi + +exit 0 + diff --git a/mkinitramfs b/mkinitramfs index 4dabfce..c05fa47 100644 --- a/mkinitramfs +++ b/mkinitramfs @@ -1,12 +1,9 @@ #!/bin/sh -# For dependency ordered mkinitramfs hook scripts. -. /usr/share/initramfs-tools/scripts/functions - -# Takes a file containing a list of modules to be added as an argument -# Figures out dependancies and adds it in. +# Takes a file containing a list of modules to be added as an +# argument, figures out dependancies, and adds them. # -# File syntax: +# Input file syntax: # # # comment # modprobe_module_name [args ...] @@ -22,13 +19,13 @@ manual_add_modules() sed -e '/^#/d' ${1} | while read module rest; do for y in $(modprobe --set-version=${version} --show-depends ${module} | awk '{ print $2 }'); do # Prune duplicates - if [ -e ${TMPDIR}/${y} ]; then + if [ -e ${DESTDIR}/${y} ]; then continue fi - mkdir -p ${TMPDIR}/$(dirname ${y}) - ln -s ${y} ${TMPDIR}/$(dirname ${y}) - echo $(basename ${y} .ko) "${rest}" >>${TMPDIR}/conf/modules + mkdir -p ${DESTDIR}/$(dirname ${y}) + ln -s ${y} ${DESTDIR}/$(dirname ${y}) + echo $(basename ${y} .ko) "${rest}" >>${DESTDIR}/conf/modules done done } @@ -36,7 +33,7 @@ manual_add_modules() # Copy entire subtrees to the initramfs copy_modules_dir() { - tmpdir_modbase=${TMPDIR}/lib/modules/${version} + tmpdir_modbase=${DESTDIR}/lib/modules/${version} mkdir -p $(dirname ${tmpdir_modbase}/${1}) cp -a /lib/modules/${version}/${1} ${tmpdir_modbase}/${1} } @@ -64,13 +61,13 @@ auto_add_modules() for x in mbcache nfs af_packet raid1 ide-cd ide-disk ide-generic; do for y in $(modprobe --set-version=${version} --show-depends ${x} | awk '{ print $2 }'); do # Prune duplicates - if [ -e ${TMPDIR}/${y} ]; then + if [ -e ${DESTDIR}/${y} ]; then continue fi - mkdir -p ${TMPDIR}/$(dirname ${y}) - ln -s ${y} ${TMPDIR}/$(dirname ${y}) - depmod -b ${TMPDIR} ${version} + mkdir -p ${DESTDIR}/$(dirname ${y}) + ln -s ${y} ${DESTDIR}/$(dirname ${y}) + depmod -b ${DESTDIR} ${version} done done } @@ -96,6 +93,8 @@ EOF # Defaults keep="n" CONFDIR="/etc/mkinitramfs" +verbose="n" +errors_to="2>/dev/null" while getopts "d:ko:r:" flag; do case $flag in @@ -117,6 +116,9 @@ done shift $((${OPTIND} - 1)) +# For dependency ordered mkinitramfs hook scripts. +. /usr/share/initramfs-tools/scripts/functions + . ${CONFDIR}/initramfs.conf if [ x${outfile} = x ]; then @@ -157,10 +159,21 @@ if [ ! -e /lib/modules/${version} ]; then exit 1 fi -TMPDIR=$(mktemp -d) || exit 1 -mkdir -p ${TMPDIR}/modules ${TMPDIR}/conf ${TMPDIR}/etc -mkdir -p ${TMPDIR}/bin ${TMPDIR}/lib ${TMPDIR}/scripts -mkdir -p ${TMPDIR}/sbin +DESTDIR=$(mktemp -t -d mkinitramfs_XXXXXX) || exit 1 +__TMPCPIOGZ=$(mktemp -t mkinitramfs-OL_XXXXXX) || exit 1 + +# Export environment for hook scripts. +# +export version +export CONFDIR +export DESTDIR + +# Private, used by 'catenate_cpiogz'. +export __TMPCPIOGZ + +for d in bin conf etc lib modules sbin scripts; do + mkdir -p ${DESTDIR}/${d} +done for x in ${CONFDIR}/modules /usr/share/initramfs-tools/modules.d/*; do manual_add_modules ${x} @@ -171,46 +184,51 @@ auto_add_modules # Have to do each file, because cpio --dereference doesn't recurse down # symlinks. -ln -s /usr/lib/klibc/bin/* ${TMPDIR}/bin -ln -s /usr/lib/klibc/lib/* ${TMPDIR}/lib -ln -s /usr/share/initramfs-tools/init ${TMPDIR}/init -cp -a /usr/share/initramfs-tools/scripts/* ${TMPDIR}/scripts -ln -s ${CONFDIR}/initramfs.conf ${TMPDIR}/conf -ln -s /etc/udev ${TMPDIR}/etc +ln -s /usr/lib/klibc/bin/* ${DESTDIR}/bin +ln -s /usr/lib/klibc/lib/* ${DESTDIR}/lib +ln -s /usr/share/initramfs-tools/init ${DESTDIR}/init +cp -a /usr/share/initramfs-tools/scripts/* ${DESTDIR}/scripts +ln -s ${CONFDIR}/initramfs.conf ${DESTDIR}/conf +ln -s /etc/udev ${DESTDIR}/etc # Hack until udev is built with klibc -ln -s /sbin/udev ${TMPDIR}/bin -ln -s /sbin/udevstart ${TMPDIR}/bin -ln -s /lib/libc.so.* ${TMPDIR}/lib -ln -s /lib/ld*.so.* ${TMPDIR}/lib -rm ${TMPDIR}/lib/*lsb* +ln -s /sbin/udev ${DESTDIR}/bin +ln -s /sbin/udevstart ${DESTDIR}/bin +ln -s /lib/libc.so.* ${DESTDIR}/lib +ln -s /lib/ld*.so.* ${DESTDIR}/lib +rm ${DESTDIR}/lib/*lsb* # Busybox -rm ${TMPDIR}/bin/sh -ln -s /usr/lib/initramfs-tools/bin/busybox ${TMPDIR}/bin/sh +rm ${DESTDIR}/bin/sh +ln -s /usr/lib/initramfs-tools/bin/busybox ${DESTDIR}/bin/sh # This is ugly, but needed atm to make the builtins work =( -ln -s /usr/lib/initramfs-tools/bin/busybox ${TMPDIR}/bin/busybox +ln -s /usr/lib/initramfs-tools/bin/busybox ${DESTDIR}/bin/busybox # Modutils -ln -s /sbin/modprobe ${TMPDIR}/sbin -ln -s /sbin/depmod ${TMPDIR}/sbin -ln -s /sbin/rmmod ${TMPDIR}/sbin -mkdir -p ${TMPDIR}/etc/modprobe.d -ln -s /etc/modprobe.d/aliases ${TMPDIR}/etc/modprobe.d +ln -s /sbin/modprobe ${DESTDIR}/sbin +ln -s /sbin/depmod ${DESTDIR}/sbin +ln -s /sbin/rmmod ${DESTDIR}/sbin +mkdir -p ${DESTDIR}/etc/modprobe.d +ln -s /etc/modprobe.d/aliases ${DESTDIR}/etc/modprobe.d # Raid -ln -s /sbin/mdadm ${TMPDIR}/sbin -ln -s /sbin/mdrun ${TMPDIR}/sbin +ln -s /sbin/mdadm ${DESTDIR}/sbin +ln -s /sbin/mdrun ${DESTDIR}/sbin run_scripts /usr/share/initramfs-tools/hooks run_scripts /etc/mkinitramfs/hooks -# FIXME catenate extra cpio.gz here >>${outfile} +(cd ${DESTDIR} && find . | cpio --quiet --dereference -o -H newc | gzip -9 >${outfile}) -(cd ${TMPDIR} && find . | cpio --quiet --dereference -o -H newc | gzip -9 >${outfile}) +if [ -s ${__TMPCPIOGZ} ]; then + cat ${__TMPCPIOGZ} >>${outfile} +fi if [ "${keep}" = "y" ]; then - echo "Working files in ${TMPDIR}" + echo "Working files in ${DESTDIR} and overlay in ${__TMPCPIOGZ}" else - rm -rf "${TMPDIR}" + rm -rf "${DESTDIR}" + rm -rf "${__TMPCPIOGZ}" fi + +exit 0 diff --git a/scripts/functions b/scripts/functions index 5fb8c04..1899a14 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1,9 +1,45 @@ # -*- shell-script -*- +_log_msg() +{ + if [ "$quiet" = "y" ]; then return; fi + echo "$@" +} + +log_success_msg() +{ + _log_msg "Success: $@" +} + +log_failure_msg() +{ + _log_msg "Failure: $@" +} + +log_warning_msg() +{ + _log_msg "Warning: $@" +} + +log_begin_msg() +{ + _log_msg "Begin: $@ ..." +} + +log_end_msg() +{ + _log_msg "Done." +} + +# update_progress() # ToDo: NOP placeholder... what else for usplash? +# { +# : +# } + panic() { echo $@ - FS1='(initramfs) ' exec /bin/sh + FS1='(initramfs) ' exec /bin/sh </dev/console >/dev/console 2>&1 } render() @@ -162,5 +198,4 @@ load_modules() done ide_boot_events - } diff --git a/scripts/local b/scripts/local index 4a17abb..bcc96ad 100644 --- a/scripts/local +++ b/scripts/local @@ -3,7 +3,9 @@ # Parameter: Where to mount the filesystem mountroot () { + log_begin_msg "Running /scripts/local-top" run_scripts /scripts/local-top + log_end_msg # Get the root filesystem type if [ ! -e ${ROOT} ]; then @@ -12,7 +14,9 @@ mountroot () eval $(fstype < ${ROOT}) + log_begin_msg "Running /scripts/local-premount" run_scripts /scripts/local-premount + log_end_msg if [ ${readonly} = y ]; then roflag=-r @@ -20,10 +24,14 @@ mountroot () roflag=-w fi + # FIXME This has no error checking modprobe ${FSTYPE} + # FIXME This has no error checking # Mount root mount ${roflag} -t ${FSTYPE} ${ROOT} ${rootmnt} + log_begin_msg "Running /scripts/log-bottom" run_scripts /scripts/local-bottom + log_end_msg } diff --git a/scripts/nfs b/scripts/nfs index 1e2be2c..8149e86 100644 --- a/scripts/nfs +++ b/scripts/nfs @@ -1,9 +1,13 @@ -# NFS filesystem mounting *- shell-script -*- +# NFS filesystem mounting -*- shell-script -*- + +# FIXME This needs error checking # Paramter: Where the root should be mounted mountroot () { + log_begin_msg "Running /scripts/nfs-top" run_scripts /scripts/nfs-top + log_end_msg modprobe nfs # For DHCP @@ -15,7 +19,9 @@ mountroot () NFSROOT=${ROOTSERVER}:${ROOTPATH} fi + log_begin_msg "Running /scripts/nfs-premount" run_scripts /scripts/nfs-premount + log_end_msg if [ ${readonly} = y ]; then roflag="-o ro" @@ -25,6 +31,8 @@ mountroot () nfsmount ${roflag} ${NFSROOT} ${rootmnt} + log_begin_msg "Running /scripts/nfs-bottom" run_scripts /scripts/nfs-bottom + log_end_msg } |