Browse Source

[PATCH 40/50] Rearranged dracut script to make it easier to split things out for

master
Victor Lowther 16 years ago committed by Dave Jones
parent
commit
0f86847d63
  1. 55
      dracut

55
dracut

@ -42,6 +42,11 @@ hookdirs="pre-udev pre-mount pre-pivot"
initdir=$(mktemp -d -t initramfs.XXXXXX) initdir=$(mktemp -d -t initramfs.XXXXXX)
trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die. trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.


# Create some directory structure first
for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do
mkdir -p "$initdir/$d";
done

# executables that we have to have # executables that we have to have
exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed" exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /sbin/pidof /bin/sleep /usr/sbin/chroot /bin/echo /bin/cat /bin/sed"
lvmexe="/sbin/lvm" lvmexe="/sbin/lvm"
@ -51,7 +56,7 @@ debugexe="/bin/ls /bin/ln /bin/ps /bin/grep /bin/more /bin/dmesg"
# udev things we care about # udev things we care about
udevexe="/lib/udev/vol_id /lib/udev/console_init" udevexe="/lib/udev/vol_id /lib/udev/console_init"


# install base files # install base executables
for binary in $exe $debugexe $udevexe $lvmexe $cryptexe ; do for binary in $exe $debugexe $udevexe $lvmexe $cryptexe ; do
inst $binary inst $binary
done done
@ -62,6 +67,26 @@ if [[ -f /bin/dash ]]; then
ln -sf /bin/dash "${initdir}/bin/sh" ln -sf /bin/dash "${initdir}/bin/sh"
fi fi


# install our scripts and hooks
inst "$initfile" "/init"
inst "$switchroot" "/sbin/switch_root"
inst "$echoer" "/echoer"
for hookdir in $hookdirs; do
for hook in "$dsrc/$hookdir"/*; do
[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
done
done

# FIXME: hard-coded module list of doom.
[[ $modules ]] || modules="=ata =block =drm dm-crypt aes sha256 cbc"

instmods $modules

# Grab modules for all filesystem types we currently have mounted
while read d mp t rest; do
instmods "$t"
done </proc/mounts

# FIXME: would be nice if we didn't have to know which rules to grab.... # FIXME: would be nice if we didn't have to know which rules to grab....
# ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
# of the rules we want so that we just copy those in would be best # of the rules we want so that we just copy those in would be best
@ -73,6 +98,8 @@ done
# terminfo bits make things work better if you fall into interactive mode # terminfo bits make things work better if you fall into interactive mode
for f in $(find /lib/terminfo -type f) ; do cp --parents $f "$initdir" ; done for f in $(find /lib/terminfo -type f) ; do cp --parents $f "$initdir" ; done


## this stuff should be moved out of the main dracut script

# FIXME: i18n stuff isn't really distro-independent :/ # FIXME: i18n stuff isn't really distro-independent :/
if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then if [[ -f /etc/sysconfig/keyboard || -f /etc/sysconfig/console/default.kmap ]]; then
if [ -f /etc/sysconfig/console/default.kmap ]; then if [ -f /etc/sysconfig/console/default.kmap ]; then
@ -113,31 +140,15 @@ if [ -f /etc/sysconfig/i18n ]; then
[[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP [[ $UNIMAP ]] && inst /lib/kbd/unimaps/$UNIMAP
fi fi


# install our files ## final stuff that has to happen
inst "$initfile" "/init"
inst "$switchroot" "/sbin/switch_root"
inst "$echoer" "/echoer"
for hookdir in $hookdirs; do
for hook in "$dsrc/$hookdir"/*; do
[[ -f $hook ]] && inst "$hook" "/$hookdir/${hook##*/}"
done
done

# and create some directory structure
for d in etc proc sys sysroot dev/pts; do mkdir -p "$initdir/$d"; done
# FIXME: hard-coded module list of doom.
[[ $modules ]] || modules="=ata =block =drm dm-crypt aes sha256 cbc"

instmods $modules

# Grab modules for all filesystem types we currently know about
while read d mp t rest; do
instmods "$t"
done </proc/mounts


# generate module dependencies for the initrd
/sbin/depmod -a -b "$initdir" $kernel || { /sbin/depmod -a -b "$initdir" $kernel || {
error "\"/sbin/depmod -a $kernel\" failed." error "\"/sbin/depmod -a $kernel\" failed."
exit 1 exit 1
} }


# make sure that library links are correct and up to date
ldconfig -r "$initdir"

( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; ) ( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; )

Loading…
Cancel
Save