initramfs-tools: add sources and use them.

* Add source files directly to avoid recreating patches and
  patches lots of times with no gain.
* Add du and expr busybox symlinks at init time.

Bump revision.

--HG--
extra : convert_revision : 4928750b0110f43cde577f6068e79bd0675c64cf
This commit is contained in:
Juan RP 2009-10-09 03:11:09 +02:00
parent 4e0f708ffb
commit 7e91eb4db8
25 changed files with 3645 additions and 292 deletions

View File

@ -0,0 +1,65 @@
#
# initramfs.conf
# Configuration file for mkinitramfs(8). See initramfs.conf(5).
#
# Note that configuration options from this file can be overriden
# by config files in the /etc/initramfs-tools/conf.d directory.
#
# MODULES: [ most | netboot | dep | list ]
#
# most - Add all framebuffer, acpi, filesystem, and harddrive drivers.
#
# dep - Try and guess which modules to load.
#
# netboot - Add the base modules, network modules, but skip block devices.
#
# list - Only include modules from the 'additional modules' list
#
MODULES=most
#
# BUSYBOX: [ y | n ]
#
# Use busybox if available.
#
BUSYBOX=y
#
# KEYMAP: [ y | n ]
#
# Load a keymap during the initramfs stage.
#
KEYMAP=n
#
# NFS Section of the config.
#
#
# BOOT: [ local | nfs ]
#
# local - Boot off of local media (harddrive, USB stick).
#
# nfs - Boot using an NFS drive as the root of the drive.
#
BOOT=local
#
# DEVICE: ...
#
# Specify the network interface, like eth0
#
DEVICE=eth0
#
# NFSROOT: [ auto | HOST:MOUNT ]
#
NFSROOT=auto

View File

@ -0,0 +1,10 @@
# List of modules that you want to include in your initramfs.
#
# Syntax: module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod

View File

@ -0,0 +1,20 @@
#
# Configuration file for update-initramfs(8)
#
#
# update_initramfs [ yes | all | no ]
#
# Default is yes
# If set to all update-initramfs will update all initramfs
# If set to no disables any update to initramfs beside kernel upgrade
update_initramfs=yes
#
# backup_initramfs [ yes | no ]
#
# Default is yes
# If set to no leaves no .bak backup files.
backup_initramfs=yes

View File

@ -0,0 +1,114 @@
#!/bin/sh
#
# This is an example hook script. It will be run by 'mkinitramfs'
# when it creates the image. It's job is to decide which files to
# install, then install them into the staging area, where the
# initramfs is being created. This happens when a new 'linux-image'
# package is installed, or when the administrator runs 'mkinitramfs'
# by hand to update an initramfs image.
#
# TODO: What about the case where you install something that should be
# added to the initramfs, but the linux-image it relates to has
# already been installed previously? Does this happen often
# enough that it needs to be handled? How can it be handled?
#
# * Think about the 'usplash'. The initramfs will need to be
# updated if a theme change or update is desired. Maybe it
# should not be totally automatic, but offered on upgrade
# predicated on a user response to a debconf question? That
# issue needs to be explored and a solution specified.
#
# * Do not assume that any needed subdirectories have been created
# yet, but don't bail out if they are already there.
#
# * All of the standard system tools are available, of course, since
# this hook is running in the real system, not the initramfs.
#
# * TODO: ... ? Anything else to tell them in this bullet-list?
#
#
# 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: May need a version_compare function for comparison of VERSION?
#
# 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
# You can do anything you need to from here on.
#
# Source the optional 'hook-functions' scriptlet, if you need the
# functions defined within it. Read it to see what is available to
# you. It contains functions for copying dynamically linked program
# binaries, and kernel modules into the DESTDIR.
#
. /usr/share/initramfs-tools/hook-functions
# If this hook script is a conffile (and thus stored in
# /etc/mkinitramfs/hooks), it must take care to do the right thing
# when the package containing it is removed but not purged. There of
# course may be other reasons to have custom logic deciding what to
# install. The version variable may be useful for this.
#
if [ -x /usr/bin/myprog ]; then
copy_exec /usr/bin/myprog usr/bin
fi
# To accompany this, there should usually be a script for inside the
# initramfs named something like:
#
# "/etc/mkinitramfs/local-premount/myprog"
#
# ... and it should do what is necessary to have 'myprog' get run
# inside the early runtime environment.
# Handle an error:
#
if [ -n "$an_error_occured" ];
then
#
# TODO: Do we need 'warn()', 'error()', and/or 'fatal()' for this?
#
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 'mkinitramfs'
# pass or fail. Consider naming the error values with
# mnemonic symbols rather than magic numbers. They may or
# may not be the same set of errors as the set for
# in-initramfs scripts.
#
fi
exit 0

View File

@ -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

View File

@ -0,0 +1,90 @@
#!/bin/sh
#
# 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()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
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

View File

@ -0,0 +1,508 @@
# -*- shell-script -*-
catenate_cpiogz() {
# Sanity check
if [ ! -e "${1}" ]; then
echo "W:catenate_cpiogz: arg1='${1}' does not exist." >&2
return
fi
cat "${1}" >>"${__TMPCPIOGZ}"
}
force_load()
{
manual_add_modules ${@}
echo "${@}" >>"${DESTDIR}/conf/modules"
}
# Takes a file containing a list of modules to be added as an
# argument, figures out dependancies, and adds them.
#
# Input file syntax:
#
# # comment
# modprobe_module_name [args ...]
# [...]
#
add_modules_from_file()
{
# Sanity check
if [ ! -e "${1}" ]; then
echo "W:add_modules_from_file: arg1='${1}' does not exist." >&2
return
fi
sed -e '/^#/d' ${1} | while read module rest; do
force_load "${module}" "${rest}"
done
}
# Add dependent modules + eventual firmware
manual_add_modules()
{
local mam_x firmwares firmware
for mam_x in $(modprobe --set-version="${version}" --ignore-install \
--show-depends "${1}" 2>/dev/null | awk '/^insmod/ { print $2 }'); do
# Prune duplicates
if [ -e "${DESTDIR}/${mam_x}" ]; then
continue
fi
mkdir -p "${DESTDIR}/$(dirname "${mam_x}")"
ln -s "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")"
if [ "${verbose}" = "y" ]; then
echo "Adding module ${mam_x}"
fi
# Add firmware files if necessary
firmwares=$(modinfo -F firmware "${mam_x}")
if [ -z "${firmwares}" ]; then
continue
fi
for firmware in $firmwares; do
if [ -e "${DESTDIR}/lib/firmware/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ]; then
continue
fi
# Only print warning for missing fw of loaded module
# or forced loaded module
if [ ! -e "/lib/firmware/${firmware}" ] \
&& [ ! -e "/lib/firmware/${version}/${firmware}" ]; then
if grep -q "^$(basename "${mam_x}" .ko)[[:space:]]" \
/proc/modules \
|| grep -q "^$(basename "${mam_x}" .ko)" \
"${CONFDIR}/modules"; then
echo "W: Possible missing firmware /lib/firmware/${firmware} for module $(basename ${mam_x} .ko)" >&2
fi
continue
fi
if [ ! -e "${DESTDIR}/lib/udev/firmware.agent" ] \
&& [ -e "/lib/udev/firmware.agent" ]; then
copy_exec /lib/udev/firmware.agent
fi
if [ -e "/lib/firmware/${version}/${firmware}" ]; then
copy_exec "/lib/firmware/${version}/${firmware}"
else
copy_exec "/lib/firmware/${firmware}"
fi
if [ "${verbose}" = "y" ]; then
echo "Adding firmware ${firmware}"
fi
done
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
#
copy_exec() {
local source target destination final_destination 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
if [ -d "${DESTDIR}/${target}" ]; then
destination="${target}/$(basename "${source}")"
else
destination="${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
# Copy the dependant libraries
for x in $(ldd ${source} 2>/dev/null | sed -e '
/\//!d;
/linux-gate/d;
/=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/};
s/[[:blank:]]*\([^[:blank:]]*\) (.*)/\1/' 2>/dev/null); do
# Try to use non-optimised libraries where possible.
# We assume that all HWCAP libraries will be in tls.
nonoptlib=$(echo "${x}" | sed -e 's#/lib/\(tls\|i686\).*/\(lib.*\)#/lib/\2#')
if [ -e "${nonoptlib}" ]; then
x="${nonoptlib}"
fi
libname=$(basename "${x}")
dirname=$(dirname "${x}")
mkdir -p "${DESTDIR}/${dirname}"
if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then
ln -s "${x}" "${DESTDIR}/${dirname}"
if [ "${verbose}" = "y" ]; then
echo "Adding library ${x}"
fi
fi
done
}
# Copy entire subtrees to the initramfs
copy_modules_dir()
{
local x_mod
if ! [ -d "${MODULESDIR}/${1}" ]; then
return;
fi
if [ "${verbose}" = "y" ]; then
echo "Copying module directory ${1}"
fi
for x_mod in $(find "${MODULESDIR}/${1}" -name '*.ko' -print); do
manual_add_modules $(basename ${x_mod} .ko)
done
}
# walk /sys for relevant modules
sys_walk_mod_add()
{
local driver_path module
device_path="$1"
while [ "${device_path}" != "/sys" ]; do
sys_walk_modalias ${device_path}
driver_path="$(readlink -f ${device_path}/driver)"
if [ -e "$driver_path" ]; then
module="$(basename $(readlink -f $driver_path))"
if [ -n "${module}" ]; then
force_load "${module}"
fi
fi
device_path="$(dirname ${device_path})"
done
}
# walk /sys for relevant modalias
sys_walk_modalias()
{
local device_path modalias
device_path="$(dirname "${1}")"
device_path="$(dirname "${device_path}")"
if [ -e "${device_path}/modalias" ]; then
modalias=$(cat "${device_path}/modalias")
fi
if [ -n "${modalias}" ]; then
force_load "${modalias}"
fi
}
# find and only copy root relevant modules
dep_add_modules()
{
local block minor root FSTYPE root_dev_path x
# findout root block device + fstype
eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')"
if [ "${root}" = "/dev/root" ] ; then
root="/dev/disk/by-uuid/"$(/sbin/blkid -s UUID -o value ${root}) 2>/dev/null
fi
root="$(readlink -f ${root})"
# find out real rootfs on auto type
if [ "${FSTYPE}" = "auto" ]; then
eval "$(/usr/lib/klibc/bin/fstype ${root})"
fi
# check that fstype rootfs recognition
if [ "${FSTYPE}" = "unknown" ]; then
echo "mkinitramfs: unknown fstype on root ${root}"
echo "mkinitramfs: workaround is MODULES=most"
echo "mkinitramfs: Error please report bug on initramfs-tools"
exit 1
fi
# Add rootfs
manual_add_modules "${FSTYPE}"
# lvm or luks root
if [ "${root#/dev/mapper/}" != "${root}" ] \
|| [ "${root#/dev/dm-}" != "${root}" ]; then
minor=$((0x$(stat --format "%T" ${root}) % 256))
block=$(ls -1 /sys/block/dm-${minor}/slaves | head -n 1)
# lvm on luks or luks on lvm
if [ "${block#dm-}" != "${block}" ]; then
block=$(ls -1 /sys/block/${block}/slaves | head -n 1)
fi
# lvm on md or luks on md
if [ "${block#md}" != "${block}" ]; then
block=$(awk "/^${block}/{print substr(\$5, 1, 4); exit}" \
/proc/mdstat)
fi
# luks or lvm on cciss or ida
if [ "${block#cciss}" != "${block}" ] \
|| [ "${block#ida}" != "${block}" ]; then
block="${block%p*}"
else
block=${block%%[0-9]*}
fi
# md root new naming scheme /dev/md/X
elif [ "${root#/dev/md/}" != "${root}" ]; then
root=${root#/dev/md/}
block=$(awk "/^md${root}/{print substr(\$5, 1, 3); exit}" \
/proc/mdstat)
# md root /dev/mdX
elif [ "${root#/dev/md}" != "${root}" ]; then
root=${root#/dev/}
block=$(awk "/^${root}/{print substr(\$5, 1, 3); exit}" \
/proc/mdstat)
# cciss device
elif [ "${root#/dev/cciss/}" != "${root}" ]; then
block=${root#/dev/cciss/*}
block="cciss!${block%p*}"
# ida device
elif [ "${root#/dev/ida/}" != "${root}" ]; then
block=${root#/dev/ida/*}
block="ida!${block%p*}"
# loop root /dev/loopX
elif [ "${root#/dev/loop}" != "${root}" ]; then
root=${root#/dev/}
block=$(losetup -a \
| awk "/${root}/{print substr(\$3, 7, 3); exit}")
# Xen virtual device /dev/xvdX
elif [ "${root#/dev/xvd}" != "${root}" ]; then
block=${root#/dev/}
# Xen has a mode where only the individual partitions are
# registered with the kernel as well as the usual full disk
# with partition table scheme.
if [ ! -e /sys/block/${block} ] ; then
block=${block%%[0-9]*}
fi
# mmc root /dev/mmcblkXpX
elif [ "${root#/dev/mmcblk}" != "${root}" ]; then
block=${root#/dev/}
block=${block%%p[0-9]*}
# classical root device
else
block=${root#/dev/}
block=${block%%[0-9]*}
fi
# Error out if /sys lack block dev
if [ -z "${block}" ] || [ ! -e /sys/block/${block} ]; then
echo "mkinitramfs: for root ${root} missing ${block} /sys/block/ entry"
echo "mkinitramfs: workaround is MODULES=most"
echo "mkinitramfs: Error please report the bug"
exit 1
fi
# sys walk ATA
root_dev_path=$(readlink -f /sys/block/${block}/device)
sys_walk_mod_add ${root_dev_path}
# catch old-style IDE
if [ -e /sys/bus/ide/devices/ ]; then
sys_walk_modalias ${root_dev_path}
manual_add_modules ide-gd_mod
# FIXME: remove post Squeeze
manual_add_modules ide-disk
manual_add_modules ide-cd
fi
if [ -e /sys/bus/scsi/devices/ ]; then
manual_add_modules sd_mod
fi
if [ -e /sys/bus/i2o/devices/ ]; then
force_load i2o_block
force_load i2o_config
fi
if [ -e /sys/bus/ps3_system_bus/ ]; then
for x in ps3disk ps3rom ps3-gelic ps3_sys_manager; do
manual_add_modules "${x}"
done
fi
if [ -e /sys/bus/vio/ ]; then
for x in sunvnet sunvdc; do
manual_add_modules "${x}"
done
fi
}
# The modules "most" classes added per default to the initramfs
auto_add_modules()
{
case "$1" in
base)
for x in ehci-hcd ohci-hcd uhci-hcd usbhid usb-storage ext2 \
ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs af_packet \
atkbd i8042 virtio_pci; do
manual_add_modules "${x}"
done
;;
net)
for x in 3c59x 8139cp 8139too 8390 atl1 atl1e b44 bmac \
bnx2 cxgb cxgb3 de2104x de4x5 defxx dl2k dmfe \
e100 e1000 e1000e ehea epic100 \
ep93xx_eth eql fealnx famachi forcedeth gelic_net \
hp100 igb ipg ixgb ixgbe mace mlx4_core mv643xx_eth myri10ge \
natsemi ne2k-pci netconsole netxen_nic niu ns83820 \
pcnet32 qla3xxx \
r8169 s2io sfc sis900 skge sky2 slhc smc911x starfire \
sundance sungem sungem_phy sunhme sunvnet tehuti tg3 tlan \
tulip typhoon via-rhine via-velocity winbond-840 \
xircom_cb xircom_tulip_cb yellowfin; do
manual_add_modules "${x}"
done
;;
ide)
copy_modules_dir kernel/drivers/ide
;;
mmc)
copy_modules_dir kernel/drivers/mmc
;;
scsi)
copy_modules_dir kernel/drivers/scsi
for x in mptfc mptsas mptscsih mptspi zfcp; do
manual_add_modules "${x}"
done
;;
ata)
copy_modules_dir kernel/drivers/ata
;;
block)
copy_modules_dir kernel/drivers/block
;;
ieee1394)
for x in ohci1394 sbp2; do
manual_add_modules "${x}"
done
;;
firewire)
for x in firewire-ohci firewire-sbp2; do
manual_add_modules "${x}"
done
;;
i2o)
for x in i2o_block; do
manual_add_modules "${x}"
done
;;
dasd)
for x in dasd_diag_mod dasd_eckd_mod dasd_fba_mod; do
manual_add_modules "${x}"
done
;;
*)
auto_add_modules base
auto_add_modules net
auto_add_modules ide
auto_add_modules scsi
auto_add_modules block
auto_add_modules ata
auto_add_modules i2o
auto_add_modules dasd
auto_add_modules ieee1394
auto_add_modules firewire
auto_add_modules mmc
;;
esac
}
usage()
{
cat >&2 << EOF
Usage: ${0} [OPTION]... -o outfile [version]
Options:
-d confdir Specify an alternative configuration directory.
-k Keep temporary directory used to make the image.
-o outfile Write to outfile.
-r root Override ROOT setting in initramfs.conf.
See mkinitramfs(8) for further details.
EOF
exit 1
}
compare_versions()
{
local curv="$1" minv="$2"
xbps-cmpver $curv $minv
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
return 0
else
return 1
fi
}
# minimal supported kernel version
check_minkver()
{
local curversion initdir ARCH minversion cm_x tmp
curversion="${1}"
initdir="${2}"
if [ -z "${initdir}" ]; then
ARCH=$(uname -m)
case ${ARCH} in
ia64|hppa)
minversion="2.6.15"
;;
*)
minversion="2.6.12"
;;
esac
if ! compare_versions "${curversion}" "${minversion}"; then
echo "W: kernel ${curversion} too old for initramfs on ${DPKG_ARCH}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
fi
return 0
fi
set_initlist
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}")
if [ -z "${tmp}" ]; then
continue
elif ! compare_versions "${curversion}" "${minver}"; then
echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
fi
done
}

