summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf/initramfs.conf7
-rw-r--r--debian/TODO14
-rw-r--r--debian/copyright2
-rwxr-xr-xdebian/script8
-rw-r--r--hook-functions121
-rwxr-xr-xinit3
-rw-r--r--initramfs-tools.814
-rwxr-xr-xmkinitramfs27
-rw-r--r--mkinitramfs.815
-rw-r--r--scripts/functions13
-rwxr-xr-xupdate-initramfs4
11 files changed, 124 insertions, 104 deletions
diff --git a/conf/initramfs.conf b/conf/initramfs.conf
index 18c6c7e..0a108a8 100644
--- a/conf/initramfs.conf
+++ b/conf/initramfs.conf
@@ -36,7 +36,7 @@ BUSYBOX=y
KEYMAP=n
#
-# COMPRESS: [ gzip | bzip2 | lzma ]
+# COMPRESS: [ gzip | bzip2 | lzma | lzop ]
#
COMPRESS=gzip
@@ -58,10 +58,11 @@ BOOT=local
#
# DEVICE: ...
#
-# Specify the network interface, like eth0
+# Specify a specific network interface, like eth0
+# Overriden by optional ip= bootarg
#
-DEVICE=eth0
+DEVICE=
#
# NFSROOT: [ auto | HOST:MOUNT ]
diff --git a/debian/TODO b/debian/TODO
index f62656f..7423d06 100644
--- a/debian/TODO
+++ b/debian/TODO
@@ -3,8 +3,16 @@ TODO
o Grep for TODO and FIXME and do those. =)
- o Eliminate ?udev?, ?klibc?, busybox (-> glibc).
+ o Exclude list of hooks for admin.
+
+ o Easier generation for remote boxes, see #570522.
+
+ o "Fix" sed magic for lib dependence,
+ copy_exec, maybe use dracut copy logic.
- o Default to dep for PPC - Possibly to detect newworld?
+ o root loop support.
+
+ o MODULES=dep md replace awk magic with proper parsing.
+
+ o Eliminate ?udev?, ?klibc?, busybox (-> glibc).
- o udevsettle timeouts handling
diff --git a/debian/copyright b/debian/copyright
index ddbb70f..c21c66d 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -26,4 +26,4 @@ Copyright: 2005 - 2006 Adam Conrad
License:
-PUBLIC DOMAIN
+GPL v2 or any later version
diff --git a/debian/script b/debian/script
index 706a84d..43ae7d1 100755
--- a/debian/script
+++ b/debian/script
@@ -2,10 +2,18 @@
exec >&3
+echo "-- initramfs sizes"
+ls -lh /boot/initrd.img-2.6.*
+
echo "-- /proc/cmdline"
cat /proc/cmdline
echo
+if [ -r /etc/initramfs-tools/conf.d/resume ]; then
+ echo "-- resume"
+ cat /etc/initramfs-tools/conf.d/resume
+fi
+
echo "-- /proc/filesystems"
grep -v nodev /proc/filesystems
echo
diff --git a/hook-functions b/hook-functions
index b7c816c..744fc91 100644
--- a/hook-functions
+++ b/hook-functions
@@ -42,27 +42,23 @@ add_modules_from_file()
# Add dependent modules + eventual firmware
manual_add_modules()
{
- local mam_x firmwares firmware
+ local kmod firmware
- for mam_x in $(modprobe --set-version="${version}" --ignore-install \
+ for kmod in $(modprobe --set-version="${version}" --ignore-install \
--quiet --show-depends "${1}" | awk '/^insmod/ { print $2 }'); do
# Prune duplicates
- if [ -e "${DESTDIR}/${mam_x}" ]; then
+ if [ -e "${DESTDIR}/${kmod}" ]; then
continue
fi
- mkdir -p "${DESTDIR}/$(dirname "${mam_x}")"
- ln -s "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")"
+ mkdir -p "${DESTDIR}/$(dirname "${kmod}")"
+ ln -s "${kmod}" "${DESTDIR}/$(dirname "${kmod}")"
if [ "${verbose}" = "y" ]; then
- echo "Adding module ${mam_x}"
+ echo "Adding module ${kmod}"
fi
- # Add firmware files if necessary
- firmwares=$(modinfo -F firmware "${mam_x}")
- if [ -z "${firmwares}" ]; then
- continue
- fi
- for firmware in $firmwares; do
+ # Add required firmware
+ for firmware in $(modinfo -F firmware "${kmod}"); do
if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then
continue
@@ -78,11 +74,11 @@ manual_add_modules()
continue
fi
- if grep -q "^$(basename "${mam_x}" .ko)[[:space:]]" \
+ if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \
/proc/modules \
- || grep -q "^$(basename "${mam_x}" .ko)" \
+ || grep -q "^$(basename "${kmod}" .ko)" \
"${CONFDIR}/modules"; then
- echo "W: Possible missing firmware /lib/firmware/${firmware} for module $(basename ${mam_x} .ko)" >&2
+ echo "W: Possible missing firmware /lib/firmware/${firmware} for module $(basename ${kmod} .ko)" >&2
fi
continue
fi
@@ -104,59 +100,33 @@ manual_add_modules()
done
}
-# $1 is the source path (e.g. /usr/bin/time)
-# $2 is the relative destination (e.g. /usr or /usr/time)
-#
-# The destination is interpreted in the same way "cp" would, meaning
-# (assuming /bin is a directory):
-#
-# "copy_exec /usr/bin/time /bin" -> /bin/time
-# "copy_exec /usr/bin/time /bin/mytime" -> /bin/mytime
-#
-# If $2 is left out, the same destination path as for the source arg will
-# be used and directories will be created as needed, so:
-#
-# "copy_exec /usr/bin/time" -> /usr/bin/time
-#
+# $1 = file to copy to ramdisk
+# $2 (optional) Name for the file on the ramdisk
+# Location of the image dir is assumed to be $DESTDIR
+# We never overwrite the target if it exists.
copy_exec() {
- local source target destination final_destination x nonoptlib
+ local src target x nonoptlib
local libname dirname
- source="${1}"
- if [ -n "${2}" ]; then
- target="${2}"
- else
- if [ ! -e "${DESTDIR}/$(dirname "${1}")" ]; then
- mkdir -p "${DESTDIR}/$(dirname "${1}")"
- fi
- target="${1}"
- fi
+ src="${1}"
+ target="${2:-$1}"
+
+ [ -f "${src}" ] || return 1
if [ -d "${DESTDIR}/${target}" ]; then
- destination="${target}/$(basename "${source}")"
+ # check if already copied
+ [ -e "${DESTDIR}/$target/${src##*/}" ] && return 0
else
- destination="${target}"
+ [ -e "${DESTDIR}/$target" ] && return 0
+ #FIXME: inst_dir
+ mkdir -p "${DESTDIR}/${target%/*}"
fi
- final_destination="${DESTDIR}/${destination}"
- if [ -L "$final_destination" ]; then
- if [ $(readlink "${final_destination}") != "${source}" ]; then
- echo "W:copy_exec: Not copying ${source} to \$DESTDIR${destination}, which is already a copy of $(readlink ${final_destination})" >&2
- return
- fi
- else
- ln -s ${source} ${DESTDIR}/${destination}
- if [ "${verbose}" = "y" ]; then
- echo "Adding binary ${source}"
- fi
- fi
+ [ "${verbose}" = "y" ] && echo "Adding binary ${src}"
+ ln -s "${src}" "${DESTDIR}/${target}"
# Copy the dependant libraries
- if ! command -v ldd >/dev/null 2>&1 ; then
- echo "WARNING: no ldd around - install libc-bin"
- exit 1
- fi
- for x in $(ldd ${source} 2>/dev/null | sed -e '
+ for x in $(ldd ${src} 2>/dev/null | sed -e '
/\//!d;
/linux-gate/d;
/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
@@ -174,12 +144,11 @@ copy_exec() {
libname=$(basename "${x}")
dirname=$(dirname "${x}")
+ # FIXME inst_lib
mkdir -p "${DESTDIR}/${dirname}"
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
ln -s "${x}" "${DESTDIR}/${dirname}"
- if [ "${verbose}" = "y" ]; then
- echo "Adding library ${x}"
- fi
+ [ "${verbose}" = "y" ] && echo "Adding library ${x}"
fi
done
}
@@ -187,8 +156,7 @@ copy_exec() {
# Copy entire subtrees to the initramfs
copy_modules_dir()
{
- local x_mod
- local exclude
+ local kmod exclude
local dir="$1"
shift
@@ -202,10 +170,10 @@ copy_modules_dir()
fi
fi
while [ $# -ge 1 ]; do
- exclude="$exclude -name $1 -prune -o "
+ exclude="${exclude:-} -name $1 -prune -o "
shift
done
- for x_mod in $(find "${MODULESDIR}/${dir}" ${exclude} -name '*.ko' -print); do
+ for kmod in $(find "${MODULESDIR}/${dir}" ${exclude:-} -name '*.ko' -print); do
manual_add_modules $(basename ${x_mod} .ko)
done
}
@@ -337,6 +305,12 @@ dep_add_modules()
elif [ "${root#/dev/mmcblk}" != "${root}" ]; then
block=${root#/dev/}
block=${block%%p[0-9]*}
+
+ # DAC960 - good old mylex raid - root dev format /dev/rd/cXdXpX
+ elif [ "${root#/dev/rd/c}" != "${root}" ]; then
+ block="rd!c${root#/dev/rd/c}"
+ block=${block%%p[0-9]*}
+
# classical root device
else
block=${root#/dev/}
@@ -394,11 +368,12 @@ dep_add_modules()
# The modules "most" classes added per default to the initramfs
auto_add_modules()
{
- case "$1" in
+ case "${1:-}" in
base)
- for x in ehci-hcd ohci-hcd uhci-hcd usbhid btrfs ext2 \
- ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs af_packet \
- atkbd i8042 virtio_pci; do
+ for x in ehci-hcd ohci-hcd uhci-hcd usbhid xhci hid-apple \
+ hid-microsoft \
+ btrfs ext2 ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs \
+ af_packet atkbd i8042 virtio_pci; do
manual_add_modules "${x}"
done
;;
@@ -506,10 +481,10 @@ check_minkver()
{
local curversion initdir DPKG_ARCH minversion cm_x tmp
- curversion="${1}"
- initdir="${2}"
+ curversion="${1:-}"
+ initdir="${2:-}"
if [ -z "${initdir}" ]; then
- case ${DPKG_ARCH} in
+ case ${DPKG_ARCH:-} in
ia64|hppa)
minversion="2.6.15"
;;
@@ -525,7 +500,7 @@ check_minkver()
return 0
fi
set_initlist
- for cm_x in ${initlist}; do
+ for cm_x in ${initlist:-}; do
# sed: keep last line starting with MINKVER=,
# remove MINKVER= and trailing space
minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")
diff --git a/init b/init
index 7d0db07..142eb14 100755
--- a/init
+++ b/init
@@ -175,6 +175,9 @@ for x in $(cat /proc/cmdline); do
netconsole=*)
netconsole=${x#netconsole=}
;;
+ BOOTIF=*)
+ BOOTIF=${x#BOOTIF=}
+ ;;
esac
done
diff --git a/initramfs-tools.8 b/initramfs-tools.8
index 3bd5f12..0a15574 100644
--- a/initramfs-tools.8
+++ b/initramfs-tools.8
@@ -1,4 +1,4 @@
-.TH INITRAMFS-TOOLS 8 "2010/04/05" "Linux" "mkinitramfs script overview"
+.TH INITRAMFS-TOOLS 8 "2010/04/10" "Linux" "mkinitramfs script overview"
.SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs
@@ -69,8 +69,10 @@ NFS server than the DHCP server. See Documentation/filesystems/nfsroot.txt
in any recent Linux source for details. Optional paramater for NFS root.
.TP
-\fB\fI cryptopts
-passes the args for cryptoroot. Set by the cryptsetup boot hooks.
+\fB\fI BOOTIF
+is a mac adress in pxelinux format with leading "01-" and "-" as separations.
+pxelinux passes mac adress of network card used to PXE boot on with this
+bootarg.
.TP
\fB\fI boot
@@ -295,7 +297,9 @@ esac
Where PREREQ is modified to list other scripts in the same subdirectory if necessary.
.SS Help functions
-A number of functions (mostly dealing with output) are provided to boot scripts:
+A number of functions (mostly dealing with output) are provided to boot scripts in
+.I /scripts/functions
+:
.TP
\fB\fI
@@ -469,7 +473,7 @@ prereqs)
;;
esac
-\fR. /usr/share/initramfs-tools/hook-functions
+\fR. /scripts/functions
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
panic "Frobnication executable not found"
diff --git a/mkinitramfs b/mkinitramfs
index 2f9ac59..e54c77f 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -7,7 +7,6 @@ export PATH='/usr/bin:/sbin:/bin'
keep="n"
CONFDIR="/etc/initramfs-tools"
verbose="n"
-errors_to="2>/dev/null"
# BUSYBOXDIR="/usr/lib/initramfs-tools/bin/"
export BUSYBOXDIR="/bin"
@@ -66,7 +65,7 @@ done
. "${CONFDIR}/initramfs.conf"
EXTRA_CONF=''
for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
- EXTRA_CONF="${EXTRA_CONF} $(basename $i \
+ [ -e $i ] && EXTRA_CONF="${EXTRA_CONF} $(basename $i \
| grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
done
# FIXME: deprecated those settings on mkinitramfs run
@@ -86,7 +85,7 @@ for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
fi
done
-if [ -n "${UMASK}" ]; then
+if [ -n "${UMASK:-}" ]; then
umask "${UMASK}"
fi
@@ -128,7 +127,7 @@ case "${version}" in
esac
# Check userspace and kernel support for compressed initramfs images
-if [ -z "${compress}" ]; then
+if [ -z "${compress:-}" ]; then
compress=${COMPRESS}
else
COMPRESS=${compress}
@@ -140,12 +139,14 @@ if ! command -v ${compress} >/dev/null 2>&1; then
echo "No ${COMPRESS} in ${PATH}, using gzip"
fi
-if ! `grep -q -i config_rd_${COMPRESS}=y /boot/config-${version}` ; then
+if ! `grep -q -i ^config_rd_${COMPRESS%p} /boot/config-${version}` ; then
compress=gzip
[ "${verbose}" = y ] && \
echo "linux-2.6 misses ${COMPRESS} support, using gzip"
fi
+[ "${compress}" = lzop ] && compress="lzop -9"
+
if [ -d "${outfile}" ]; then
echo "${outfile} is a directory"
exit 1
@@ -161,9 +162,9 @@ if [ ! -e "${MODULESDIR}/modules.dep" ]; then
depmod ${version}
fi
-DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1
+DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1
chmod 755 "${DESTDIR}"
-__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1
+__TMPCPIOGZ="$(mktemp ${TMPDIR:-/tmp}/mkinitramfs-OL_XXXXXX)" || exit 1
DPKG_ARCH=`dpkg --print-architecture`
@@ -252,15 +253,20 @@ for i in ${EXTRA_CONF}; do
done
# ROOT hardcoding
-if [ -n "${ROOT}" ]; then
+if [ -n "${ROOT:-}" ]; then
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
fi
+if ! command -v ldd >/dev/null 2>&1 ; then
+ echo "WARNING: no ldd around - install libc-bin"
+ exit 1
+fi
+
# module-init-tools
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/rmmod /sbin
mkdir -p "${DESTDIR}/etc/modprobe.d"
-cp -a /etc/modprobe.d/*.conf "${DESTDIR}/etc/modprobe.d/"
+cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
# workaround: libgcc always needed on old-abi arm
if [ "$DPKG_ARCH" = arm ] || [ "$DPKG_ARCH" = armeb ]; then
@@ -285,8 +291,9 @@ if [ -e "${CONFDIR}/DSDT.aml" ]; then
fi
# Remove any looping or broken symbolic links, since they break cpio.
+[ "${verbose}" = y ] && xargs_verbose="-t"
find "${DESTDIR}" -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
- | xargs -rL1 rm -f
+ | xargs ${xargs_verbose:-} -rL1 rm -f
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
(
diff --git a/mkinitramfs.8 b/mkinitramfs.8
index 7fdeefb..49db6c8 100644
--- a/mkinitramfs.8
+++ b/mkinitramfs.8
@@ -1,4 +1,4 @@
-.TH MKINITRAMFS 8 "2010/04/04" "Linux" "mkinitramfs manual"
+.TH MKINITRAMFS 8 "2010/04/07" "Linux" "mkinitramfs manual"
.SH NAME
mkinitramfs \- low-level tool for generating an initramfs image
@@ -92,6 +92,19 @@ This option queries if mkinitramfs can create ramdisks on a running kernel of ve
This option queries if mkinitramfs can create ramdisks for kernel version
.IR tversion .
+.SH ENVIRONMENT
+.B mkinitramfs
+honours the
+.B TMPDIR
+environment variable. If set, it uses subdirectories in the given
+directory to create its temporary working directories. Else it uses
+.I /tmp
+as default value for that purpose. The given directory should be on a
+filesystem which allows the execution of files stored there, i.e.
+should not be mounted with the
+.B noexec
+mount option.
+
.SH FILES
.TP
.I /etc/initramfs-tools/initramfs.conf
diff --git a/scripts/functions b/scripts/functions
index 7b68255..1cc9be6 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -189,7 +189,7 @@ reduce_prereqs()
get_prereq_pairs()
{
set_initlist
- for gp_x in ${initlist}; do
+ for gp_x in ${initlist:-}; do
echo ${gp_x} ${gp_x}
prereqs=$(${initdir}/${gp_x} prereqs)
for prereq in ${prereqs}; do
@@ -223,7 +223,7 @@ run_scripts()
. ${initdir}/ORDER
elif command -v tsort >/dev/null 2>&1; then
runlist=$(get_prereq_pairs | tsort)
- call_scripts $2
+ call_scripts ${2:-}
else
get_prereqs
reduce_prereqs
@@ -323,7 +323,7 @@ configure_networking()
if [ -z "$bootif_mac" ]; then
bootif_mac="$x"
else
- bootif_mac="$x:$bootif_mac"
+ bootif_mac="$bootif_mac:$x"
fi
done
unset IFS
@@ -363,10 +363,10 @@ configure_networking()
;;
""|on|any)
# Bring up device
- ipconfig -t ${ROUNDTTT} ${DEVICE}
+ ipconfig -t ${ROUNDTTT} "${DEVICE}"
;;
dhcp|bootp|rarp|both)
- ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE}
+ ipconfig -t ${ROUNDTTT} -c ${IP} -d "${DEVICE}"
;;
*)
ipconfig -t ${ROUNDTTT} -d $IP
@@ -391,7 +391,8 @@ configure_networking()
# source specific bootdevice
. /tmp/net-${DEVICE}.conf
else
- # source any interface as not exaclty specified
+ # source any interface...
+ # ipconfig should have quit after first response
. /tmp/net-*.conf
fi
}
diff --git a/update-initramfs b/update-initramfs
index 8213e48..94b8971 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -8,12 +8,12 @@ USETRIGGERS=true
mode=""
version=""
-set -e
+set -eu
[ -r ${CONF} ] && . ${CONF}
if $USETRIGGERS \
- && [ x"$DPKG_MAINTSCRIPT_PACKAGE" != x ] \
+ && [ x"${DPKG_MAINTSCRIPT_PACKAGE:-}" != x ] \
&& [ $# = 1 ] \
&& [ x"$1" = x-u ] \
&& dpkg-trigger --check-supported 2>/dev/null