Browse Source

* introduced early target, a proof of concept for an initrd target

(working only on udev branch)


git-svn-id: svn://svn.opensde.net/opensde/opensde/trunk@21400 10447126-35f2-4685-b0cf-6dd780d3921f
misl/sde-wrapper
Alejandro Mery 17 years ago
parent
commit
e81db99a4e
12 changed files with 682 additions and 0 deletions
  1. +79
    -0
      target/early/build-initramfs.in
  2. +23
    -0
      target/early/build.sh
  3. +73
    -0
      target/early/busybox.config
  4. +36
    -0
      target/early/config.in
  5. +205
    -0
      target/early/initrd/etc_modprobe.conf.txt
  6. +124
    -0
      target/early/initrd/init.exec
  7. +18
    -0
      target/early/initrd/sbin_bb-modprobe.exec
  8. +18
    -0
      target/early/initrd/sbin_modprobe.exec
  9. +27
    -0
      target/early/initrd/sbin_start-lvm.exec
  10. +28
    -0
      target/early/initrd/sbin_start-raid.exec
  11. +24
    -0
      target/early/initrd/sbin_vc-spawn.exec
  12. +27
    -0
      target/early/pkgsel

+ 79
- 0
target/early/build-initramfs.in

@ -0,0 +1,79 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/build-initramfs.in
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
INITRD_POSTFLIST_HOOK='early_adjust_initrd'
# flatten
ln -s . ${initrddir}/usr
# don't break /tmp when flattening
INITRD_FLIST_PATTERN="$INITRD_FLIST_PATTERN -e '/ usr\/tmp/d;'"
INITRD_EMPTY_PATTERN="-e '/\.\/rootfs/d;'"
initrd_flist_install_filter() {
local root="build/${SDECFG_ID}/"
case "$1" in
hotplug2)
cp "$root/sbin/hotplug2-modwrap" "$initrddir/sbin/"
;;
strace)
cp "$root/usr/bin/strace" "$initrddir/bin/"
;;
sysfiles)
for x in etc/{,SDE-}VERSION etc/{passwd,group} etc/rc.d/functions{,-ansi,-std}.in; do
cp "$root/$x" "$initrddir/$x"
done
for x in etc/{fstab,hosts,resolv.conf}; do
touch "$initrddir/$x"
done
;;
*) return 0 ;;
esac
return 1
}
early_adjust_initrd() {
echo_status "Tweaking initrd ..."
for x in var/state/pkgtool var/spool/{locks,mail} \
usr/{doc,info,man,opt,spool} etc/{rc.d/,}init.d usr
do
rm ${initrddir}/$x
done
mkdir "${initrddir}/rootfs"
# HACK: bb's modprobe needs insmod on PATH, but udev clears it
# HACK: additionaly bb's modprobe doesn't handle MODALIAS properly
# HACK: so we use our own wrapper on top of bb's
rm ${initrddir}/sbin/modprobe
for x in $( ls -1 target/$target/initrd/*.exec 2> /dev/null ); do
y="${x##*/}"; y="$( echo ${y%.exec} | tr '_%' '/_' )"
echo_status "injecting $y*"
cp -f "$x" "${initrddir}/$y"
chmod +x "${initrddir}/$y"
done
for x in $( ls -1 target/$target/initrd/*.txt 2> /dev/null ); do
y="${x##*/}"; y="$( echo ${y%.txt} | tr '_%' '/_' )"
echo_status "injecting $y"
cp -f "$x" "${initrddir}/$y"
done
for x in $( ls -1 target/$target/initrd/*.patch 2> /dev/null ); do
echo_status "$(patch -p1 -d "${initrddir}" 2>&1 < $x )"
done
}

+ 23
- 0
target/early/build.sh

@ -0,0 +1,23 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/build.sh
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
pkgloop
# NOTE: I know SDECFG_IMAGE is hardcoded by the target, but I prefer to keep this generic -amery
if [ "$SDECFG_IMAGE" -a -e target/share/$SDECFG_IMAGE/build.sh ]; then
echo_header "Creating output image ..."
. target/share/$SDECFG_IMAGE/build.sh
fi
echo_header "Done."

+ 73
- 0
target/early/busybox.config

@ -0,0 +1,73 @@
X CONFIG_SHOW_USAGE
X CONFIG_FEATURE_EDITING
X CONFIG_FEATURE_TAB_COMPLETION
X CONFIG_FEATURE_EDITING_FANCY_PROMPT
X CONFIG_FEATURE_DEVPTS
X CONFIG_LFS
X CONFIG_INSTALL_NO_USR
X CONFIG_FEATURE_SH_IS_ASH
X CONFIG_ASH
O CONFIG_ASH_ALIAS
O CONFIG_ASH_BUILTIN_ECHO
O CONFIG_ASH_BUILTIN_TEST
O CONFIG_ASH_MAIL
X CONFIG_EXPR
X CONFIG_CAT
X CONFIG_TR
X CONFIG_SEQ
X CONFIG_SLEEP
X CONFIG_CP
X CONFIG_MV
X CONFIG_CUT
X CONFIG_STTY
X CONFIG_FEATURE_PRESERVE_HARDLINKS
X CONFIG_ECHO
X CONFIG_FEATURE_FANCY_ECHO
X CONFIG_LS
X CONFIG_FEATURE_LS_USERNAME
X CONFIG_READLINK
X CONFIG_FEATURE_READLINK_FOLLOW
X CONFIG_LSMOD
X CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT
X CONFIG_MODPROBE
X CONFIG_INSMOD
O CONFIG_FEATURE_2_4_MODULES
X CONFIG_FEATURE_2_6_MODULES
X CONFIG_MKNOD
#util-linux
#X CONFIG_DMESG
#X CONFIG_MOUNT
#X CONFIG_FEATURE_MOUNT_FLAGS
#O CONFIG_FEATURE_MOUNT_FSTAB
#X CONFIG_UMOUNT
#X CONFIG_FEATURE_UMOUNT_ALL
X CONFIG_SWITCH_ROOT
X CONFIG_KILL
X CONFIG_KILLALL
X CONFIG_PIDOF
X CONFIG_PS
X CONFIG_VI
X CONFIG_FIND
X CONFIG_GREP
X CONFIG_MORE
X CONFIG_DU
X CONFIG_DF
X CONFIG_RM
X CONFIG_MKDIR
X CONFIG_REBOOT
X CONFIG_POWEROFF

+ 36
- 0
target/early/config.in

@ -0,0 +1,36 @@
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/config.in
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
#Description: Early User Space (Proof of Concept) - WIP
SDECFGSET_IMAGE='initramfs'
SDECFGSET_INIT='none'
SDECFGSET_CROSSBUILD=1
SDECFGSET_LIBC='uclibc'
SDECFGSET_STATIC=1
SDECFGSET_OPT='size'
SDECFGSET_DISABLE_NLS=1
SDECFGSET_PKG_GCC_CXX=0
SDECFGSET_PKG_GCC_JAVA=0
SDECFGSET_PKG_GCC_F77=0
SDECFGSET_PKG_GCC_OBJC=0
SDECFGSET_PKG_BUSYBOX_SYMLINKS=1
SDECFGSET_PKG_BUSYBOX_DEFCONFIG=0
hack_stages 0- automake autoconf binutils gcc flex libtool ccache
hack_stages -1 device-mapper lvm2 mdadm
hack_stages -1 e2fsprogs reiserfsprogs

+ 205
- 0
target/early/initrd/etc_modprobe.conf.txt

@ -0,0 +1,205 @@
#
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/etc_modprobe.conf.txt
# Copyright (C) 2007 The OpenSDE Project
# Copyright (C) 1998 - 2003 Clifford Wolf
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
#
# See 'man 5 modprobe.conf' for details.
# Host specific aliases
#alias parport_lowlevel parport_pc
#options parport_pc io=0x378 irq=auto
alias /dev/snd/* /dev/snd
alias /dev/sound* snd-pcm-oss snd-mixer-oss snd-seq-oss
#alias /dev/input/js* joydev pcigame analog
#alias /dev/usb/lp0 printer
# ALSA default setup
alias char-major-116-* snd
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss
alias sound-service-1-0 snd-mixer-oss
alias sound-service-1-3 snd-pcm-oss
alias sound-service-1-8 snd-seq-oss
alias sound-service-1-12 snd-pcm-oss
alias /dev/nvidia* nvidia
# Generic aliases
alias /dev/loop loop
alias ppp ppp_generic
alias binfmt-204 binfmt_aout
alias binfmt-263 binfmt_aout
alias binfmt-264 binfmt_aout
alias binfmt-267 binfmt_aout
alias binfmt-387 binfmt_aout
alias binfmt-332 iBCS
alias binfmt--310 binfmt_java
alias block-major-1-* rd
alias block-major-2-* floppy
alias block-major-3-* ide-probe-mod
alias block-major-7-* loop
alias block-major-8-* sd_mod
alias block-major-9-* md
alias block-major-11-* sr_mod
alias block-major-13-* xd
alias block-major-15-* cdu31a
alias block-major-16-* gscd
alias block-major-17-* optcd
alias block-major-18-* sjcd
alias block-major-20-* mcdx
alias block-major-22-* ide-probe-mod
alias block-major-23-* mcd
alias block-major-24-* sonycd535
alias block-major-25-* sbpcd
alias block-major-26-* sbpcd
alias block-major-27-* sbpcd
alias block-major-29-* aztcd
alias block-major-32-* cm206
alias block-major-33-* ide-probe-mod
alias block-major-34-* ide-probe-mod
alias block-major-37-* ide-tape
alias block-major-44-* ftl
alias block-major-46-* pcd
alias block-major-47-* pf
alias block-major-56-* ide-probe-mod
alias block-major-57-* ide-probe-mod
alias block-major-58-* lvm-mod
alias block-major-88-* ide-probe-mod
alias block-major-89-* ide-probe-mod
alias block-major-90-* ide-probe-mod
alias block-major-91-* ide-probe-mod
alias block-major-93-* nftl
alias block-major-97-* pg
alias block-major-113-* viocd
alias char-major-4-* serial
alias char-major-5-* serial
alias char-major-6-* lp
alias char-major-9-* st
alias char-major-10-0 busmouse
alias char-major-10-2 msbusmouse
alias char-major-10-3 atixlmouse
alias char-major-10-130 wdt
alias char-major-10-131 wdt
alias char-major-10-139 openprom
alias char-major-10-144 nvram
alias char-major-10-157 applicom
alias char-major-10-175 agpgart
alias char-major-10-184 microcode
alias char-major-10-200 tun
alias char-major-10-250 hci_vhci
alias char-major-13-* analog
alias char-major-13-0 joydev
alias char-major-13-32 mousedev
alias char-major-14-* soundcore
alias char-major-19-* cyclades
alias char-major-20-* cyclades
alias char-major-21-* sg
alias char-major-22-* pcxx
alias char-major-23-* pcxx
alias char-major-27-* ftape
alias char-major-34-* scc
alias char-major-35-* tclmidi
alias char-major-36-* netlink
alias char-major-37-* ide-tape
alias char-major-48-* riscom8
alias char-major-49-* riscom8
alias char-major-57-* esp
alias char-major-58-* esp
alias char-major-63-* kdebug
alias char-major-90-* mtdchar
alias char-major-96-* pt
alias char-major-99-* ppdev
alias char-major-107-* 3dfx
alias char-major-108-* ppp_generic
alias char-major-109-* lvm-mod
alias char-major-161-* ircomm-tty
alias char-major-171-* raw1394
alias char-major-195-* NVdriver
alias char-major-200-* vxspec
alias char-major-206-* osst
alias char-major-216-* rfcomm
alias dos msdos
alias dummy0 dummy
alias dummy1 dummy
alias eth0 your-card
alias iso9660 isofs
alias md-personality-1 linear
alias md-personality-2 raid0
alias md-personality-3 raid1
alias md-personality-4 raid5
alias md-personality-7 multipath
alias net-pf-1 unix
alias net-pf-2 ipv4
alias net-pf-4 ipx
alias net-pf-5 appletalk
alias net-pf-10 ipv6
alias net-pf-15 af_key
alias net-pf-17 af_packet
alias net-pf-31 bluez
alias netalias-2 ip_alias
alias irlan0 irlan
alias irda-dongle-0 tekram
alias irda-dongle-1 esi
alias irda-dongle-2 actisys
alias irda-dongle-3 actisys
alias irda-dongle-4 girbil
alias irda-dongle-5 litelink
alias irda-dongle-6 airport
alias irda-dongle-7 old_belkin
alias bt-proto-0 l2cap
alias bt-proto-2 sco
alias bt-proto-3 rfcomm
alias bt-proto-4 bnep
alias plip0 plip
alias plip1 plip
alias tunl0 ipip
alias cipcb0 cipcb
alias cipcb1 cipcb
alias cipcb2 cipcb
alias cipcb3 cipcb
alias ppp0 ppp_generic
alias ppp1 ppp_generic
alias slip0 slip
alias slip1 slip
alias tty-ldisc-1 slip
alias tty-ldisc-3 ppp_async
alias tty-ldisc-11 irtty
alias tty-ldisc-14 ppp_synctty
alias tty-ldisc-15 hci_uart
alias ppp-compress-18 ppp_mppe
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate
alias parport_lowlevel parport_pc
alias usbdevfs usbcore
alias xfrm-type-2-50 esp4
alias xfrm-type-2-51 ah4
alias xfrm-type-2-108 ipcomp
alias xfrm-type-10-50 esp6
alias xfrm-type-10-51 ah6
alias xfrm-type-10-108 ipcomp6
alias cipher_null crypto_null
alias digest_null crypto_null
alias compress_null crypto_null
alias sha384 sha512
alias char-major-89-* i2c-dev
alias net-pf-24 pppoe

+ 124
- 0
target/early/initrd/init.exec

@ -0,0 +1,124 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/init.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
modules=
root=
mode=
initrd=/sbin/init
NOCOLOR=
initargs="$*"
# read kernel arguments
[ -e /proc/cmdline ] || mount -n -t proc none /proc
set -- $( cat /proc/cmdline )
for x; do
v="${x#*=}"
case "$x" in
root=*) root="$v" ;;
init=*) init="$v" ;;
rw|ro) mode="$x" ;;
modules=*) modules=$( echo "$v" | tr ',' ' ' ) ;;
nocolor) export NOCOLOR=yes ;;
esac
done
. /etc/rc.d/functions.in
banner "Starting Early User Space environment"
title "Mounting /dev, /proc, /tmp and /sys"
check mount -n -t tmpfs none /dev
check mount -n -t usbfs none /proc/bus/usb
check mount -n -t tmpfs none /tmp
check mount -n -t sysfs none /sys
status
title "Populating /dev"
check cp -a /lib/udev/devices/* /dev
status
[ -x /bin/dmesg ] && /bin/dmesg -n 3
title "Starting udev daemon"
echo "" > /sys/kernel/uevent_helper
check udevd --daemon
status
if [ -x /sbin/modprobe -a -n "$modules" ]; then
title "Preloading requested kernel modules"
for x in $modules; do
echo -n " $x"
check modprobe -q $x
done
status
fi
title "Triggering coldplug"
check udevtrigger
check udevsettle
status
sleep 2
if [ -z "$root" ]; then
echo "No root device defined, mount it on /rootfs and exit to continue."
elif [ ! -e "$root" ]; then
start-raid
start-lvm
fi
if [ -n "$root" ]; then
for x in $( seq 1 10 ); do
[ ! -e "$root" ] || break
sleep 1
done
if [ -e "$root" ]; then
title "Mounting $root"
check mount ${mode:+-o $mode} "$root" /rootfs
status
else
echo "root device ($root) not found on time."
fi
fi
# wait for /sbin/init
while [ ! -x "/rootfs$initrd" ]; do
echo "Please mount root device on /rootfs and exit to continue"
setsid /bin/sh < /dev/vc/1 > /dev/vc/1 2> /dev/vc1
done
title "Stopping udev daemon"
check killall udevd
status
if [ ! -e /rootfs/dev/console ]; then
title "Injecting /dev/console"
check cp -a /dev/console /rootfs/dev/console
status
fi
title "Cleaning the room"
check umount /sys
check umount /tmp
check umount /proc/bus/usb
check umount /proc
check umount /dev
status
exec switch_root /rootfs "$initrd" "$initargs"

+ 18
- 0
target/early/initrd/sbin_bb-modprobe.exec

@ -0,0 +1,18 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/sbin_bb-modprobe.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
export PATH
exec /bin/busybox modprobe "$@"

+ 18
- 0
target/early/initrd/sbin_modprobe.exec

@ -0,0 +1,18 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/sbin_modprobe.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
export MODPROBE_COMMAND=/sbin/bb-modprobe
exec /sbin/hotplug2-modwrap "$@"

+ 27
- 0
target/early/initrd/sbin_start-lvm.exec

@ -0,0 +1,27 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/sbin_start-lvm.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
. /etc/rc.d/functions.in
title "Detecting possible LVM devices"
check lvm vgscan
status
if [ -n "$( lvm vgs 2> /dev/null )" ]; then
title "Activating LVM devices"
modprobe dm_mod
check lvm vgchange -ay
status
fi

+ 28
- 0
target/early/initrd/sbin_start-raid.exec

@ -0,0 +1,28 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/sbin_start-raid.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
. /etc/rc.d/functions.in
if [ ! -s /etc/mdadm.conf ]; then
title "Detecting possible RAID devices"
check mdadm -E --scan /dev/sd* > /etc/mdadm.conf
status
fi
if [ -s /etc/mdadm.conf ]; then
title "Activating RAID devices"
check mdadm -As --auto=yes
status
fi

+ 24
- 0
target/early/initrd/sbin_vc-spawn.exec

@ -0,0 +1,24 @@
#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: target/early/initrd/sbin_vc-spawn.exec
# Copyright (C) 2007 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
if [ $# -eq 0 ]; then
echo "Usage: \${0##*/} <vc> [<command> <arguments>]"
exit 1
else
vc=$1; shift
set -e
( setsid "${@:-/bin/sh}" < /dev/$vc > /dev/$vc 2> /dev/$vc & ) &
echo $!
fi

+ 27
- 0
target/early/pkgsel

@ -0,0 +1,27 @@
O *
X 00-dirtree
X sysfiles
X linux-header
X uclibc
X automake
X autoconf
X gcc
X binutils
X flex
X libtool
X ccache
X busybox
X disktype
X udev
X hotplug2
X device-mapper
X lvm2
X mdadm
X util-linux
X e2fsprogs
X reiserfsprogs

Loading…
Cancel
Save