View File

@ -0,0 +1,55 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
# Hook to load keymaps into the initramfs if requested by KEYMAP="y"
if [ "$KEYMAP" != "y" ] && [ "$KEYMAP" != "Y" ]; then
exit 0
fi
# Step 1 - Basic tools
if [ ! -x /bin/loadkeys ] || [ ! -r /etc/console/boottime.kmap.gz ]; then
exit 0
fi
. /usr/share/initramfs-tools/hook-functions
copy_exec /bin/loadkeys /bin
cp /etc/console/boottime.kmap.gz ${DESTDIR}/etc/
# Step 2 - Check for UTF8 console
if [ ! -x /usr/bin/kbd_mode ]; then
exit 0
fi
if [ -r /etc/environment ]; then
env="/etc/environment"
elif [ -r /etc/default/locale ]; then
env="/etc/default/locale"
else
exit 0
fi
for var in LANG LC_ALL LC_CTYPE; do
value=$(egrep "^[^#]*${var}=" $env | tail -n1 | cut -d= -f2)
eval $var=$value
done
charmap=$(LANG=$LANG LC_ALL=$LC_ALL LC_CTYPE=$LC_CTYPE locale charmap)
if [ "$charmap" = "UTF-8" ]; then
copy_exec /usr/bin/kbd_mode /bin
fi
exit 0

View File

