diff options
| author | Jeremie Koenig <jk@jk.fr.eu.org> | 2010-08-01 13:35:57 +0200 |
|---|---|---|
| committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2010-08-01 13:35:57 +0200 |
| commit | 16c741ccaea1356d29e6d9d0ca93bd3a98c2d934 (patch) | |
| tree | 195cf0476c502a69f7afca3b46b21f0a6e40cc8a /debian/local | |
| parent | 50861e36b4126aebba2ece7ab0bc3b61ff26add8 (diff) | |
Sort out how device and server nodes are created
- debian/patches/makedev_keep_options.patch: Introduces the -k and -K
options to MAKEDEV, respectively to keep active translators running or
leave existing files alone completely.
- debian/patches/makedev_parted_store.patch: MAKEDEV -p will use parted
instead of device stores for disk partitions.
- debian/local/setup-translators: New script installed in /usr/lib/hurd,
uses MAKEDEV's new options to create all the necessary device and
server nodes.
- debian/local/runsystem (hurd-udeb): Uses setup-translators in "minimal
mode" to prepare the initrd when the installer is started. Parted
stores are used to avoid problems when reloading the partition table.
- debian/hurd.postinst: Uses setup-translators to create missing nodes on
upgrades (on initial installs, debootstrap will use the
setup-translators script from the installed hurd package to setup the
devices and servers itself).
Diffstat (limited to 'debian/local')
| -rwxr-xr-x | debian/local/runsystem | 54 | ||||
| -rw-r--r-- | debian/local/setup-translators | 148 |
2 files changed, 153 insertions, 49 deletions
diff --git a/debian/local/runsystem b/debian/local/runsystem index 986fcabe..eb7d8586 100755 --- a/debian/local/runsystem +++ b/debian/local/runsystem @@ -3,64 +3,20 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH -# Usage: foldsubst <pat> xxxx yyyy zzzz ... -# <pat> is substituted for every character of xxxx with sed, the character in -# question being accessible as a '\0' in <pat>, and the result is used as the -# new pattern to handle the remaining arguments. -foldsubst () { - [ "$2" ] || { echo $1; return; } - expanded=$(echo "$2" | sed "s/./ $1/g"); shift 2 - foldsubst "$expanded" $@; -} +# Create a minimal subset of device and server nodes +/usr/lib/hurd/setup-translators -m -k -p -# Verbosely attach a translator. -st () { - echo -n " $1" - settrans -ck /servers/$1 /hurd/$2 -} - -# Verbosely create device nodes, -# after the aguments are filtered through foldsubst. -md () { - pattern=$1; shift - sedrepl=$(echo $pattern | sed -e 's/X/\\0/' -e 's/Y/\\\\0/') - devs=$(foldsubst "$sedrepl" $@) - (cd /dev; ./MAKEDEV $devs) - echo -n " $pattern" -} - - -echo -n "Setting up translators:" -mkdir -p /servers/socket -ln -s 1 /servers/socket/local -ln -s 2 /servers/socket/inet -st socket/1 pflocal -st socket/2 pfinet -st exec exec -st default-pager proxy-defpager /hurd/mach-defpager -echo . - -echo -n "Creating device nodes:" -md 'fd std vcs' -md ttyX 1234 -md ptypX 0123 -md loopX 0123 -md hdX 0123 -md hdXsY 0123 12345678 -echo . - -echo -n "Starting procfs" -settrans -g /proc /hurd/procfs -echo . -echo -n "Starting the Hurd console..." # Touch the first tty so that the Hurd console is certain to pick it # and not some random other tty. sleep 1 touch /dev/tty1 + +echo -n "Starting the Hurd console..." console -d vga -d pc_kbd -c /dev/vcs & sleep 1 + # Switch over exec < /dev/tty1 > /dev/tty1 2>&1 echo "Console started." diff --git a/debian/local/setup-translators b/debian/local/setup-translators new file mode 100644 index 00000000..a865f3ea --- /dev/null +++ b/debian/local/setup-translators @@ -0,0 +1,148 @@ +#!/bin/sh +# Set up device nodes and /servers translators. +# +# Use cases: +# - from d-i's /libexec/runsystem, to create a minimal set of device nodes +# and translators for the installer environment; +# - from debootstrap on initial installation, to create device and server +# nodes before /dev and /servers are firmlinked to the host system. +# - from hurd.postinst, on upgrade, where only non-existant nodes should be +# created, and the other ones should be left alone. + + +PATH=/bin:/sbin:/usr/bin:/usr/sbin +export PATH + +usage () { +cat >&2 <<EOU +Usage: $0 [OPTIONS] +Set up device nodes and /servers translators. + + -k, --keep-active Keep active translators running + -K, --keep-all Don't even set passive translators on existing files + -m, --minimal Create a minimal subset of nodes only + -p, --parted Prefer parted stores for partition devices + +At least one of -k or -K must be given. +EOU +} + +# Parse command-line arguments +REPLACE= +MDFLAGS= +MINIMAL= +while [ $# -gt 0 ]; do + case "$1" in + -k|--keep-active) + MDFLAGS="$MDFLAGS -k" + REPLACE=y + shift;; + -K|--keep-all) + MDFLAGS="$MDFLAGS -K" + REPLACE=n + shift;; + -m|--minimal) + MINIMAL=y + shift;; + -p|--parted) + MDFLAGS="$MDFLAGS -p" + shift;; + *) + usage + exit 1;; + esac +done + +if [ -z "$REPLACE" ]; then + usage + exit 1 +fi + +# Usage: foldsubst <pat> xxxx yyyy zzzz ... +# <pat> is substituted for every character of xxxx with sed, the character in +# question being accessible as a '\0' in <pat>, and the result is used as the +# new pattern to handle the remaining arguments. +foldsubst () { + [ "$2" ] || { echo $1; return; } + expanded=$(echo "$2" | sed "s/./ $1/g"); shift 2 + foldsubst "$expanded" $@; +} + +# Verbosely attach a translator. +st () { + node=$1 + cmdl=$2 + name=${3:-$cmdl} + + echo -n " $name" + if [ "$REPLACE" = y ] || [ ! -e $1 ]; then + # Work around a bug in ext2fs, which crashes if a non-empty + # file is turned into a symlink through settrans, by clearing + # the passive translator first. + settrans -ck $node + settrans -ck $node /hurd/$cmdl + fi +} + +# Verbosely create device nodes, with some help from foldsubst. +md () { + pattern=$1; shift + sedrepl=$(echo $pattern | sed -e 's/X/\\0/' -e 's/Y/\\\\0/') + devs=$(foldsubst "$sedrepl" $@) + + echo -n " $pattern" + /sbin/MAKEDEV $MDFLAGS $devs +} + + +echo -n "Setting up translators:" +cd /servers +mkdir -p socket + +st exec exec +st default-pager proxy-defpager +st socket/1 pflocal +st socket/local 'symlink 1' '(+link)' +st socket/2 pfinet +st socket/inet 'symlink 2' '(+link)' +st /proc procfs + +if [ -z "$MINIMAL" ]; then + st password password + st crash-kill 'crash --kill' crash-kill + st crash-suspend 'crash --suspend' crash-suspend + st crash-dump-core 'crash --dump-core' crash-dump-core + st crash 'symlink crash-kill' crash +fi + +echo . + + +echo -n "Creating device nodes:" +cd /dev + +md fd +md std +md vcs +md hdX 0123 +md hdXsY 0123 12345678 +md sdX 0123 +md sdXsY 0123 12345678 + +if [ "$MINIMAL" ]; then + md loopX 0123 + md ttyX 1234 + md ptypX 0123 +else + md loopX 01234567 + md ttyX 123456 + md ptyp + md ptyq + md comX 0123 + md lprX 0123 + st kbd 'symlink cons/kbd' kbd + st mouse 'symlink cons/mouse' mouse +fi + +echo . + |
