initramfs-tools: update to 0.99.3, sync with debian 0.95.1.

This commit is contained in:
Juan RP 2010-06-03 01:35:01 +02:00
parent 25f7e2a47b
commit c81781ab0f
9 changed files with 111 additions and 104 deletions

View file

@ -28,7 +28,7 @@ MODULES=most
KEYMAP=n KEYMAP=n
# #
# COMPRESS: [ gzip | bzip2 | lzma ] # COMPRESS: [ gzip | bzip2 | lzma | lzop ]
# #
COMPRESS=gzip COMPRESS=gzip
@ -50,10 +50,11 @@ BOOT=local
# #
# DEVICE: ... # 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 ] # NFSROOT: [ auto | HOST:MOUNT ]

View file

@ -42,27 +42,23 @@ add_modules_from_file()
# Add dependent modules + eventual firmware # Add dependent modules + eventual firmware
manual_add_modules() 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 --quiet --show-depends "${1}" | awk '/^insmod/ { print $2 }'); do
# Prune duplicates # Prune duplicates
if [ -e "${DESTDIR}/${mam_x}" ]; then if [ -e "${DESTDIR}/${kmod}" ]; then
continue continue
fi fi
mkdir -p "${DESTDIR}/$(dirname "${mam_x}")" mkdir -p "${DESTDIR}/$(dirname "${kmod}")"
ln -s "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")" ln -s "${kmod}" "${DESTDIR}/$(dirname "${kmod}")"
if [ "${verbose}" = "y" ]; then if [ "${verbose}" = "y" ]; then
echo "Adding module ${mam_x}" echo "Adding module ${kmod}"
fi fi
# Add firmware files if necessary # Add required firmware
firmwares=$(modinfo -F firmware "${mam_x}") for firmware in $(modinfo -F firmware "${kmod}"); do
if [ -z "${firmwares}" ]; then
continue
fi
for firmware in $firmwares; do
if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \ if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then || [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then
continue continue
@ -77,11 +73,11 @@ manual_add_modules()
if [ ! -e /proc/modules ] ; then if [ ! -e /proc/modules ] ; then
continue continue
fi fi
if grep -q "^$(basename "${mam_x}" .ko)[[:space:]]" \ if grep -q "^$(basename "${kmod}" .ko)[[:space:]]" \
/proc/modules \ /proc/modules \
|| grep -q "^$(basename "${mam_x}" .ko)" \ || grep -q "^$(basename "${kmod}" .ko)" \
"${CONFDIR}/modules"; then "${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 fi
continue continue
fi fi
@ -103,59 +99,33 @@ manual_add_modules()
done done
} }
# $1 is the source path (e.g. /usr/bin/time) # $1 = file to copy to ramdisk
# $2 is the relative destination (e.g. /usr or /usr/time) # $2 (optional) Name for the file on the ramdisk
# # Location of the image dir is assumed to be $DESTDIR
# The destination is interpreted in the same way "cp" would, meaning # We never overwrite the target if it exists.
# (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
#
copy_exec() { copy_exec() {
local source target destination final_destination x nonoptlib local src target x nonoptlib
local libname dirname local libname dirname
source="${1}" src="${1}"
if [ -n "${2}" ]; then target="${2:-$1}"
target="${2}"
else [ -f "${src}" ] || return 1
if [ ! -e "${DESTDIR}/$(dirname "${1}")" ]; then
mkdir -p "${DESTDIR}/$(dirname "${1}")"
fi
target="${1}"
fi
if [ -d "${DESTDIR}/${target}" ]; then if [ -d "${DESTDIR}/${target}" ]; then
destination="${target}/$(basename "${source}")" # check if already copied
[ -e "${DESTDIR}/$target/${src##*/}" ] && return 0
else else
destination="${target}" [ -e "${DESTDIR}/$target" ] && return 0
#FIXME: inst_dir
mkdir -p "${DESTDIR}/${target%/*}"
fi fi
final_destination="${DESTDIR}/${destination}"
if [ -L "$final_destination" ]; then [ "${verbose}" = "y" ] && echo "Adding binary ${src}"
if [ $(readlink "${final_destination}") != "${source}" ]; then ln -s "${src}" "${DESTDIR}/${target}"
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
# Copy the dependant libraries # Copy the dependant libraries
if ! command -v ldd >/dev/null 2>&1 ; then for x in $(ldd ${src} 2>/dev/null | sed -e '
echo "WARNING: no ldd around - install glibc package."
exit 1
fi
for x in $(ldd ${source} 2>/dev/null | sed -e '
/\//!d; /\//!d;
/linux-gate/d; /linux-gate/d;
/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/}; /=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
@ -173,12 +143,11 @@ copy_exec() {
libname=$(basename "${x}") libname=$(basename "${x}")
dirname=$(dirname "${x}") dirname=$(dirname "${x}")
# FIXME inst_lib
mkdir -p "${DESTDIR}/${dirname}" mkdir -p "${DESTDIR}/${dirname}"
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
ln -s "${x}" "${DESTDIR}/${dirname}" ln -s "${x}" "${DESTDIR}/${dirname}"
if [ "${verbose}" = "y" ]; then [ "${verbose}" = "y" ] && echo "Adding library ${x}"
echo "Adding library ${x}"
fi
fi fi
done done
} }
@ -186,8 +155,7 @@ copy_exec() {
# Copy entire subtrees to the initramfs # Copy entire subtrees to the initramfs
copy_modules_dir() copy_modules_dir()
{ {
local x_mod local kmod exclude
local exclude
local dir="$1" local dir="$1"
shift shift
@ -197,15 +165,15 @@ copy_modules_dir()
if [ "${verbose}" = "y" ]; then if [ "${verbose}" = "y" ]; then
echo "Copying module directory ${dir}" echo "Copying module directory ${dir}"
if [ $# -ge 1 ]; then if [ $# -ge 1 ]; then
echo "(excluding $*)" echo "(excluding $*)"
fi fi
fi fi
while [ $# -ge 1 ]; do while [ $# -ge 1 ]; do
exclude="$exclude -name $1 -prune -o " exclude="${exclude:-} -name $1 -prune -o "
shift shift
done 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) manual_add_modules $(basename ${kmod} .ko)
done done
} }
@ -338,6 +306,12 @@ dep_add_modules()
elif [ "${root#/dev/mmcblk}" != "${root}" ]; then elif [ "${root#/dev/mmcblk}" != "${root}" ]; then
block=${root#/dev/} block=${root#/dev/}
block=${block%%p[0-9]*} 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 # classical root device
else else
block=${root#/dev/} block=${root#/dev/}
@ -395,11 +369,12 @@ dep_add_modules()
# The modules "most" classes added per default to the initramfs # The modules "most" classes added per default to the initramfs
auto_add_modules() auto_add_modules()
{ {
case "$1" in case "${1:-}" in
base) base)
for x in ehci-hcd ohci-hcd uhci-hcd usbhid btrfs ext2 \ for x in ehci-hcd ohci-hcd uhci-hcd usbhid xhci hid-apple \
ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs af_packet \ hid-microsoft \
atkbd i8042 virtio_pci; do btrfs ext2 ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs \
af_packet atkbd i8042 virtio_pci; do
manual_add_modules "${x}" manual_add_modules "${x}"
done done
;; ;;
@ -525,8 +500,8 @@ check_minkver()
{ {
local curversion initdir ARCH minversion cm_x tmp local curversion initdir ARCH minversion cm_x tmp
curversion="${1}" curversion="${1:-}"
initdir="${2}" initdir="${2:-}"
if [ -z "${initdir}" ]; then if [ -z "${initdir}" ]; then
ARCH=$(uname -m) ARCH=$(uname -m)
case ${ARCH} in case ${ARCH} in
@ -545,7 +520,7 @@ check_minkver()
return 0 return 0
fi fi
set_initlist set_initlist
for cm_x in ${initlist}; do for cm_x in ${initlist:-}; do
# sed: keep last line starting with MINKVER=, # sed: keep last line starting with MINKVER=,
# remove MINKVER= and trailing space # remove MINKVER= and trailing space
minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}") minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")

View file

@ -190,6 +190,9 @@ for x in $(cat /proc/cmdline); do
netconsole=*) netconsole=*)
netconsole=${x#netconsole=} netconsole=${x#netconsole=}
;; ;;
BOOTIF=*)
BOOTIF=${x#BOOTIF=}
;;
esac esac
done done

View file

@ -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 .SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs 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. in any recent Linux source for details. Optional paramater for NFS root.
.TP .TP
\fB\fI cryptopts \fB\fI BOOTIF
passes the args for cryptoroot. Set by the cryptsetup boot hooks. 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 .TP
\fB\fI boot \fB\fI boot
@ -295,7 +297,9 @@ esac
Where PREREQ is modified to list other scripts in the same subdirectory if necessary. Where PREREQ is modified to list other scripts in the same subdirectory if necessary.
.SS Help functions .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 .TP
\fB\fI \fB\fI
@ -469,7 +473,7 @@ prereqs)
;; ;;
esac esac
\fR. /usr/share/initramfs-tools/hook-functions \fR. /scripts/functions
# Begin real processing below this line # Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then if [ ! \-x "/sbin/frobnicate" ]; then
panic "Frobnication executable not found" panic "Frobnication executable not found"

View file

@ -64,7 +64,7 @@ done
. "${CONFDIR}/initramfs.conf" . "${CONFDIR}/initramfs.conf"
EXTRA_CONF='' EXTRA_CONF=''
for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do 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-.*$')"; | grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
done done
# FIXME: deprecated those settings on mkinitramfs run # FIXME: deprecated those settings on mkinitramfs run
@ -84,7 +84,7 @@ for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
fi fi
done done
if [ -n "${UMASK}" ]; then if [ -n "${UMASK:-}" ]; then
umask "${UMASK}" umask "${UMASK}"
fi fi
@ -126,7 +126,7 @@ case "${version}" in
esac esac
# Check userspace and kernel support for compressed initramfs images # Check userspace and kernel support for compressed initramfs images
if [ -z "${compress}" ]; then if [ -z "${compress:-}" ]; then
compress=${COMPRESS} compress=${COMPRESS}
else else
COMPRESS=${compress} COMPRESS=${compress}
@ -146,6 +146,9 @@ if [ -r /boot/config-${version} ]; then
fi fi
fi fi
# Always use max compression.
compress="${compress} -9"
if [ -d "${outfile}" ]; then if [ -d "${outfile}" ]; then
echo "${outfile} is a directory" echo "${outfile} is a directory"
exit 1 exit 1
@ -161,9 +164,9 @@ if [ ! -e "${MODULESDIR}/modules.dep" ]; then
depmod ${version} depmod ${version}
fi fi
DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1 DESTDIR="$(mktemp -d ${TMPDIR:-/tmp}/mkinitramfs_XXXXXX)" || exit 1
chmod 755 "${DESTDIR}" chmod 755 "${DESTDIR}"
__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1 __TMPCPIOGZ="$(mktemp ${TMPDIR:-/tmp}/mkinitramfs-OL_XXXXXX)" || exit 1
DPKG_ARCH=`uname -m` DPKG_ARCH=`uname -m`
@ -250,7 +253,7 @@ for i in ${EXTRA_CONF}; do
done done
# ROOT hardcoding # ROOT hardcoding
if [ -n "${ROOT}" ]; then if [ -n "${ROOT:-}" ]; then
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
fi fi
@ -275,8 +278,9 @@ if [ -e "${CONFDIR}/DSDT.aml" ]; then
fi fi
# Remove any looping or broken symbolic links, since they break cpio. # 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' \ find "${DESTDIR}" -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' \
| xargs -rL1 rm -f | xargs ${xargs_verbose:-} -rL1 rm -f
# Copy resume from klibc # Copy resume from klibc
copy_exec /bin/resume /bin copy_exec /bin/resume /bin

View file

@ -1,4 +1,4 @@
.TH MKINITRAMFS 8 "2010/04/04" "Linux" "mkinitramfs manual" .TH MKINITRAMFS 8 "2010/04/07" "Linux" "mkinitramfs manual"
.SH NAME .SH NAME
mkinitramfs \- low-level tool for generating an initramfs image 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 This option queries if mkinitramfs can create ramdisks for kernel version
.IR tversion . .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 .SH FILES
.TP .TP
.I /etc/initramfs-tools/initramfs.conf .I /etc/initramfs-tools/initramfs.conf

View file

@ -182,7 +182,7 @@ reduce_prereqs()
get_prereq_pairs() get_prereq_pairs()
{ {
set_initlist set_initlist
for gp_x in ${initlist}; do for gp_x in ${initlist:-}; do
echo ${gp_x} ${gp_x} echo ${gp_x} ${gp_x}
prereqs=$(${initdir}/${gp_x} prereqs) prereqs=$(${initdir}/${gp_x} prereqs)
for prereq in ${prereqs}; do for prereq in ${prereqs}; do
@ -216,7 +216,7 @@ run_scripts()
. ${initdir}/ORDER . ${initdir}/ORDER
elif command -v tsort >/dev/null 2>&1; then elif command -v tsort >/dev/null 2>&1; then
runlist=$(get_prereq_pairs | tsort) runlist=$(get_prereq_pairs | tsort)
call_scripts $2 call_scripts ${2:-}
else else
get_prereqs get_prereqs
reduce_prereqs reduce_prereqs
@ -315,7 +315,7 @@ configure_networking()
if [ -z "$bootif_mac" ]; then if [ -z "$bootif_mac" ]; then
bootif_mac="$x" bootif_mac="$x"
else else
bootif_mac="$x:$bootif_mac" bootif_mac="$bootif_mac:$x"
fi fi
done done
unset IFS unset IFS
@ -355,10 +355,10 @@ configure_networking()
;; ;;
""|on|any) ""|on|any)
# Bring up device # Bring up device
ipconfig -t ${ROUNDTTT} ${DEVICE} ipconfig -t ${ROUNDTTT} "${DEVICE}"
;; ;;
dhcp|bootp|rarp|both) dhcp|bootp|rarp|both)
ipconfig -t ${ROUNDTTT} -c ${IP} -d ${DEVICE} ipconfig -t ${ROUNDTTT} -c ${IP} -d "${DEVICE}"
;; ;;
*) *)
ipconfig -t ${ROUNDTTT} -d $IP ipconfig -t ${ROUNDTTT} -d $IP
@ -383,7 +383,8 @@ configure_networking()
# source specific bootdevice # source specific bootdevice
. /tmp/net-${DEVICE}.conf . /tmp/net-${DEVICE}.conf
else else
# source any interface as not exaclty specified # source any interface...
# ipconfig should have quit after first response
. /tmp/net-*.conf . /tmp/net-*.conf
fi fi
} }