@ -0,0 +1,267 @@
#!/bin/sh
echo "Loading, please wait..."
# Create some required busybox symlinks.
if [ -x /bin/busybox ]; then
for f in cut touch tr grep awk tail basename ls cp rm \
head expr du; do
busybox ln -s /bin/busybox /bin/${f}
done
busybox ln -s /bin/busybox /sbin/pkill
fi
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir -m 0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
mkdir -p /var/lock
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
mount -t proc -o nodev,noexec,nosuid proc /proc
# Note that this only becomes /dev on the real filesystem if udev's scripts
# are used; which they will be, but it's worth pointing out
tmpfs_size="10M"
if [ -e /etc/udev/udev.conf ]; then
. /etc/udev/udev.conf
fi
mount -t tmpfs -o size=$tmpfs_size,mode=0755 udev /dev
[ -e /dev/console ] || mknod -m 0600 /dev/console c 5 1
[ -e /dev/null ] || mknod /dev/null c 1 3
> /dev/.initramfs-tools
mkdir /dev/.initramfs
# Export the dpkg architecture
export DPKG_ARCH=
. /conf/arch.conf
# Set modprobe env
export MODPROBE_OPTIONS="-qb"
# Export relevant variables
export ROOT=
export ROOTDELAY=
export ROOTFLAGS=
export ROOTFSTYPE=
export IP=
export break=
export init=/sbin/init
export quiet=n
export readonly=y
export rootmnt=/root
export debug=
export panic=
export blacklist=
export resume_offset=
# Bring in the main config
. /conf/initramfs.conf
for conf in conf/conf.d/*; do
[ -f ${conf} ] && . ${conf}
done
. /scripts/functions
# Parse command line options
for x in $(cat /proc/cmdline); do
case $x in
init=*)
init=${x#init=}
;;
root=*)
ROOT=${x#root=}
case $ROOT in
LABEL=*)
ROOT="${ROOT#LABEL=}"
# support any / in LABEL= path (escape to \x2f)
case "${ROOT}" in
*[/]*)
if [ -x "$(command -v sed)" ]; then
ROOT="$(echo ${ROOT} | sed 's,/,\\x2f,g')"
else
if [ "${ROOT}" != "${ROOT#/}" ]; then
ROOT="\x2f${ROOT#/}"
fi
if [ "${ROOT}" != "${ROOT%/}" ]; then
ROOT="${ROOT%/}\x2f"
fi
IFS='/'
newroot=
for s in $ROOT; do
if [ -z "${newroot}" ]; then
newroot="${s}"
else
newroot="${newroot}\\x2f${s}"
fi
done
unset IFS
ROOT="${newroot}"
fi
esac
ROOT="/dev/disk/by-label/${ROOT}"
;;
UUID=*)
ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
;;
/dev/nfs)
[ -z "${BOOT}" ] && BOOT=nfs
;;
esac
;;
rootflags=*)
ROOTFLAGS="-o ${x#rootflags=}"
;;
rootfstype=*)
ROOTFSTYPE="${x#rootfstype=}"
;;
rootdelay=*)
ROOTDELAY="${x#rootdelay=}"
case ${ROOTDELAY} in
*[![:digit:].]*)
ROOTDELAY=
;;
esac
;;
nfsroot=*)
NFSROOT="${x#nfsroot=}"
;;
ip=*)
IP="${x#ip=}"
;;
boot=*)
BOOT=${x#boot=}
;;
resume=*)
RESUME="${x#resume=}"
;;
resume_offset=*)
resume_offset="${x#resume_offset=}"
;;
noresume)
noresume=y
;;
panic=*)
panic="${x#panic=}"
case ${panic} in
*[![:digit:].]*)
panic=
;;
esac
;;
quiet)
quiet=y
;;
ro)
readonly=y
;;
rw)
readonly=n
;;
debug)
debug=y
quiet=n
exec >/dev/.initramfs/initramfs.debug 2>&1
set -x
;;
debug=*)
debug=y
quiet=n
set -x
;;
break=*)
break=${x#break=}
;;
break)
break=premount
;;
blacklist=*)
blacklist=${x#blacklist=}
;;
esac
done
if [ -z "${noresume}" ]; then
export resume=${RESUME}
else
export noresume
fi
depmod -a
maybe_break top
# Don't do log messages here to avoid confusing usplash
run_scripts /scripts/init-top
maybe_break modules
log_begin_msg "Loading essential drivers"
load_modules
log_end_msg
maybe_break premount
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
run_scripts /scripts/init-premount
[ "$quiet" != "y" ] && log_end_msg
maybe_break mount
log_begin_msg "Mounting root file system"
. /scripts/${BOOT}
parse_numeric ${ROOT}
maybe_break mountroot
mountroot
log_end_msg
maybe_break bottom
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
run_scripts /scripts/init-bottom
[ "$quiet" != "y" ] && log_end_msg
# Move virtual filesystems over to the real filesystem
mount -n -o move /sys ${rootmnt}/sys
mount -n -o move /proc ${rootmnt}/proc
# Check init bootarg
if [ -n "${init}" ] && [ ! -x "${rootmnt}${init}" ]; then
echo "Target filesystem doesn't have ${init}."
init=
fi
# Search for valid init
if [ -z "${init}" ] ; then
for init in /sbin/init /etc/init /bin/init /bin/sh; do
if [ ! -x "${rootmnt}${init}" ]; then
continue
fi
break
done
fi
# No init on rootmount
if [ ! -x "${rootmnt}${init}" ]; then
panic "No init found. Try passing init= bootarg."
fi
maybe_break init
# don't leak too much of env - some init(8) don't clear it
# (keep init, rootmnt)
unset debug
unset MODPROBE_OPTIONS
unset DPKG_ARCH
unset ROOTFLAGS
unset ROOTFSTYPE
unset ROOTDELAY
unset ROOT
unset IP
unset blacklist
unset break
unset noresume
unset panic
unset quiet
unset readonly
unset resume
unset resume_offset
# Chain to real filesystem
exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console
panic "Could not execute run-init."

View File

@ -0,0 +1,544 @@
.TH INITRAMFS-TOOLS 8 "2009/02/23" "Linux" "mkinitramfs script overview"
.SH NAME
initramfs-tools \- an introduction to writing scripts for mkinitramfs
.SH DESCRIPTION
initramfs-tools has one main script and two different sets of subscripts which
will be used during different phases of execution. Each of these will be
discussed separately below with the help of an imaginary tool which performs a
frobnication of a lvm partition prior to mounting the root partition.
Valid boot and hook scripts names consist solely of alphabetics, numerics
and underscores. Other scripts are discarded.
.SS Hook scripts
These are used when an initramfs image is created and not included in the
image itself. They can however cause files to be included in the image.
.SS Boot scripts
These are included in the initramfs image and normally executed during
kernel boot in the early user-space before the root partition has been
mounted.
.SH INIT SCRIPT
The script which is executed first and is in charge of running all other
scripts can be found in /usr/share/initramfs-tools/init. It takes a number of
arguments which influence the boot procedure:
.SS Boot options
The init and root are usually passed by the boot loader for local boot.
The other parameters are optional.
.TP
\fB\fI init
the binary to hand over execution to on the root fs after the initramfs scripts are done.
.TP
\fB\fI root
the device node to mount as the root file system.
The recommended usage is to specify the UUID as followed "root=UUID=xxx".
As normal device names are not stable and may change depending on the
boot order.
.TP
\fB\fI rootdelay
set delay in seconds. Determines how long mountroot waits for root to appear.
The default is 180 seconds.
.TP
\fB\fI rootflags
set the file system mount option string.
.TP
\fB\fI rootfstype
set the root file system type.
.TP
\fB\fI nfsroot
can be either "auto" to try to get the relevant information from DHCP or a
string of the form NFSSERVER:NFSPATH or NFSSERVER:NFSPATH:NFSOPTS.
Use root=/dev/nfs for NFS to kick to in. NFSOPTS can be looked up in
\fInfs(5)\fP.
.TP
\fB\fI ip
tells how to configure the ip address. Allows to specify an different
NFS server than the DHCP server. See Documentation/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.
.TP
\fB\fI boot
either local or NFS (affects which initramfs scripts are run, see the "Subdirectories" section under boot scripts).
.TP
\fB\fI resume
On install initramfs-tools tries to autodetect the resume partition. On success
the RESUME variable is written to /etc/initramfs-tools/conf.d/resume.
The boot variable noresume overrides it.
.TP
\fB\fI resume_offset
Specify the offset from the partition given by "resume=" at which the swap
header of the swap file is located.
.TP
\fB\fI quiet
reduces the amount of text output to the console during boot.
.TP
\fB\fI ro
mounts the rootfs read-only.
.TP
\fB\fI rw
mounts the rootfs read-write.
.TP
\fB\fI blacklist
disables load of specific modules.
Use blacklist=module1,module2,module3 bootparameter.
.TP
\fB\fI panic
sets an timeout on panic.
panic=<sec> is a documented security feature: it disables the debug shell.
.TP
\fB\fI debug
generates lots of output. It writes a log to /dev/.initramfs/initramfs.debug.
Instead when invoked with an arbitrary argument output is written to console.
Use for example "debug=vc".
.TP
\fB\fI break
spawns a shell in the initramfs image at chosen run-time
(top, modules, premount, mount, mountroot, bottom, init).
The default is premount without any arg.
Beware that if both "panic" and "break" are present,
initramfs will not spawn any shells but reboot instead.
.TP
\fB\fI all_generic_ide
loads generic IDE/ATA chipset support on boot.
.SH HOOK SCRIPTS
Hooks can be found in two places: /usr/share/initramfs-tools/hooks and
/etc/initramfs-tools/hooks. They are executed during generation of the
initramfs-image and are responsible for including all the necessary components
in the image itself. No guarantees are made as to the order in which the
different scripts are executed unless the prereqs are setup in the script.
.SS Header
In order to support prereqs, each script should begin with the following lines:
.RS
.nf
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
\fR. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
.fi
.RE
For example, if you are writing a new hook script which relies on lvm, the line
starting with PREREQ should be changed to PREREQ="lvm" which will ensure that
the lvm hook script is run before your custom script.
.SS Help functions
/usr/share/initramfs-tools/hook-functions contains a number of functions which
deal with some common tasks in a hook script:
.TP
\fB\fI
manual_add_modules
adds a module (and any modules which it depends on) to the initramfs image.
.RS
.PP
.B Example:
manual_add_modules isofs
.RE
.TP
\fB\fI
add_modules_from_file
reads a file containing a list of modules (one per line) to be added to the
initramfs image. The file can contain comments (lines starting with #) and
arguments to the modules by writing the arguments on the same line as the name
of the module.
.RS
.PP
.B Example:
add_modules_from_file /tmp/modlist
.RE
.TP
\fB\fI
force_load
adds a module (and its dependencies) to the initramfs image and also
unconditionally loads the module during boot. Also supports passing arguments
to the module by listing them after the module name.
.RS
.PP
.B Example:
force_load cdrom debug=1
.RE
.TP
\fB\fI
copy_modules_dir
copies an entire module directory from /lib/modules/KERNELVERSION/ into the
initramfs image.
.RS
.PP
.B Example:
copy_modules_dir kernel/drivers/ata
.RE
.SS Including binaries
If you need to copy binaries to the initramfs module, a command like this
should be used:
.PP
.RS
copy_exec /sbin/mdadm /sbin
.RE
mkinitramfs will automatically detect which libraries the executable depends on
and copy them to the initramfs. This means that most executables, unless
compiled with klibc, will automatically include glibc in the image which will
increase its size by several hundred kilobytes.
.SS Exported variables
mkinitramfs sets several variables for the hook scripts environment.
.TP
\fB\fI MODULESDIR
corresponds to the linux-2.6 modules dir.
.TP
\fB\fI version
is the $(uname -r) linux-2.6 version against mkinitramfs is run.
.TP
\fB\fI CONFDIR
is the path of the used initramfs-tools configurations.
.TP
\fB\fI DESTDIR
is the root path of the newly build initramfs.
.TP
\fB\fI DPKG_ARCH
allows arch specific hook additions.
.TP
\fB\fI verbose
corresponds to the verbosity of the update-initramfs run.
.TP
\fB\fI KEYMAP
sets if a keymap needs to be added to initramfs.
.TP
\fB\fI MODULES
specifies which kind of modules should land on initramfs.
This setting shouldn't be overriden by hook script, but can guide them
on how much they need to include on initramfs.
.SH BOOT SCRIPTS
Similarly to hook scripts, boot scripts can be found in two places
/usr/share/initramfs-tools/scripts/ and /etc/initramfs-tools/scripts/. There
are a number of subdirectories to these two directories which control the boot
stage at which the scripts are executed.
.SS Header
Like for hook scripts, there are no guarantees as to the order in which the
different scripts in one subdirectory (see "Subdirectories" below) are
executed. In order to define a certain order, a similar header as for hook
scripts should be used:
.RS
.nf
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
.fi
.RE
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:
.TP
\fB\fI
log_success_msg
Logs a success message
.RS
.PP
.B Example:
log_success_msg "Frobnication successful"
.RE
.TP
\fB\fI
log_failure_msg
Logs a failure message
.RS
.PP
.B Example:
log_failure_msg "Frobnication component froobz missing"
.RE
.TP
\fB\fI
log_warning_msg
Logs a warning message
.RS
.PP
.B Example:
log_warning_msg "Only partial frobnication possible"
.RE
.TP
\fB\fI
log_begin_msg
Logs a message that some processing step has begun
.TP
\fB\fI
log_end_msg
Logs a message that some processing step is finished
.RS
.PP
.B Example:
.PP
.RS
.nf
log_begin_msg "Frobnication begun"
# Do something
log_end_msg
.fi
.RE
.RE
.TP
\fB\fI
panic
Logs an error message and executes a shell in the initramfs image to allow the
user to investigate the situation.
.RS
.PP
.B Example:
panic "Frobnication failed"
.RE
.SS Subdirectories
Both /usr/share/initramfs-tools/scripts and /etc/initramfs-tools/scripts
contains the following subdirectories.
.TP
\fB\fI
init-top
the scripts in this directory are the first scripts to be executed after sysfs
and procfs have been mounted and /dev/console and /dev/null have been created.
No other device files are present yet.
.TP
\fB\fI
init-premount
runs the udev hooks for populating the /dev tree (udev will keep running until
init-bottom) after modules specified by hooks and /etc/initramfs-tools/modules
have been loaded.
.TP
\fB\fI
local-top OR nfs-top
After these scripts have been executed, the root device node is expected to be
present (local) or the network interface is expected to be usable (NFS).
.TP
\fB\fI
local-premount OR nfs-premount
are run after the sanity of the root device has been verified (local) or the
network interface has been brought up (NFS), but before the actual root fs has
been mounted.
.TP
\fB\fI
local-bottom OR nfs-bottom
are run after the rootfs has been mounted (local) or the NFS root share has
been mounted. udev is stopped.
.TP
\fB\fI
init-bottom
are the last scripts to be executed before procfs and sysfs are moved to the
real rootfs and execution is turned over to the init binary which should now be
found in the mounted rootfs.
.SS Boot parameters
.TP
\fB\fI
/conf/param.conf
allows boot scripts to change exported variables that are listed on top of init. Write the new values to it. It will be sourced after an boot script run if it exists.
.SH EXAMPLES
.SS Hook script
An example hook script would look something like this (and would usually be
placed in /etc/initramfs-tools/hooks/frobnicate):
.RS
.nf
#!/bin/sh
# Example frobnication hook script
PREREQ="lvm"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
\fR. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
exit 0
fi
force_load frobnicator interval=10
cp /sbin/frobnicate "${DESTDIR}/sbin"
exit 0
.fi
.RE
.SS Boot script
An example boot script would look something like this (and would usually be placed in /etc/initramfs-tools/scripts/local-top/frobnicate):
.RS
.nf
#!/bin/sh
# Example frobnication boot script
PREREQ="lvm"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
# Begin real processing below this line
if [ ! \-x "/sbin/frobnicate" ]; then
panic "Frobnication executable not found"
fi
if [ ! \-e "/dev/mapper/frobb" ]; then
panic "Frobnication device not found"
fi
log_begin_msg "Starting frobnication"
/sbin/frobnicate "/dev/mapper/frobb" || panic "Frobnication failed"
log_end_msg
exit 0
.fi
.RE
.SS Exported variables
init sets several variables for the boot scripts environment.
.TP
\fB\fI ROOT
correponds to the root boot option.
Advanced boot scripts like cryptsetup or live-initramfs need to play tricks.
Otherwise keep it alone.
.TP
\fB\fI ROOTDELAY, ROOTFLAGS, ROOTFSTYPE, IP
correponds to the rootdelay, rootflags, rootfstype or ip boot option.
.TP
\fB\fI DPKG_ARCH
allows arch specific boot actions.
.TP
\fB\fI blacklist, panic, quiet, resume, noresume, resume_offset
set according relevant boot option.
.TP
\fB\fI break
Useful for manual intervention during setup and coding an boot script.
.TP
\fB\fI init
passes the path to init(8) usually /sbin/init.
.TP
\fB\fI readonly
is the default for mounting the root corresponds to the ro bootarg.
Overriden by rw bootarg.
.TP
\fB\fI rootmnt
is the path where root gets mounted usualy /root.
.TP
\fB\fI debug
indicates that a debug log is captured for further investigation.
.SH DEBUG
It is easy to check the generated initramfs for its content. One may need
to double-check if it contains the relevant binaries, libs or modules:
.RS
.nf
mkdir tmp/initramfs
cd tmp/initramfs
gunzip \-c /boot/initrd.img\-2.6.18\-1\-686 | \\
cpio \-i \-d \-H newc \-\-no\-absolute\-filenames
.fi
.RE
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.PP
This manual was written by David H\[:a]rdeman <david@hardeman.nu>,
updated by Maximilian Attems <maks@debian.org>.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR mkinitramfs (8),
.IR update-initramfs(8).

View File

@ -0,0 +1,82 @@
.TH INITRAMFS.CONF 5 "2008/12/19" "Linux" "initramfs.conf manual"
.SH NAME
initramfs.conf \- configuration file for mkinitramfs
.SH DESCRIPTION
The behaviour of
.B mkinitramfs
can be modified by its configuration file.
Each line in the file can be a configuration variable, a blank line,
or a comment. The value of an variable is assigned by an statement
of the form: \fIname\fP=[\fIvalue\fP]
Configuration options can be broken out into configuration snippets and
placed in individual files in the /etc/mkinitramfs/conf.d directory. Files
in this directory are always read \fBafter\fP the main configuration file,
so you can override the settings in the main config file without editing it
directly.
.SH GENERAL VARIABLES
.TP
\fB MODULES
Specifies the modules for the initramfs image.
The default setting is \fImost\fP.
\fImost\fP adds all the framebuffer, acpi, file system, ide, sata, scsi and usb drivers.
\fIdep\fP tries to guess which modules are necessary for the running box.
\fInetboot\fP adds the base modules, network modules, but skips block devices.
\fIlist\fP includes only modules from the additional modules list to load them
early.
.TP
\fB BUSYBOX
Include busybox utilities for the boot scripts.
If set to 'n'
.B mkinitramfs
will build an initramfs without busybox.
Beware that many boot scripts need busybox utilities.
.TP
\fB KEYMAP
If set to 'y', the console keymap will be loaded during the initramfs stage.
The keymap will anyway be loaded by the initscripts later, and the packages
that might need input will normally set this variable automatically, so there
should normally be no need to set this.
.SH NFS VARIABLES
.TP
\fB BOOT
Allows to use an nfs drive as the root of the drive.
The default is to boot from \fIlocal\fP media (hard drive, USB stick).
Set to \fInfs\fP for an NFS root share.
.TP
\fB DEVICE
Specifies the network interface, like eth0.
.TP
\fB ROOT
Allows optional root bootarg hardcoding, when no root bootarg can be passed.
A root bootarg overrides that special setting.
.TP
\fB NFSROOT
Defaults to \fIauto\fP in order to pick up value from DHCP server.
Otherwise you need to specify \fIHOST:MOUNT\fP.
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
Loosely based on mkinitrd.conf by Herbert Xu.
.SH SEE ALSO
.BR
.IR initramfs-tools (8),
.IR mkinitramfs (8),
.IR update-initramfs (8).

View File

@ -0,0 +1,305 @@
#!/bin/sh
umask 0022
export PATH='/usr/bin:/sbin:/bin'
# Defaults
keep="n"
CONFDIR="/etc/initramfs-tools"
verbose="n"
errors_to="2>/dev/null"
BUSYBOXDIR="/usr/lib/busybox-initramfs/bin"
OPTIONS=`getopt -o d:ko:r:v -n "$0" -- "$@"`
# Check for non-GNU getopt
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$OPTIONS"
while true; do
case "$1" in
-d)
CONFDIR="$2"
shift 2
if [ ! -d "${CONFDIR}" ]; then
echo "${0}: ${CONFDIR}: Not a directory" >&2
exit 1
fi
;;
-o)
outfile="$2"
shift 2
;;
-k)
keep="y"
shift
;;
-r)
ROOT="$2"
shift 2
;;
-v)
verbose="y"
shift
;;
--)
shift
break
;;
*)
echo "Internal error!" >&2
exit 1
;;
esac
done
# For dependency ordered mkinitramfs hook scripts.
. /usr/share/initramfs-tools/scripts/functions
. /usr/share/initramfs-tools/hook-functions
. "${CONFDIR}/initramfs.conf"
EXTRA_CONF=''
for i in /usr/share/initramfs-tools/conf.d/* ${CONFDIR}/conf.d/*; do
EXTRA_CONF="${EXTRA_CONF} $(basename $i \
| grep '^[[:alnum:]][[:alnum:]\._-]*$' | grep -v '\.dpkg-.*$')";
done
# FIXME: deprecated those settings on mkinitramfs run
# these conf dirs are for boot scripts and land on initramfs
for i in ${EXTRA_CONF}; do
if [ -e ${CONFDIR}/conf.d/${i} ]; then
. ${CONFDIR}/conf.d/${i}
elif [ -e /usr/share/initramfs-tools/conf.d/${i} ]; then
. /usr/share/initramfs-tools/conf.d/${i}
fi
done
# source package confs
for i in /usr/share/initramfs-tools/conf-hooks.d/*; do
if [ -e "${i}" ]; then
. "${i}"
fi
done
if [ -n "${UMASK}" ]; then
umask "${UMASK}"
fi
if [ -z "${outfile}" ]; then
usage
fi
touch "$outfile"
outfile="$(readlink -f "$outfile")"
# And by "version" we really mean path to kernel modules
# This is braindead, and exists to preserve the interface with mkinitrd
if [ ${#} -ne 1 ]; then
version="$(uname -r)"
else
version="${1}"
fi
# Check that we're using a new enough kernel version, first for ourselves,
# then for each of the hooks, which can have a MINKVER variable defined
check_minkver ${version}
check_minkver ${version} /usr/share/initramfs-tools/hooks
check_minkver ${version} ${CONFDIR}/hooks
case "${version}" in
/lib/modules/*/[!/]*)
;;
/lib/modules/[!/]*)
version="${version#/lib/modules/}"
version="${version%%/*}"
;;
esac
case "${version}" in
*/*)
echo "$PROG: ${version} is not a valid kernel version" >&2
exit 1
;;
esac
if [ -d "${outfile}" ]; then
echo "${outfile} is a directory"
exit 1
fi
MODULESDIR="/lib/modules/${version}"
if [ ! -e "${MODULESDIR}" ]; then
echo "Cannot find ${MODULESDIR}"
exit 1
fi
if [ ! -e "${MODULESDIR}/modules.dep" ]; then
depmod ${version}
fi
DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1
__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1
DPKG_ARCH=`uname -m`
# Export environment for hook scripts.
#
export MODULESDIR
export version
export CONFDIR
export DESTDIR
export DPKG_ARCH
export verbose
export KEYMAP
export MODULES
# Private, used by 'catenate_cpiogz'.
export __TMPCPIOGZ
for d in bin conf/conf.d etc lib/modules sbin scripts ${MODULESDIR}; do
mkdir -p "${DESTDIR}/${d}"
done
# Copy the modules.order file in
if [ -f "${MODULESDIR}/modules.order" ]; then
cp -p "${MODULESDIR}/modules.order" \
"${DESTDIR}${MODULESDIR}/modules.order"
fi
# MODULES=list case. Always honour.
for x in "${CONFDIR}/modules" /usr/share/initramfs-tools/modules.d/*; do
if [ -f "${x}" ]; then
add_modules_from_file "${x}"
fi
done
# MODULES=most is default
case "${MODULES}" in
dep)
dep_add_modules
;;
most)
auto_add_modules
;;
netboot)
auto_add_modules base
auto_add_modules net
;;
list)
# nothing to add
;;
*)
echo "mkinitramfs: Warning unsupported MODULES setting: ${MODULES}."
echo "mkinitramfs: Falling back to MODULES=most."
auto_add_modules
;;
esac
# Have to do each file, because cpio --dereference doesn't recurse down
# symlinks.
# klibc
ln -s /usr/lib/klibc/bin/* ${DESTDIR}/bin
ln -s /lib/klibc-*.so ${DESTDIR}/lib
rm -f ${DESTDIR}/bin/kinit* ${DESTDIR}/bin/gzip
cp -p /usr/share/initramfs-tools/init ${DESTDIR}/init
# add existant boot scripts
for b in $(cd /usr/share/initramfs-tools/scripts/ && find . \
-regextype posix-extended -regex '.*/[[:alnum:]_.]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "/usr/share/initramfs-tools/scripts/${b}" \
"${DESTDIR}/scripts/$(dirname "${b}")/"
done
for b in $(cd "${CONFDIR}/scripts" && find . \
-regextype posix-extended -regex '.*/[[:alnum:]_.]+$' -type f); do
[ -d "${DESTDIR}/scripts/$(dirname "${b}")" ] \
|| mkdir -p "${DESTDIR}/scripts/$(dirname "${b}")"
cp -p "${CONFDIR}/scripts/${b}" "${DESTDIR}/scripts/$(dirname "${b}")/"
done
echo "DPKG_ARCH=${DPKG_ARCH}" > ${DESTDIR}/conf/arch.conf
cp -p "${CONFDIR}/initramfs.conf" ${DESTDIR}/conf
for i in ${EXTRA_CONF}; do
if [ -e "${CONFDIR}/conf.d/${i}" ]; then
copy_exec "${CONFDIR}/conf.d/${i}" /conf/conf.d
elif [ -e "/usr/share/initramfs-tools/conf.d/${i}" ]; then
copy_exec "/usr/share/initramfs-tools/conf.d/${i}" /conf/conf.d
fi
done
# ROOT hardcoding
if [ -n "${ROOT}" ]; then
echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
fi
# Busybox
if [ "${BUSYBOX}" = "n" ] || [ ! -e ${BUSYBOXDIR}/busybox ]; then
# those root need busybox
eval "$(mount | awk '/ \/ / {print "r_dev=" $1; exit}')"
if [ "${r_dev#/dev/mapper/}" != "${r_dev}" ]; then
echo "Warning: Busybox is required for successful boot!"
fi
else
rm -f ${DESTDIR}/bin/sh
rm -f ${DESTDIR}/bin/busybox
copy_exec ${BUSYBOXDIR}/busybox /bin/busybox
ln -s ${BUSYBOXDIR}/busybox ${DESTDIR}/bin/sh
fi
# Module-init-tools
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/depmod /sbin
copy_exec /sbin/rmmod /sbin
# libblkid
copy_exec /sbin/blkid /sbin
if [ -d /etc/modprobe.d ]; then
mkdir -p "${DESTDIR}/etc/modprobe.d"
cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
fi
run_scripts /usr/share/initramfs-tools/hooks
run_scripts "${CONFDIR}"/hooks
# Apply DSDT to initramfs
if [ -e "${CONFDIR}/DSDT.aml" ]; then
copy_exec "${CONFDIR}/DSDT.aml" /
fi
[ "${verbose}" = y ] && echo "Building cpio ${outfile} initramfs"
(
# work around lack of "set -o pipefail" for the following pipe:
# cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip >"${outfile}" || exit 1
exec 3>&1
eval `
# http://cfaj.freeshell.org/shell/cus-faq-2.html
exec 4>&1 >&3 3>&-
cd "${DESTDIR}"
{
find . 4>&-; echo "ec1=$?;" >&4
} | {
cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4
} | gzip >"${outfile}"
echo "ec3=$?;" >&4
`
if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi
if [ "$ec2" -ne 0 ]; then exit "$ec2"; fi
if [ "$ec3" -ne 0 ]; then exit "$ec3"; fi
) || exit 1
if [ -s "${__TMPCPIOGZ}" ]; then
cat "${__TMPCPIOGZ}" >>"${outfile}" || exit 1
fi
if [ "${keep}" = "y" ]; then
echo "Working files in ${DESTDIR} and overlay in ${__TMPCPIOGZ}"
else
rm -rf "${DESTDIR}"
rm -rf "${__TMPCPIOGZ}"
fi
exit 0

View File

@ -0,0 +1,135 @@
.TH MKINITRAMFS 8 "2008/12/19" "Linux" "mkinitramfs manual"
.SH NAME
mkinitramfs \- low-level tool for generating an initramfs image
.SH SYNOPSIS
.B mkinitramfs
.RB [ \-d
.IR confdir ]
.RB [ \-k ]
.RB \-o
.IR outfile
.RB [ \-r
.IR root ]
.RB [ \-v ]
.RI [ version ]
.B mkinitramfs
.RB [ \-\-supported-host-version=
.IR hversion ]
.B mkinitramfs
.RB [ \-\-supported-target-version=
.IR tversion ]
.SH DESCRIPTION
The
.B mkinitramfs
script generates an initramfs image.
The initramfs is a gzipped cpio archive. The archive can be used on a
different box of the same arch with the corresponding Linux kernel.
.B mkinitramfs
is meant for advanced usage. On your local box
.B update-initramfs
calls
.B mkinitramfs
with the relevant parameters.
.B update-initramfs
keeps sha1sum of generated initramfs. It takes care to generate backups
and eventually runs the bootloader.
At boot time, the kernel unpacks that archive into RAM disk, mounts and
uses it as initial root file system. All finding of the root device
happens in this early userspace.
.SH OPTIONS
.TP
\fB \-d \fI confdir
Set an alternate configuration directory.
.TP
\fB \-k
Keep the temporary directory used to make the image.
.TP
\fB \-o \fI outfile
Write the image to
.IR outfile .
.TP
\fB \-r \fI root
Override the
.B ROOT
setting in
.IR initramfs.conf .
.TP
\fB \-v
Set the verbose mode output.
.TP
\fI version
Set the kernel version of the initramfs image
(defaults to the running kernel).
.TP
\fB\-\-supported-host-version=\fIhversion
This option queries if mkinitramfs can create ramdisks on a running kernel of version
.IR hversion .
.TP
\fB\-\-supported-target-version=\fItversion
This option queries if mkinitramfs can create ramdisks for kernel version
.IR tversion .
.SH FILES
.TP
.I /etc/initramfs-tools/initramfs.conf
The default configuration file for the script. See
.BR initramfs.conf (5)
for a description of the available configuration parameter.
.TP
.I /etc/initramfs-tools/modules
Specified modules will be put in the generated image and loaded when the system boots. The format - one per line - is identical to that of
.I /etc/modules,
which is described in
.BR modules (5).
.TP
.I /etc/initramfs-tools/conf.d
The conf.d directory allows to hardcode bootargs at initramfs build time
via config snippets. This allows to set ROOT or RESUME.
This is especially useful for bootloaders, which do not pass an root bootarg.
.TP
.I /etc/initramfs-tools/DSDT.aml
If this file exists, it will be appended to the initramfs in a way that causes
it to be loaded by ACPI.
.SH EXAMPLES
Create an initramfs for current running kernel:
.PP
.B mkinitramfs -o ~/tmp/initramfs-$(uname -r)
Create an initramfs for specific kernel and keep builddirs:
.PP
.B mkinitramfs -k -o ~/tmp/initramfs-2.6.21-686 2.6.21-686
Debug initramfs creation (check out written logfile)
.PP
.B sh -x mkinitramfs -o ~/tmp/initramfs-$(uname -r) 2> ~/tmp/log
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR update-initramfs (8).