View file

@ -11,8 +11,8 @@ version=""
usage() usage()
{ {
if [ -n "${1}" ]; then if [ -n "${1:-}" ]; then
printf "${@}\n\n" >&2 printf "${*}\n\n" >&2
fi fi
cat >&2 << EOF cat >&2 << EOF
Usage: ${0} [OPTION]... Usage: ${0} [OPTION]...
@ -48,16 +48,16 @@ chrooted()
mild_panic() mild_panic()
{ {
if [ -n "${1}" ]; then if [ -n "${1:-}" ]; then
printf "${@}\n" >&2 printf "${*}\n" >&2
fi fi
exit 0 exit 0
} }
panic() panic()
{ {
if [ -n "${1}" ]; then if [ -n "${1:-}" ]; then
printf "${@}\n" >&2 printf "${*}\n" >&2
fi fi
exit 1 exit 1
} }
@ -65,7 +65,7 @@ panic()
verbose() verbose()
{ {
if [ "${verbose}" = 1 ]; then if [ "${verbose}" = 1 ]; then
printf "${@}\n" printf "${*}\n"
fi fi
} }
@ -114,6 +114,7 @@ backup_booted_initramfs()
fi fi
# keep booted initramfs # keep booted initramfs
boot_initramfs=
uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime) uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime)
if [ -n "$uptime_days" ]; then if [ -n "$uptime_days" ]; then
boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days}) boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days})
@ -256,6 +257,7 @@ set_current_version()
set_linked_version() set_linked_version()
{ {
linktarget=
if [ -e /initrd.img ] && [ -L /initrd.img ]; then if [ -e /initrd.img ] && [ -L /initrd.img ]; then
linktarget="$(basename "$(readlink /initrd.img)")" linktarget="$(basename "$(readlink /initrd.img)")"
fi fi
@ -274,6 +276,10 @@ set_linked_version()
set_highest_version() set_highest_version()
{ {
get_sorted_versions get_sorted_versions
if [ -z "${version_list}" ]; then
version=
return
fi
set -- ${version_list} set -- ${version_list}
version=${1} version=${1}
} }

View file

@ -1,6 +1,6 @@
# Template file for 'initramfs-tools' # Template file for 'initramfs-tools'
pkgname=initramfs-tools pkgname=initramfs-tools
version=0.99.2.debian0.94.4 version=0.99.3.debian0.95.1
build_style=custom-install build_style=custom-install
short_desc="Tools for generating an initramfs" short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>" maintainer="Juan RP <xtraeme@gmail.com>"