View File

@ -0,0 +1,309 @@
# -*- shell-script -*-
_log_msg()
{
if [ "$quiet" = "y" ]; then return; fi
printf "$@"
}
log_success_msg()
{
_log_msg "Success: $@\n"
}
log_failure_msg()
{
_log_msg "Failure: $@\n"
}
log_warning_msg()
{
_log_msg "Warning: $@\n"
}
log_begin_msg()
{
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TEXT $@"
fi
_log_msg "Begin: $@ ... "
}
log_end_msg()
{
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "SUCCESS ok"
fi
_log_msg "done.\n"
}
panic()
{
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "QUIT"
fi
# Disallow console access
if [ -n "${panic}" ]; then
sleep ${panic}
reboot
fi
modprobe i8042
modprobe atkbd
echo $@
PS1='(initramfs) ' /bin/sh -i </dev/console >/dev/console 2>&1
}
maybe_break()
{
if [ "${break:-}" = "$1" ]; then
panic "Spawning shell within the initramfs"
fi
}
render()
{
eval "echo -n \${$@}"
}
set_initlist()
{
unset initlist
for si_x in ${initdir}/*; do
# skip empty dirs without warning
[ "${si_x}" = "${initdir}/*" ] && return
# only allow variable name chars
case ${si_x#${initdir}/} in
*[![:alnum:]_.]*)
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: not alphanumeric or '_' file"
continue
;;
esac
# skip non executable scripts
if [ ! -x ${si_x} ]; then
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: not executable"
continue
fi
# skip directories
if [ -d ${si_x} ]; then
[ "${verbose}" = "y" ] \
&& echo "$si_x ignored: a directory"
continue
fi
initlist="${initlist} ${si_x#${initdir}/}"
done
}
reduce_satisfied()
{
deplist="$(render array_${1})"
unset tmpdeplist
for rs_y in ${deplist}; do
# only allow variable name chars
case ${rs_y} in
*[![:alnum:]_.]*)
continue
;;
esac
# skip non executable scripts
if [ ! -x ${initdir}/${rs_y} ]; then
continue
fi
# skip directories
if [ -d ${initdir}/${rs_y} ]; then
continue
fi
tmpdeplist="${tmpdeplist} ${rs_y}"
done
deplist=${tmpdeplist}
for rs_x in ${runlist}; do
pop_list_item ${rs_x} ${deplist}
deplist=${tmppop}
done
eval array_${1}=\"${deplist}\"
}
get_prereqs()
{
set_initlist
for gp_x in ${initlist}; do
tmp=$(${initdir}/${gp_x} prereqs)
eval array_${gp_x}=\"${tmp}\"
done
}
count_unsatisfied()
{
set -- ${@}
return ${#}
}
# Removes $1 from initlist
pop_list_item()
{
item=${1}
shift
set -- ${@}
unset tmppop
# Iterate
for pop in ${@}; do
if [ ${pop} = ${item} ]; then
continue
fi
tmppop="${tmppop} ${pop}"
done
}
# This function generates the runlist, so we clear it first.
reduce_prereqs()
{
unset runlist
set -- ${initlist}
i=$#
# Loop until there's no more in the queue to loop through
while [ ${i} -ne 0 ]; do
oldi=${i}
for rp_x in ${initlist}; do
reduce_satisfied ${rp_x}
count_unsatisfied $(render array_${rp_x})
cnt=${?}
if [ ${cnt} -eq 0 ]; then
runlist="${runlist} ${rp_x}"
pop_list_item ${rp_x} ${initlist}
initlist=${tmppop}
i=$((${i} - 1))
fi
done
if [ ${i} -eq ${oldi} ]; then
panic "PANIC: Circular dependancy. Exiting."
fi
done
}
call_scripts()
{
for cs_x in ${runlist}; do
# mkinitramfs verbose output
if [ "${verbose}" = "y" ]; then
echo "Calling hook ${cs_x}"
fi
${initdir}/${cs_x}
# allow boot scripts to modify exported boot paramaters
if [ -e /conf/param.conf ]; then
. /conf/param.conf
fi
done
}
run_scripts()
{
initdir=${1}
[ ! -d ${initdir} ] && return
get_prereqs
reduce_prereqs
call_scripts
}
# Load custom modules first
load_modules()
{
if [ -e /conf/modules ]; then
cat /conf/modules | while read m; do
# Skip empty lines
if [ -z "$m" ]; then
continue
fi
# Skip comments - d?ash removes whitespace prefix
com=$(printf "%.1s" "${m}")
if [ "$com" = "#" ]; then
continue
fi
modprobe $m
done
fi
}
# lilo compatibility
parse_numeric() {
case $1 in
"")
return
;;
/*)
return
;;
[0-9]*:[0-9]*)
minor=${1#*:}
major=${1%:*}
;;
[A-Fa-f0-9]*)
value=$(( 0x${1} ))
minor=$(( ${value} % 256 ))
major=$(( ${value} / 256 ))
;;
*)
return
;;
esac
mknod -m 600 /dev/root b ${major} ${minor}
ROOT=/dev/root
}
configure_networking()
{
# networking already configured thus bail out
[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0
# support ip options see linux sources
# Documentation/filesystems/nfsroot.txt
case ${IP} in
none|off)
# Do nothing
;;
""|on|any)
# Bring up device
ipconfig -t 180 ${DEVICE}
;;
dhcp|bootp|rarp|both)
ipconfig -t 180 -c ${IP} -d ${DEVICE}
;;
*)
ipconfig -t 180 -d $IP
# grab device entry from ip option
NEW_DEVICE=${IP#*:*:*:*:*:*}
if [ "${NEW_DEVICE}" != "${IP}" ]; then
NEW_DEVICE=${NEW_DEVICE%:*}
else
# wrong parse, possibly only a partial string
NEW_DEVICE=
fi
if [ -n "${NEW_DEVICE}" ]; then
DEVICE="${NEW_DEVICE}"
fi
;;
esac
# source ipconfig output
if [ -n "${DEVICE}" ]; then
# source specific bootdevice
. /tmp/net-${DEVICE}.conf
else
# source any interface as not exaclty specified
. /tmp/net-*.conf
fi
}
# Wait for queued kernel/udev events
wait_for_udev()
{
[ -x "$(command -v udevadm)" ] || return 0
udevadm settle ${1:+--timeout=$1}
}

View File

@ -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

View File

@ -0,0 +1,27 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
for x in $(cat /proc/cmdline); do
case ${x} in
all_generic_ide)
modprobe ide-generic
;;
all_generic_ide=*)
if [ ${x#all_generic_ide=} ]; then
modprobe ide-generic
fi
;;
esac
done

View File

@ -0,0 +1,27 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
OPTS="-q"
# Should terminal be in UTF8 mode?
if [ -x /sbin/kbd_mode ]; then
/sbin/kbd_mode -u
OPTS="${OPTS} -u"
fi
# Load custom keymap
if [ -x /sbin/loadkeys -a -r /etc/boottime.kmap.gz ]; then
loadkeys ${OPTS} /etc/boottime.kmap.gz
fi

View File

@ -0,0 +1,135 @@
# Local filesystem mounting -*- shell-script -*-
# Parameter: device node to check
# Echos fstype to stdout
# Return value: indicates if an fs could be recognized
get_fstype ()
{
local FS FSTYPE FSSIZE RET
FS="${1}"
# blkid has a more complete list of file systems,
# but fstype is more robust
eval $(fstype "${FS}" 2> /dev/null)
if [ "$FSTYPE" = "unknown" ] && [ -x /sbin/blkid ]; then
FSTYPE=$(/sbin/blkid -s TYPE -o value "${FS}" 2> /dev/null)
fi
RET=$?
if [ -z "${FSTYPE}" ]; then
FSTYPE="unknown"
fi
echo "${FSTYPE}"
return ${RET}
}
pre_mountroot()
{
wait_for_udev 10
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && log_end_msg
# Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0)
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
return
fi
# If the root device hasn't shown up yet, give it a little while
# to deal with removable devices
if [ ! -e "${ROOT}" ] || ! $(get_fstype "${ROOT}" >/dev/null); then
log_begin_msg "Waiting for root file system"
# Default delay is 180s
if [ -z "${ROOTDELAY}" ]; then
slumber=180
else
slumber=${ROOTDELAY}
fi
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT ${slumber}" || true
fi
slumber=$(( ${slumber} * 10 ))
while [ ! -e "${ROOT}" ] \
|| ! $(get_fstype "${ROOT}" >/dev/null); do
/bin/sleep 0.1
slumber=$(( ${slumber} - 1 ))
[ ${slumber} -gt 0 ] || break
done
if [ ${slumber} -gt 0 ]; then
log_end_msg 0
else
log_end_msg 1 || true
fi
if [ -x /sbin/usplash_write ]; then
/sbin/usplash_write "TIMEOUT 15" || true
fi
fi
# We've given up, but we'll let the user fix matters if they can
while [ ! -e "${ROOT}" ]; do
# give hint about renamed root
case "${ROOT}" in
/dev/hd*)
suffix="${ROOT#/dev/hd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/sd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/sd${suffix}"
fi
;;
/dev/sd*)
suffix="${ROOT#/dev/sd}"
major="${suffix%[[:digit:]]}"
major="${major%[[:digit:]]}"
if [ -d "/sys/block/hd${major}" ]; then
echo "WARNING bootdevice may be renamed. Try root=/dev/hd${suffix}"
fi
;;
esac
echo "Gave up waiting for root device. Common problems:"
echo " - Boot args (cat /proc/cmdline)"
echo " - Check rootdelay= (did the system wait long enough?)"
echo " - Check root= (did the system wait for the right device?)"
echo " - Missing modules (cat /proc/modules; ls /dev)"
panic "ALERT! ${ROOT} does not exist. Dropping to a shell!"
done
}
mountroot()
{
pre_mountroot
# Get the root filesystem type if not set
if [ -z "${ROOTFSTYPE}" ]; then
FSTYPE=$(get_fstype "${ROOT}")
else
FSTYPE=${ROOTFSTYPE}
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
run_scripts /scripts/local-premount
[ "$quiet" != "y" ] && log_end_msg
if [ "${readonly}" = "y" ]; then
roflag=-r
else
roflag=-w
fi
# FIXME This has no error checking
modprobe ${FSTYPE}
# FIXME This has no error checking
# Mount root
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
}

View File

@ -0,0 +1,67 @@
#!/bin/sh
PREREQ=""
prereqs()
{
echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
prereqs
exit 0
;;
esac
if [ -z "${resume}" ]; then
exit 0
fi
case $resume in
LABEL=*)
resume="${resume#LABEL=}"
# support any / in LABEL= path (escape to \x2f)
case "${resume}" in
*[/]*)
if [ -x "$(command -v sed)" ]; then
resume="$(echo ${resume} | sed 's,/,\\x2f,g')"
else
if [ "${resume}" != "${resume#/}" ]; then
resume="\x2f${resume#/}"
fi
if [ "${resume}" != "${resume%/}" ]; then
resume="${resume%/}\x2f"
fi
IFS='/'
newresume=
for s in $resume; do
if [ -z "${newresume}" ]; then
newresume="${s}"
else
newresume="${newresume}\\x2f${s}"
fi
done
unset IFS
resume="${newresume}"
fi
esac
resume="/dev/disk/by-label/${resume}"
;;
UUID=*)
resume="/dev/disk/by-uuid/${resume#UUID=}"
;;
esac
[ ! -e "${resume}" ] && exit 0
[ ! -e /sys/power/resume ] && exit 0
# hardcode path, uswsusp ships an resume binary too
if [ -n "${resume_offset}" ]; then
/bin/resume ${resume} ${resume_offset}
else
/bin/resume ${resume}
fi

View File

@ -0,0 +1,85 @@
# NFS filesystem mounting -*- shell-script -*-
# FIXME This needs error checking
retry_nr=0
# parse nfs bootargs and mount nfs
do_nfsmount()
{
configure_networking
# get nfs root from dhcp
if [ "x${NFSROOT}" = "xauto" ]; then
# check if server ip is part of dhcp root-path
if [ "${ROOTPATH#*:}" = "${ROOTPATH}" ]; then
NFSROOT=${ROOTSERVER}:${ROOTPATH}
else
NFSROOT=${ROOTPATH}
fi
# nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>]
elif [ -n "${NFSROOT}" ]; then
# nfs options are an optional arg
if [ "${NFSROOT#*,}" != "${NFSROOT}" ]; then
NFSOPTS="-o ${NFSROOT#*,}"
fi
NFSROOT=${NFSROOT%%,*}
if [ "${NFSROOT#*:}" = "$NFSROOT" ]; then
NFSROOT=${ROOTSERVER}:${NFSROOT}
fi
fi
if [ -z "${NFSOPTS}" ]; then
NFSOPTS="-o retrans=10"
fi
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-premount"
run_scripts /scripts/nfs-premount
[ "$quiet" != "y" ] && log_end_msg
if [ ${readonly} = y ]; then
roflag="-o ro"
else
roflag="-o rw"
fi
nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt}
}
# NFS root mounting
mountroot()
{
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-top"
run_scripts /scripts/nfs-top
[ "$quiet" != "y" ] && log_end_msg
modprobe nfs
# For DHCP
modprobe af_packet
wait_for_udev 10
# Default delay is around 180s
# FIXME: add usplash_write info
if [ -z "${ROOTDELAY}" ]; then
delay=180
else
delay=${ROOTDELAY}
fi
# loop until nfsmount succeds
while [ ${retry_nr} -lt ${delay} ] && [ ! -e ${rootmnt}${init} ]; do
[ ${retry_nr} -gt 0 ] && \
[ "$quiet" != "y" ] && log_begin_msg "Retrying nfs mount"
do_nfsmount
retry_nr=$(( ${retry_nr} + 1 ))
[ ! -e ${rootmnt}${init} ] && /bin/sleep 1
[ ${retry_nr} -gt 0 ] && [ "$quiet" != "y" ] && log_end_msg
done
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/nfs-bottom"
run_scripts /scripts/nfs-bottom
[ "$quiet" != "y" ] && log_end_msg
}

View File

@ -0,0 +1,546 @@
#!/bin/sh
STATEDIR=/var/lib/initramfs-tools
BOOTDIR=/boot
CONF=/etc/initramfs-tools/update-initramfs.conf
KPKGCONF=/etc/kernel-img.conf
USETRIGGERS=true
mode=""
version=""
[ -r ${CONF} ] && . ${CONF}
usage()
{
if [ -n "${1}" ]; then
printf "${@}\n\n" >&2
fi
cat >&2 << EOF
Usage: ${0} [OPTION]...
Options:
-k [version] Specify kernel version or 'all'
-c Create a new initramfs
-u Update an existing initramfs
-d Remove an existing initramfs
-t Take over a custom initramfs with this one
-b Set alternate boot directory
-v Be verbose
-h This message
EOF
exit 1
}
# chroot check
chrooted()
{
# borrowed from udev's postinst
if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
# the devicenumber/inode pair of / is the same as that of
# /sbin/init's root, so we're *not* in a chroot and hence
# return false.
return 1
fi
return 0
}
mild_panic()
{
if [ -n "${1}" ]; then
printf "${@}\n" >&2
fi
exit 0
}
panic()
{
if [ -n "${1}" ]; then
printf "${@}\n" >&2
fi
exit 1
}
verbose()
{
if [ "${verbose}" = 1 ]; then
printf "${@}\n"
fi
}
version_exists()
{
[ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ]
return $?
}
set_initramfs()
{
initramfs="${BOOTDIR}/initrd.img-${version}"
}
# backup initramfs while running
backup_initramfs()
{
[ ! -r "${initramfs}" ] && return 0
initramfs_bak="${initramfs}.dpkg-bak"
[ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}"
ln -f "${initramfs}" "${initramfs_bak}" \
|| cp -a "${initramfs}" "${initramfs_bak}"
verbose "Keeping ${initramfs_bak}"
}
# keep booted initramfs
backup_booted_initramfs()
{
initramfs_bak="${initramfs}.dpkg-bak"
# first time run thus no backup
[ ! -r "${initramfs_bak}" ] && return 0
# chroot with no /proc
[ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0
# no kept backup wanted
[ "${backup_initramfs}" = "no" ] && rm -f "${initramfs_bak}" && return 0
# no backup yet
if [ ! -r "${initramfs}.bak" ]; then
mv -f ${initramfs_bak} "${initramfs}.bak"
verbose "Backup ${initramfs}.bak"
return 0
fi
# keep booted initramfs
uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime)
if [ -n "$uptime_days" ]; then
boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days})
fi
if [ -n "${boot_initramfs}" ]; then
mv -f "${initramfs_bak}" "${initramfs}.bak"
verbose "Backup ${initramfs}.bak"
return 0
fi
verbose "Removing current backup ${initramfs_bak}"
rm -f ${initramfs_bak}
}
# nuke generated copy
remove_initramfs()
{
[ -z "${initramfs_bak}" ] && return 0
rm -f "${initramfs_bak}"
verbose "Removing ${initramfs_bak}"
}
generate_initramfs()
{
echo "update-initramfs: Generating ${initramfs}"
OPTS="-o"
if [ "${verbose}" = 1 ]; then
OPTS="-v ${OPTS}"
fi
if mkinitramfs ${OPTS} "${initramfs}.new" "${version}"; then
mv -f "${initramfs}.new" "${initramfs}"
set_sha1
else
mkinitramfs_return="$?"
remove_initramfs
rm -f "${initramfs}.new"
if [ "$mkinitramfs_return" = "2" ]; then
# minversion wasn't met, exit 0
exit 0
fi
echo "update-initramfs: failed for ${initramfs}"
exit $mkinitramfs_return
fi
}
# lilo call
run_lilo()
{
# show lilo errors on failure
if ! lilo -t > /dev/null 2>&1 ; then
echo "ERROR lilo fails for new ${initramfs}:"
echo
lilo -t
fi
lilo
}
# check if lilo is on mbr
mbr_check()
{
# try to discover grub|grub2 and be happy
[ -r /boot/grub/grub.cfg ] \
&& groot=$(awk '/^set root=/{print substr($2, 7, 3); exit}' \
/boot/grub/grub.cfg)
[ -r /boot/grub/menu.lst ] \
&& groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
/boot/grub/menu.lst)
[ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
&& dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
[ -n "${dev}" ] && [ -r ${dev} ] \
&& dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
| grep -q GRUB && return 0
# check out lilo.conf for validity
boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf)
[ -z "${boot}" ] && return 0
case ${boot} in
/dev/md/*)
if [ -r /proc/mdstat ]; then
MD=${boot#/dev/md/}
boot="/dev/$(awk "/^md${MD}/{print substr(\$5, 1, 3)}" \
/proc/mdstat)"
fi
;;
/dev/md*)
if [ -r /proc/mdstat ]; then
MD=${boot#/dev/}
boot="/dev/$(awk "/^${MD}/{print substr(\$5, 1, 3)}" \
/proc/mdstat)"
fi
;;
esac
[ ! -r "${boot}" ] && return 0
dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
&& run_lilo && return 0
# no idea which bootloader is used
echo
echo "WARNING: grub and lilo installed."
echo "If you use grub as bootloader everything is fine."
echo "If you use lilo as bootloader you must run lilo!"
echo
}
# Invoke bootloader
run_bootloader()
{
# if both lilo and grub around, figure out if lilo needs to be run
if ( [ -x "$(command -v update-grub)" ] || [ -e /boot/grub/menu.lst ] \
|| [ -e /boot/grub/grub.cfg ] ) \
&& ( [ -e /etc/lilo.conf ] && [ -x /sbin/lilo ] ); then
[ -r "${KPKGCONF}" ] && \
do_b=$(awk '/^do_bootloader/{print $3}' "${KPKGCONF}")
if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \
|| [ "${do_b}" = "YES" ]; then
run_lilo
return 0
elif [ "${do_b}" = "no" ] || [ "${do_b}" = "No" ] \
|| [ "${do_b}" = "NO" ]; then
return 0
fi
# do_bootloader unconfigured
mbr_check
return 0
fi
if [ -r /etc/lilo.conf ] && [ -x /sbin/lilo ]; then
run_lilo
return 0
fi
if [ -x /sbin/elilo ]; then
elilo
return 0
fi
if [ -r /etc/zipl.conf ]; then
zipl
fi
if flash-kernel --supported >/dev/null 2>&1; then
flash-kernel
fi
}
compare_sha1()
{
sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1
return $?
}
# Note that this must overwrite so that updates work.
set_sha1()
{
sha1sum "${initramfs}" > "${STATEDIR}/${version}"
}
delete_sha1()
{
rm -f "${STATEDIR}/${version}"
}
# ro /boot is not modified
ro_boot_check()
{
# check irrelevant inside of a chroot
if [ ! -r /proc/mounts ] || chrooted; then
return 0
fi
boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
&& $2 == "/boot") print "ro"}' /proc/mounts)
if [ -n "${boot_opts}" ]; then
echo "WARNING: /boot is ro mounted."
echo "update-initramfs: Not updating ${initramfs}"
exit 0
fi
}
get_sorted_versions()
{
version_list=""
for gsv_x in "${STATEDIR}"/*; do
gsv_x="$(basename "${gsv_x}")"
if [ "${gsv_x}" = '*' ]; then
return 0
fi
worklist=""
for gsv_i in $version_list; do
xbps-cmpver "${gsv_x}" "${gsv_i}"
if [ $? -eq 0 ] || [ $? -eq 1 ]; then
worklist="${worklist} ${gsv_x} ${gsv_i}"
gsv_x=""
else
worklist="${worklist} ${gsv_i}"
fi
done
if [ "${gsv_x}" != "" ]; then
worklist="${worklist} ${gsv_x}"
fi
version_list="${worklist}"
done
verbose "Available versions: ${version_list}"
}
set_current_version()
{
if [ -f /boot/initrd.img-`uname -r` ]; then
version=`uname -r`
fi
}
set_linked_version()
{
if [ -e /initrd.img ] && [ -L /initrd.img ]; then
linktarget="$(basename "$(readlink /initrd.img)")"
fi
if [ -e /boot/initrd.img ] && [ -L /boot/initrd.img ]; then
linktarget="$(basename "$(readlink /boot/initrd.img)")"
fi
if [ -z "${linktarget}" ]; then
return
fi
version="${linktarget##initrd.img-}"
}
set_highest_version()
{
get_sorted_versions
set -- ${version_list}
version=${1}
}
create()
{
if [ -z "${version}" ]; then
usage "Create mode requires a version argument"
fi
set_initramfs
if [ "${takeover}" = 0 ]; then
if version_exists "${version}"; then
panic "Cannot create version ${version}: already exists"
fi
if [ -e "${initramfs}" ]; then
panic "${initramfs} already exists, cannot create."
fi
fi
generate_initramfs
}
update()
{
if [ "${update_initramfs}" = "no" ]; then
echo "update-initramfs: Not updating initramfs."
exit 0
fi
if [ -z "${version}" ]; then
set_highest_version
fi
if [ -z "${version}" ]; then
set_linked_version
fi
if [ -z "${version}" ]; then
set_current_version
fi
if [ -z "${version}" ]; then
verbose "Nothing to do, exiting."
exit 0
fi
set_initramfs
ro_boot_check
altered_check
backup_initramfs
generate_initramfs
run_bootloader
backup_booted_initramfs
}
delete()
{
if [ -z "${version}" ]; then
usage "Delete mode requires a version argument"
fi
set_initramfs
if [ ! -e "${initramfs}" ]; then
panic "Cannot delete ${initramfs}, doesn't exist."
fi
if ! version_exists "${version}"; then
panic "Cannot delete version ${version}: Not created by this utility."
fi
altered_check
echo "update-initramfs: Deleting ${initramfs}"
delete_sha1
rm -f "${initramfs}"
}
# Check for update mode on existing and modified initramfs
altered_check()
{
# No check on takeover
[ "${takeover}" = 1 ] && return 0
if [ ! -e "${initramfs}" ]; then
mild_panic "${initramfs} does not exist. Cannot update."
fi
if ! compare_sha1; then
echo "update-initramfs: ${initramfs} has been altered." >&2
mild_panic "update-initramfs: Cannot update. Override with -t option."
fi
}
# Defaults
verbose=0
yes=0
# We default to takeover=1 in Ubuntu, but not Debian
takeover=0
##
while getopts "k:cudyvtb:h?" flag; do
case "${flag}" in
k)
version="${OPTARG}"
;;
c)
mode="c"
;;
d)
mode="d"
;;
u)
mode="u"
;;
v)
verbose="1"
;;
y)
yes="1"
;;
t)
takeover="1"
;;
b)
BOOTDIR="${OPTARG}"
if [ ! -d "${BOOTDIR}" ]; then
echo "Error: ${BOOTDIR} is not a directory."
exit 1
fi
;;
h|?)
usage
;;
esac
done
shift $((${OPTIND} - 1))
if [ $# -ne 0 ]; then
echo "Invalid argument for option -k."
usage
fi
# Validate arguments
if [ -z "${mode}" ]; then
usage "You must specify at least one of -c, -u, or -d."
fi
if [ "${version}" = "all" ] \
|| ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then
: FIXME check for --yes, and if not ask are you sure
get_sorted_versions
if [ -z "${version_list}" ]; then
verbose "Nothing to do, exiting."
exit 0
fi
OPTS="-b ${BOOTDIR}"
if [ "${verbose}" = "1" ]; then
OPTS="${OPTS} -v"
fi
if [ "${takeover}" = "1" ]; then
OPTS="${OPTS} -t"
fi
if [ "${yes}" = "1" ]; then
OPTS="${OPTS} -y"
fi
for u_version in ${version_list}; do
# Don't stop if one version doesn't work.
set +e
verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}"
"${0}" -${mode} -k "${u_version}" ${OPTS}
set -e
done
exit 0
fi
case "${mode}" in
c)
create
;;
d)
delete
;;
u)
update
;;
esac

View File

@ -0,0 +1,97 @@
.TH UPDATE-INITRAMFS 8 "2008/12/19" "Linux" "update\-initramfs manual"
.SH NAME
update\-initramfs \- generate an initramfs image
.SH SYNOPSIS
.B update\-initramfs
.RB \-c | \-d | \-u
.RB [ \-k
.IR version ]
.RB [ \-t ]
.RB [ \-v ]
.RB [ \-b ]
.RB [ \-h ]
.SH DESCRIPTION
The
.B update\-initramfs
script manages your initramfs images on your local box.
It keeps track of the existing initramfs archives in /boot.
There are three modes of operation create, update or delete.
You must at least specify one of those modes.
The initramfs is a gzipped cpio archive.
At boot time, the kernel unpacks that archive into RAM disk, mounts and
uses it as initial root file system. All finding of the root device
happens in this early userspace.
.SH OPTIONS
.TP
\fB \-k \fI version
Set the specific kernel version for whom the initramfs will be generated.
For example the output of uname \-r for your currently running kernel.
This argument is optional for update. The default is the latest kernel version.
The use of "all" for the
.I version
string specifies
.B update\-initramfs
to execute the chosen action for all kernel versions, that are already known
to
.B update\-initramfs.
.TP
\fB \-c
This mode creates a new initramfs.
.TP
\fB \-u
This mode updates an existing initramfs.
.TP
\fB \-d
This mode removes an existing initramfs.
.TP
\fB \-t
Allows to take over an custom initramfs with a newer one.
.TP
\fB \-v
This option increases the amount of information you are given during
the chosen action.
.TP
\fB \-b
Set an different bootdir for the image creation.
.TP
\fB \-h
Print a short help page describing the available options in
.B update\-initramfs.
.SH EXAMPLES
Update the initramfs of the newest kernel:
.PP
.B update\-initramfs -u
Create the initramfs for a specific kernel:
.PP
.B update\-initramfs -c -k 2.6.18-1-686
.SH FILES
/etc/initramfs-tools/update-initramfs.conf
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR mkinitramfs (8).

View File

@ -0,0 +1,31 @@
.TH UPDATE-INITRAMFS.CONF 5 "2008/12/19" "Linux" "update-initramfs.conf manual"
.SH NAME
update-initramfs.conf \- configuration file for update-initramfs
.SH DESCRIPTION
The configuration file allows to disable the update action from
.B update-initramfs.
.SH GENERAL VARIABLES
.TP
\fB update_initramfs
Default is \fIyes\fP for running the latest initramfs-tools hooks in the
newest Linux image.
Setting it to \fIall\fP updates any known initramfs.
It is possible to set it to \fIno\fP for remote servers or boxes where
conservative manners needs to be applied. This disables
the \fBupdate_initramfs \-u\fP call.
.TP
\fB backup_initramfs
By default \fBupdate_initramfs\fP keeps an .bak file of the previous initramfs. If set to \fIno\fP the backup initramfs will not be kept.
.SH AUTHOR
The initramfs-tools are written by Maximilian Attems <maks@debian.org>,
Jeff Bailey <jbailey@raspberryginger.com> and numerous others.
.SH SEE ALSO
.BR
.IR initramfs.conf (5),
.IR initramfs-tools (8),
.IR mkinitramfs (8),
.IR update-initramfs (8).

View File

@ -1,265 +0,0 @@
--- scripts/init-top/keymap.orig 2009-08-27 07:25:39.071099923 +0200
+++ scripts/init-top/keymap 2009-08-27 07:25:57.336100046 +0200
@@ -16,12 +16,12 @@ esac
OPTS="-q"
# Should terminal be in UTF8 mode?
-if [ -x /bin/kbd_mode ]; then
- /bin/kbd_mode -u
+if [ -x /sbin/kbd_mode ]; then
+ /sbin/kbd_mode -u
OPTS="${OPTS} -u"
fi
# Load custom keymap
-if [ -x /bin/loadkeys -a -r /etc/boottime.kmap.gz ]; then
+if [ -x /sbin/loadkeys -a -r /etc/boottime.kmap.gz ]; then
loadkeys ${OPTS} /etc/boottime.kmap.gz
fi
--- hook-functions.orig 2009-03-30 11:48:21.000000000 +0200
+++ hook-functions 2009-08-27 08:17:31.726915318 +0200
@@ -231,7 +231,7 @@ dep_add_modules()
# findout root block device + fstype
eval "$(mount | awk '/\/dev\// {if ($3 == "/") {print "root=" $1 "\nFSTYPE=" $5; exit}}')"
if [ "${root}" = "/dev/root" ] ; then
- root="/dev/disk/by-uuid/"$(/lib/udev/vol_id --uuid ${root}) 2>/dev/null
+ root="/dev/disk/by-uuid/"$(/sbin/blkid -s UUID -o value ${root}) 2>/dev/null
fi
root="$(readlink -f ${root})"
@@ -363,11 +363,7 @@ auto_add_modules()
{
case "$1" in
base)
- for x in ehci-hcd ohci-hcd uhci-hcd usbhid hid_a4tech \
- hid_apple hid_belkin hid_bright hid_cherry hid_chicony \
- hid_cypress hid_dell hid_ezkey hid_gyration hid_logitech \
- hid_microsoft hid_monterey hid_petalynx hid_pl hid_samsung \
- hid_sony hid_sunplus hid_tmff hid_zpff usb-storage ext2 \
+ for x in ehci-hcd ohci-hcd uhci-hcd usbhid usb-storage ext2 \
ext3 ext4 ext4dev isofs jfs nfs reiserfs udf xfs af_packet \
atkbd i8042 virtio_pci; do
manual_add_modules "${x}"
@@ -388,10 +384,6 @@ auto_add_modules()
manual_add_modules "${x}"
done
;;
- fb)
- copy_modules_dir kernel/drivers/video
- copy_modules_dir kernel/drivers/char/agp
- ;;
ide)
copy_modules_dir kernel/drivers/ide
;;
@@ -433,7 +425,6 @@ auto_add_modules()
*)
auto_add_modules base
auto_add_modules net
- auto_add_modules fb
auto_add_modules ide
auto_add_modules scsi
auto_add_modules block
@@ -465,16 +456,28 @@ EOF
}
+compare_versions()
+{
+ local curv="$1" minv="$2"
+
+ xbps-cmpver $curv $minv
+ if [ $? -eq 0 ] || [ $? -eq 1 ]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
# minimal supported kernel version
check_minkver()
{
- local curversion initdir DPKG_ARCH minversion cm_x tmp
+ local curversion initdir ARCH minversion cm_x tmp
curversion="${1}"
initdir="${2}"
if [ -z "${initdir}" ]; then
- DPKG_ARCH=$(dpkg --print-installation-architecture)
- case ${DPKG_ARCH} in
+ ARCH=$(uname -m)
+ case ${ARCH} in
ia64|hppa)
minversion="2.6.15"
;;
@@ -482,7 +485,7 @@ check_minkver()
minversion="2.6.12"
;;
esac
- if dpkg --compare-versions "${curversion}" lt "${minversion}"; then
+ if ! compare_versions "${curversion}" "${minversion}"; then
echo "W: kernel ${curversion} too old for initramfs on ${DPKG_ARCH}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
@@ -496,7 +499,7 @@ check_minkver()
minver=$(sed '/^MINKVER=/!d;$!d;s/^MINKVER=//;s/[[:space:]]*$//' "${initdir}/${cm_x}")
if [ -z "${tmp}" ]; then
continue
- elif dpkg --compare-versions "${curversion}" lt "${minver}"; then
+ elif ! compare_versions "${curversion}" "${minver}"; then
echo "W: ${cm_x} hook script requires at least kernel version ${minver}" >&2
echo "W: not generating requested initramfs for kernel ${curversion}" >&2
exit 2
--- update-initramfs.orig 2009-03-30 18:31:44.000000000 +0200
+++ update-initramfs 2009-08-27 08:40:12.227893271 +0200
@@ -8,22 +8,8 @@ USETRIGGERS=true
mode=""
version=""
-set -e
-
[ -r ${CONF} ] && . ${CONF}
-if $USETRIGGERS \
- && [ x"$DPKG_MAINTSCRIPT_PACKAGE" != x ] \
- && [ $# = 1 ] \
- && [ x"$1" = x-u ] \
- && dpkg-trigger --check-supported 2>/dev/null
-then
- if dpkg-trigger --no-await update-initramfs; then
- echo "update-initramfs: deferring update (trigger activated)"
- exit 0
- fi
-fi
-
usage()
{
if [ -n "${1}" ]; then
@@ -314,7 +300,8 @@ get_sorted_versions()
fi
worklist=""
for gsv_i in $version_list; do
- if dpkg --compare-versions "${gsv_x}" '>' "${gsv_i}"; then
+ xbps-cmpver "${gsv_x}" "${gsv_i}"
+ if [ $? -eq 0 ] || [ $? -eq 1 ]; then
worklist="${worklist} ${gsv_x} ${gsv_i}"
gsv_x=""
else
--- scripts/local.orig 2009-03-19 21:16:14.000000000 +0100
+++ scripts/local 2009-10-06 17:45:04.671054874 +0200
@@ -8,11 +8,11 @@ get_fstype ()
local FS FSTYPE FSSIZE RET
FS="${1}"
- # vol_id has a more complete list of file systems,
+ # blkid has a more complete list of file systems,
# but fstype is more robust
eval $(fstype "${FS}" 2> /dev/null)
- if [ "$FSTYPE" = "unknown" ] && [ -x /lib/udev/vol_id ]; then
- FSTYPE=$(/lib/udev/vol_id -t "${FS}" 2> /dev/null)
+ if [ "$FSTYPE" = "unknown" ] && [ -x /sbin/blkid ]; then
+ FSTYPE=$(/sbin/blkid -s TYPE -o value "${FS}" 2> /dev/null)
fi
RET=$?
@@ -26,12 +26,12 @@ get_fstype ()
pre_mountroot()
{
+ wait_for_udev 10
+
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
run_scripts /scripts/local-top
[ "$quiet" != "y" ] && log_end_msg
- wait_for_udev 10
-
# Don't wait for a root device that doesn't have a corresponding
# device in /dev (ie, mtd0)
if [ "${ROOT#/dev}" = "${ROOT}" ]; then
--- init.orig 2009-03-20 10:10:13.000000000 +0100
+++ init 2009-10-08 16:50:24.108954736 +0200
@@ -2,14 +2,29 @@
echo "Loading, please wait..."
+# Create some required busybox symlinks.
+if [ -x /bin/busybox ]; then
+ busybox ln -s /bin/busybox /bin/cut
+ busybox ln -s /bin/busybox /bin/touch
+ busybox ln -s /bin/busybox /bin/tr
+ busybox ln -s /bin/busybox /bin/grep
+ busybox ln -s /bin/busybox /bin/awk
+ busybox ln -s /bin/busybox /bin/tail
+ busybox ln -s /bin/busybox /bin/basename
+ busybox ln -s /bin/busybox /bin/ls
+ busybox ln -s /bin/busybox /bin/cp
+ busybox ln -s /bin/busybox /bin/rm
+ busybox ln -s /bin/busybox /sbin/pkill
+fi
+
[ -d /dev ] || mkdir -m 0755 /dev
[ -d /root ] || mkdir -m 0700 /root
[ -d /sys ] || mkdir /sys
[ -d /proc ] || mkdir /proc
[ -d /tmp ] || mkdir /tmp
mkdir -p /var/lock
-mount -t sysfs -o nodev,noexec,nosuid none /sys
-mount -t proc -o nodev,noexec,nosuid none /proc
+mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
+mount -t proc -o nodev,noexec,nosuid proc /proc
# Note that this only becomes /dev on the real filesystem if udev's scripts
# are used; which they will be, but it's worth pointing out
--- mkinitramfs.orig 2009-04-02 12:25:45.000000000 +0200
+++ mkinitramfs 2009-10-08 16:50:03.681982224 +0200
@@ -8,8 +8,7 @@ keep="n"
CONFDIR="/etc/initramfs-tools"
verbose="n"
errors_to="2>/dev/null"
-# BUSYBOXDIR="/usr/lib/initramfs-tools/bin/"
-BUSYBOXDIR="/bin"
+BUSYBOXDIR="/usr/lib/busybox-initramfs/bin"
OPTIONS=`getopt -o d:ko:r:v -n "$0" -- "$@"`
@@ -141,7 +140,7 @@ fi
DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1
__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1
-DPKG_ARCH=`dpkg --print-installation-architecture`
+DPKG_ARCH=`uname -m`
# Export environment for hook scripts.
#
@@ -238,7 +237,6 @@ fi
# Busybox
if [ "${BUSYBOX}" = "n" ] || [ ! -e ${BUSYBOXDIR}/busybox ]; then
- mv ${DESTDIR}/bin/sh.shared ${DESTDIR}/bin/sh
# those root need busybox
eval "$(mount | awk '/ \/ / {print "r_dev=" $1; exit}')"
if [ "${r_dev#/dev/mapper/}" != "${r_dev}" ]; then
@@ -251,16 +249,17 @@ else
ln -s ${BUSYBOXDIR}/busybox ${DESTDIR}/bin/sh
fi
-# Modutils
+# module-init-tools
copy_exec /sbin/modprobe /sbin
copy_exec /sbin/depmod /sbin
copy_exec /sbin/rmmod /sbin
-mkdir -p "${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
- cp -a /lib/libgcc_s.so.1 "${DESTDIR}/lib/"
+# libblkid
+copy_exec /sbin/blkid /sbin
+
+if [ -d /etc/modprobe.d ]; then
+ mkdir -p "${DESTDIR}/etc/modprobe.d"
+ cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d/"
fi
run_scripts /usr/share/initramfs-tools/hooks

View File

@ -1,10 +1,7 @@
# Template file for 'initramfs-tools'
pkgname=initramfs-tools
version=0.93.2
revision=9
wrksrc=$pkgname
patch_files="$pkgname-xbps.diff"
distfiles="${DEBIAN_SITE}/main/i/${pkgname}/${pkgname}_${version}.tar.gz"
revision=10
build_style=custom-install
short_desc="Tools for generating an initramfs"
maintainer="Juan RP <xtraeme@gmail.com>"
@ -18,9 +15,9 @@ long_desc="
LVM2, LUKS or NFS is also supported. Any boot loader with initrd support is
able to load an initramfs archive."
no_extract=yes
noarch=yes
triggers="initramfs-tools"
keep_dirs="/var/lib/$pkgname"
conf_files="/etc/$pkgname/initramfs.conf /etc/$pkgname/update-initramfs.conf
/etc/$pkgname/modules"
@ -70,40 +67,33 @@ do_install()
install -d $DESTDIR/var/lib/$pkgname
# /etc config files
install -m 644 $wrksrc/conf/initramfs.conf $etcdir
install -m 644 $wrksrc/conf/update-initramfs.conf $etcdir
install -m 644 $FILESDIR/conf/initramfs.conf $etcdir
install -m 644 $FILESDIR/conf/update-initramfs.conf $etcdir
# Data
install -m 755 $wrksrc/init $DESTDIR/usr/share/$pkgname
install -m 755 $FILESDIR/init $DESTDIR/usr/share/$pkgname
for f in functions local nfs; do
install -m 644 $wrksrc/scripts/$f \
install -m 644 $FILESDIR/scripts/$f \
$DESTDIR/usr/share/$pkgname/scripts
done
install -m 755 $wrksrc/scripts/init-premount/* \
install -m 755 $FILESDIR/scripts/init-premount/* \
$DESTDIR/usr/share/$pkgname/scripts/init-premount
install -m 755 $wrksrc/scripts/init-top/* \
install -m 755 $FILESDIR/scripts/init-top/* \
$DESTDIR/usr/share/$pkgname/scripts/init-top
install -m 755 $wrksrc/scripts/local-premount/* \
install -m 755 $FILESDIR/scripts/local-premount/* \
$DESTDIR/usr/share/$pkgname/scripts/local-premount
install -m 755 $wrksrc/hooks/* $DESTDIR/usr/share/$pkgname/hooks
install -m 644 $wrksrc/hook-functions $DESTDIR/usr/share/$pkgname
install -m 644 $wrksrc/conf/modules $etcdir
install -m 755 $FILESDIR/hooks/* $DESTDIR/usr/share/$pkgname/hooks
install -m 644 $FILESDIR/hook-functions $DESTDIR/usr/share/$pkgname
install -m 644 $FILESDIR/conf/modules $etcdir
# Examples
install -m 644 $wrksrc/docs/* $DESTDIR/usr/share/doc/$pkgname/examples
install -m 644 $FILESDIR/docs/* $DESTDIR/usr/share/doc/$pkgname/examples
# Manpages
install -m 644 $wrksrc/*.5 $DESTDIR/usr/share/man/man5
install -m 644 $wrksrc/*.8 $DESTDIR/usr/share/man/man8
rm -f ${DESTDIR}/usr/share/man/man8/mkinitramfs-kpkg.8
install -m 644 $FILESDIR/*.5 $DESTDIR/usr/share/man/man5
install -m 644 $FILESDIR/*.8 $DESTDIR/usr/share/man/man8
# Scripts
install -m 755 $wrksrc/mkinitramfs $DESTDIR/usr/sbin
install -m 755 $wrksrc/update-initramfs $DESTDIR/usr/sbin
# Remove unneeded stuff.
rm -f $DESTDIR/usr/share/$pkgname/hooks/kernelextras
rm -f $DESTDIR/usr/share/$pkgname/hooks/thermal
rm -f $DESTDIR/usr/share/$pkgname/scripts/init-top/framebuffer
rm -f $DESTDIR/usr/share/$pkgname/scripts/init-premount/thermal
install -m 755 $FILESDIR/mkinitramfs $DESTDIR/usr/sbin
install -m 755 $FILESDIR/update-initramfs $DESTDIR/usr/sbin
}