From f606854113a9736e87420cf49bbb53ad8ee6bbd4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 28 Jan 2014 19:04:32 +0100 Subject: [rfs-stage31] udhcpc in stage 3.1 to get DNS servers etc. early TODO: Patch udhcpc to support searchdomain option (119) --- .../rootfs-stage31/data/bin/activate_sysconfig | 80 ------------------- .../rootfs/rootfs-stage31/data/bin/setup_network | 85 -------------------- .../rootfs/rootfs-stage31/data/bin/setup_stage32 | 48 ------------ .../rootfs-stage31/data/inc/activate_sysconfig | 83 ++++++++++++++++++++ .../rootfs/rootfs-stage31/data/inc/setup_network | 91 ++++++++++++++++++++++ .../rootfs/rootfs-stage31/data/inc/setup_stage32 | 48 ++++++++++++ .../rootfs/rootfs-stage31/data/inc/udhcpc-trigger | 59 ++++++++++++++ remote/rootfs/rootfs-stage31/data/init | 45 ++++++----- remote/rootfs/rootfs-stage31/rootfs-stage31.build | 41 +++++----- remote/rootfs/rootfs-stage31/rootfs-stage31.conf | 44 +++++++---- 10 files changed, 354 insertions(+), 270 deletions(-) delete mode 100755 remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig delete mode 100755 remote/rootfs/rootfs-stage31/data/bin/setup_network delete mode 100755 remote/rootfs/rootfs-stage31/data/bin/setup_stage32 create mode 100755 remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig create mode 100755 remote/rootfs/rootfs-stage31/data/inc/setup_network create mode 100755 remote/rootfs/rootfs-stage31/data/inc/setup_stage32 create mode 100755 remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger diff --git a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig deleted file mode 100755 index 580b23ed..00000000 --- a/remote/rootfs/rootfs-stage31/data/bin/activate_sysconfig +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/ash - -echo "Configuring stage 3.2 ..." - -# first a few variables -CONFIG="${FUTURE_ROOT}/opt/openslx/config" - -# parse kernel command line to determine the base for the URLs -SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") -SLX_BASE_PATH=$(read_from_cmdline "slxbase") - -######################################################################### -# -# This function downloads the config containing environment variables -# -fetch_sysconfig() { - [ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ - && echo "Config already fetched." && return 0 - - download "${SLX_BASE_PATH}/config" "${CONFIG}-remote" || return 1 - - echo "# Config fetched from $URL" >> "$CONFIG" - echo "#_RCONFIG_TAG" >> "$CONFIG" - cat "${CONFIG}-remote" >> "$CONFIG" -} -######################################################################### -# -# This function downloads the config.tgz and unpacks it to $TARGET_PATH -# -fetch_config_files() { - [ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && exit 0 - - download "${SLX_BASE_PATH}/config.tgz" "${CONFIG}.tgz" || return 1 -} - - -######################################################################### -# -# This function updates the downloaded config with the IP information -# received from /bin/setup_network -update_sysconfig() { - # sanity checks - [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } - [ ! -e "${CONFIG}.tgz" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } - - # write IP and SLX_SERVER configuration to $CONFIG -cat >> "$CONFIG" </dev/null - cd "${TEMP_EXTRACT_DIR}" - tar -cp * | tar -xp -C "${FUTURE_ROOT}" -} - - -######################################################################### -# -# MAIN PART -# - -fetch_sysconfig -fetch_config_files -update_sysconfig diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_network b/remote/rootfs/rootfs-stage31/data/bin/setup_network deleted file mode 100755 index 79ae0886..00000000 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_network +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/ash - -echo "Setting up network..." - -echo "Main MAC address is '$MAC'" - -# setup network - -# set up loopback networking -echo "Setting up loopback" -ip link set dev lo up 2>/dev/null -ip addr add 127.0.0.1/8 dev lo 2>/dev/null - -echo "Setting up bridge" -BRIDGE="br0" - -# Following was supposed to prevent scripts from getting confused by multiple interfaces with same MAC - does not work though -## Flip mac address of original interface - this var is not local so init sees the changes too -#MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')" -#ip link set addr "$MAC" "$SLAVE" - -mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d" - -#IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':') -IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#') - -for LINE in $IP_OUT; do - IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}') - IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm - echo "${IFACE} = ${IFMAC}" - - if [ "x$IFMAC" == "x$MAC" ]; then - brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE" - brctl stp "$BRIDGE" 0 - brctl setfd "$BRIDGE" 0.000000000001 - ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE" - ip link set dev "$IFACE" up - brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE" - - # analyze ip information from the kernel command line and put parts - # of it into several variables - if [ -n "$IPINFO" ] ; then - getip () { - local val="$IPINFO:"; i=$(($1 - 1)); - while [ $i -gt 0 ] ; do - val=${val#*:} ; i=$(($i - 1)); - done; - echo $val|sed "s/:.*//"; - } - CLIENTIP="$(getip 1)" - SERVERIP="$(getip 2)" - GATEWAY="$(getip 3)" - SUBNET_MASK="$(getip 4)" - BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)" - [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255" - # we might have an idea of the dns server via preboot - DNS_SERVER="$(getip 5)" - # set static ip address - ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" - ip link set dev "$BRIDGE" up - ip route add default via "$GATEWAY" dev "$BRIDGE" - else - NOIPYET="yes" - fi - fi - # youdev - echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$IFMAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$IFACE\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/70-net-boot-nic-name.rules" - # continue... - IFACE="" -done - -echo -n "Waiting for interface $BRIDGE: " -# Some systems don't have operstate. Seems to be hardware dependent -[ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && sleep 2 -while true; do - # still no operstate? assume up and hope for the best... - [ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && break - # check linkstate - [ "x$(cat "/sys/class/net/${BRIDGE}/operstate")" == "xup" ] && break - # else - echo -n "." - usleep 500000 -done -echo "." - diff --git a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 b/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 deleted file mode 100755 index 4e19fb3a..00000000 --- a/remote/rootfs/rootfs-stage31/data/bin/setup_stage32 +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/ash -# -# This script sets up the stage 3.2. -# - downloads/mounts stage32.sqfs -# - merge it with current rootfs through aufs -# - will not download, if the "nfs=" is used in the -# kernel command line -# -######################################################################### -# -# first check if an NFS-share was given per command line -# -if [ -n "$NFS" ]; then - echo "Mounting stage 3.2 as NFS..." - busybox mount -n -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs \ - || drop_shell "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}." \ - || return 1 - return 0 -fi - -######################################################################### -# -# MAIN PART -# - -echo "Setting up stage 3.2 ..." - -# parse kernel command line to determine the URL of the stage3.2 -SLX_BASE_PATH="$(read_from_cmdline "slxbase")" -STAGE32_TARGET_PATH="/stage32.sqfs" -STAGE32_MOUNT_POINT="/rorootfs" - -# try to download it -download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!" - -# try to mount it at STAGE32_MOUNT_POINT -echo "Mounting stage 3.2 as SquashFS..." -busybox mount -n -t squashfs "$STAGE32_TARGET_PATH" "$STAGE32_MOUNT_POINT" || drop_shell "Problem mounting Squashfs." - -echo "Building aufs ..." -busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || drop_shell "Problem building aufs." -mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp -busybox mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." -FUTURE_ROOT="/mnt" - -# "Delete" addon hook-script in aufs view -touch "/mnt/opt/openslx/uniontmp/.wh.addon-init" - diff --git a/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig new file mode 100755 index 00000000..53487332 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/activate_sysconfig @@ -0,0 +1,83 @@ +#!/bin/ash + +echo "Configuring stage 3.2 ..." + +# first a few variables +CONFIG="${FUTURE_ROOT}/opt/openslx/config" + +# parse kernel command line to determine the base for the URLs +SLX_KCL_SERVERS=$(read_from_cmdline "slxsrv") +SLX_BASE_PATH=$(read_from_cmdline "slxbase") + +######################################################################### +# +# This function downloads the config containing environment variables +# +fetch_sysconfig() { + [ -e "$CONFIG" ] && grep '^#_RCONFIG_TAG$' "$CONFIG" > /dev/null \ + && echo "Config already fetched." && return 0 + + download "${SLX_BASE_PATH}/config" "${CONFIG}-remote" || return 1 + + echo "# Config fetched from $URL" >> "$CONFIG" + echo "#_RCONFIG_TAG" >> "$CONFIG" + cat "${CONFIG}-remote" >> "$CONFIG" +} +######################################################################### +# +# This function downloads the config.tgz and unpacks it to $TARGET_PATH +# +fetch_config_files() { + [ -e "${CONFIG}.tgz" ] && echo "config.tgz already downloaded." && exit 0 + + download "${SLX_BASE_PATH}/config.tgz" "${CONFIG}.tgz" || return 1 +} + + +######################################################################### +# +# This function updates the downloaded config with the IP information +# received from /inc/setup_network +update_sysconfig() { + # sanity checks + [ ! -e "${CONFIG}" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } + [ ! -e "${CONFIG}.tgz" ] && { echo "Cannot update. '$CONFIG' does not exist."; return 1; } + + # write IP and SLX_SERVER configuration to $CONFIG +cat >> "$CONFIG" </dev/null + cd "${TEMP_EXTRACT_DIR}" + tar -cp * | tar -xp -C "${FUTURE_ROOT}" + cd / + rm -rf -- "${TEMP_EXTRACT_DIR}" "${CONFIG}.tgz" +} + + +######################################################################### +# +# MAIN PART +# + +fetch_sysconfig +fetch_config_files +update_sysconfig + diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_network b/remote/rootfs/rootfs-stage31/data/inc/setup_network new file mode 100755 index 00000000..3de48057 --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_network @@ -0,0 +1,91 @@ +#!/bin/ash + +echo "Setting up network..." + +echo "Main MAC address is '$MAC'" + +# setup network + +# set up loopback networking +echo "Setting up loopback" +ip link set dev lo up 2>/dev/null +ip addr add 127.0.0.1/8 dev lo 2>/dev/null + +echo "Setting up bridge" +BRIDGE="br0" + +# Following was supposed to prevent scripts from getting confused by multiple interfaces with same MAC - does not work though +## Flip mac address of original interface - this var is not local so init sees the changes too +#MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')" +#ip link set addr "$MAC" "$SLAVE" + +mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d" + +#IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':') +IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#') + +for LINE in $IP_OUT; do + IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}') + IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm + echo "${IFACE} = ${IFMAC}" + + if [ "x$IFMAC" == "x$MAC" ]; then + brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE" + brctl stp "$BRIDGE" 0 + brctl setfd "$BRIDGE" 0.000000000001 + ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE" + ip link set dev "$IFACE" up + brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE" + + # analyze ip information from the kernel command line and put parts + # of it into several variables + if [ -n "$IPINFO" ] ; then + getip () { + echo "${IPINFO}" | awk -F ':' "{print \$$1}" + } + CLIENTIP="$(getip 1)" + SERVERIP="$(getip 2)" + GATEWAY="$(getip 3)" + SUBNET_MASK="$(getip 4)" + BROADCAST_ADDRESS="$(ipcalc -s -b "$CLIENTIP" "$SUBNET_MASK" | sed s/.*=//)" + [ -z "$BROADCAST_ADDRESS" ] && BROADCAST_ADDRESS="255.255.255.255" + # we might have an idea of the dns server via preboot + DNS_SERVER="$(getip 5)" + # set static ip address + [ -n "$CLIENTIP" ] && ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE" + ip link set dev "$BRIDGE" up + [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE" + else + NOIPYET="yes" + fi + fi + # youdev + echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$IFMAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$IFACE\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/70-net-boot-nic-name.rules" + # continue... + IFACE="" +done + +echo -n "Waiting for interface $BRIDGE: " +# Some systems don't have operstate. Seems to be hardware dependent +[ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && sleep 2 +while true; do + # still no operstate? assume up and hope for the best... + [ ! -e "/sys/class/net/${BRIDGE}/operstate" ] && break + # check linkstate + [ "x$(cat "/sys/class/net/${BRIDGE}/operstate")" == "xup" ] && break + # else + echo -n "." + usleep 500000 +done +echo "." + +# udhcpc +PARAM= +if [ -n "$CLIENTIP" ]; then + PARAM="-r $CLIENTIP" +fi +echo -n "$CLIENTIP" > "/run/firstip" +echo -n "$GATEWAY" > "/run/firstgw" +echo -n "$FUTURE_ROOT" > "/run/future_root" +udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE" + diff --git a/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 new file mode 100755 index 00000000..4e19fb3a --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/setup_stage32 @@ -0,0 +1,48 @@ +#!/bin/ash +# +# This script sets up the stage 3.2. +# - downloads/mounts stage32.sqfs +# - merge it with current rootfs through aufs +# - will not download, if the "nfs=" is used in the +# kernel command line +# +######################################################################### +# +# first check if an NFS-share was given per command line +# +if [ -n "$NFS" ]; then + echo "Mounting stage 3.2 as NFS..." + busybox mount -n -t nfs -o ro,async,nolock ${NFSSERVER}:${NFSPATH} /rorootfs \ + || drop_shell "Problem mounting NFS-Directory from ${NFSSERVER}:${NFSPATH}." \ + || return 1 + return 0 +fi + +######################################################################### +# +# MAIN PART +# + +echo "Setting up stage 3.2 ..." + +# parse kernel command line to determine the URL of the stage3.2 +SLX_BASE_PATH="$(read_from_cmdline "slxbase")" +STAGE32_TARGET_PATH="/stage32.sqfs" +STAGE32_MOUNT_POINT="/rorootfs" + +# try to download it +download "${SLX_BASE_PATH}/stage32.sqfs" "$STAGE32_TARGET_PATH" || drop_shell "Could not download stage32!" + +# try to mount it at STAGE32_MOUNT_POINT +echo "Mounting stage 3.2 as SquashFS..." +busybox mount -n -t squashfs "$STAGE32_TARGET_PATH" "$STAGE32_MOUNT_POINT" || drop_shell "Problem mounting Squashfs." + +echo "Building aufs ..." +busybox mount -n -t aufs -o "br:${FUTURE_ROOT}:${STAGE32_MOUNT_POINT}=ro" none /mnt || drop_shell "Problem building aufs." +mkdir -p /mnt/opt/openslx/uniontmp /mnt/tmp +busybox mount -n --move "$FUTURE_ROOT" /mnt/opt/openslx/uniontmp || drop_shell "Problem moving uniontmp." +FUTURE_ROOT="/mnt" + +# "Delete" addon hook-script in aufs view +touch "/mnt/opt/openslx/uniontmp/.wh.addon-init" + diff --git a/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger b/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger new file mode 100755 index 00000000..7a8eaf0b --- /dev/null +++ b/remote/rootfs/rootfs-stage31/data/inc/udhcpc-trigger @@ -0,0 +1,59 @@ +#!/bin/ash + +exec >> /run/stdout +exec 2>> /run/stderr +set -x + +if [ "x$1" != "xbound" -a "x$1" != "xrenew" ] || [ "x$interface" != "xbr0" ] || [ -z "$ip" ]; then + exit 0 +fi + +# If we already got an IP from KCL, see if it differs, and remove first if so +# We just try to prevent everything from breaking if the DHCP server doesn't +# objey the renew request by the client and hands out a new address +if [ -s "/run/firstip" ]; then + #...some address is already configured... + OLD=$(cat "/run/firstip") + if [ "x${OLD}" != "x${ip}" ]; then + #...it's a different one, reconfigure... + echo "..reconfiguring ${OLD} to ${ip}.." + ip addr del "${OLD}" dev "${interface}" 2>/dev/null + ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}" + fi +else + #...no address configured yet, just add... + echo "..adding ${ip}.." + ip addr add "${ip}/$(ipcalc -s -p "${ip}" "${subnet}" | sed s/.*=//)" dev "${interface}" +fi +echo -n "$ip" > "/run/firstip" + +# Same procedure for default gateway +if [ -n "${router}" ]; then + if [ -s "/run/firstgw" ]; then + OLD=$(cat "/run/firstgw") + if [ "x${OLD}" != "x${router}" ]; then + echo "..reconfiguring default gw from ${OLD} to ${router}.." + ip route del default 2>/dev/null + ip route add default via "$router" + fi + else + ip route add default via "$router" + fi + echo -n "$router" > "/run/firstgw" +fi + +RESOLV=$(cat "/run/future_root") +RESOLV="${RESOLV}/etc/resolv.conf" +rm -f -- "$RESOLV" + +# DNS/domain? +if [ -n "$domain" ]; then + echo "domain $domain" >> "$RESOLV" + echo "search $domain" >> "$RESOLV" +fi +[ -n "$dns" ] && echo "..got DNS.." +for serv in $dns; do + echo "nameserver $serv" >> "$RESOLV" +done +cp "$RESOLV" "/etc/resolv.conf" 2>/dev/null + diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init index ae65d9da..ac058591 100755 --- a/remote/rootfs/rootfs-stage31/data/init +++ b/remote/rootfs/rootfs-stage31/data/init @@ -16,7 +16,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin # import common functions -. /etc/functions.inc +. "/etc/functions.inc" # mount the important standard directories busybox mount -n -t tmpfs -o 'mode=755' run "/run" @@ -32,14 +32,25 @@ mkdir -p "$FUTURE_ROOT/opt/openslx" # let kernel know that mdev is to be used for hotplug echo "/sbin/mdev" > /proc/sys/kernel/hotplug -# read graphic and network adaptor configuration (without proprietary drivers yet) -# TODO: must ugly hack ever... needs to be improved when we add prop drivers -for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do - DRM="$(basename "$DRM")" - DRM="${DRM%.ko}" - echo "Trying to load module $DRM" - modprobe "$DRM" -done +setup_gfx () { + # read graphic and network adaptor configuration (without proprietary drivers yet) + # TODO: most ugly hack ever... needs to be improved when we add prop drivers + for DRM in /lib/modules/*/kernel/drivers/gpu/drm/*.ko /lib/modules/*/kernel/drivers/gpu/drm/*/*.ko; do + DRM="$(basename "$DRM")" + DRM="${DRM%.ko}" + #echo "Trying to load module $DRM" + modprobe "$DRM" 2>/dev/null + done + # start plymouth if activated + #if [ $DEBUG -lt 1 ]; then + # echo "Starting plymouth..." + # # link the theming directory from the config to the current root + # ln -sf "${FUTURE_ROOT}/usr/share" /usr/share + # lymouthd --kernel-command-line="splash" --tty=/dev/tty7 && plymouth show-splash + #fi +} + +setup_gfx & # discover devices mdev -s @@ -70,25 +81,17 @@ done [ $DEBUG -ge 5 ] && drop_shell "Requested Debug Shell: before network." -. "/bin/setup_network" || drop_shell "Error setting up network" +. "/inc/setup_network" || drop_shell "Error setting up network" [ $DEBUG -ge 4 ] && drop_shell "Requested Debug Shell: after network/before configuring." -. "/bin/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" +. "/inc/activate_sysconfig" || drop_shell "Could not source /bin/activate_sysconfig" [ $DEBUG -ge 3 ] && drop_shell "Requested Debug Shell: after network/before configuring." -# start plymouth if activated -#if [ $DEBUG -lt 1 ]; then -# echo "Starting plymouth..." -# # link the theming directory from the config to the current root -# ln -sf "${FUTURE_ROOT}/usr/share" /usr/share -# plymouthd --kernel-command-line="splash" --tty=/dev/tty7 && plymouth show-splash -#fi - [ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32." -. "/bin/setup_stage32" || drop_shell "Problem setting up stage3.2" +. "/inc/setup_stage32" || drop_shell "Problem setting up stage3.2" # copy files needed for stage3.2 to FUTURE_ROOT [ $DEBUG -ge 1 ] && echo "Copying busybox etc. to stage32..." @@ -107,7 +110,7 @@ fi # unmount filesystems for mnt in proc sys run ; do - busybox umount -n "$mnt" + busybox umount -n "$mnt" 2>/dev/null done echo "Switching root...." diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.build b/remote/rootfs/rootfs-stage31/rootfs-stage31.build index b2b66459..82477940 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.build +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.build @@ -15,21 +15,24 @@ build() { get_link_chain "$FILE" >> "$COPYLIST" done + mkdir -p "$MODULE_BUILD_DIR/lib" + find /lib /lib64 /usr/lib /usr/lib64 \( -name "libnss_dns*" -o -name "libresolv*" \) -exec cp {} "$MODULE_BUILD_DIR/lib" \; + tarcopy "$(cat "$COPYLIST" | sort -u)" "$MODULE_BUILD_DIR" } post_copy() { pinfo "Generating rootfs for Stage 3.1 ..." - generate_rootfs + generate_rootfs # copy kernel, modules and firmware - copy_kernel_modules - copy_firmware + copy_kernel_modules + copy_firmware copy_kernel - # when vmwgfx is loaded via modprobe in stage31, this conf file is read, - # enables fbdev support for vmware so that - # fb doesnt break when switching tty's in minilinux running inside vmware + # when vmwgfx is loaded via modprobe in stage31, this conf file is read, + # enables fbdev support for vmware so that + # fb doesnt break when switching tty's in minilinux running inside vmware # TODO: Why isn't this a simple static file in this module's data dir? mkdir -p "$TARGET_BUILD_DIR/etc/modprobe.d" echo "options vmwgfx enable_fbdev=1" > "${TARGET_BUILD_DIR}"/etc/modprobe.d/vmwgfx-fbdev.conf @@ -39,18 +42,18 @@ post_copy() { # helper functions to generate the base rootfs # generate_rootfs() { - # create basic directory structure - mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,run,etc,mnt,sys} \ - || perror "Cannot create basic directory structure in '${TARGET_BUILD_DIR}'" - - # copy device files from running system - cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ - "${TARGET_BUILD_DIR}"/dev || perror "Cannot copy devices from running system" - - # copy libc and ld-linux - tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}" - - # copy required files - tarcopy "${REQUIRED_FILES}" "${TARGET_BUILD_DIR}" + # create basic directory structure + mkdir -p "${TARGET_BUILD_DIR}"/{bin,dev,proc,run,etc,mnt,sys} \ + || perror "Cannot create basic directory structure in '${TARGET_BUILD_DIR}'" + + # copy device files from running system + cp -a /dev/{console,kmsg,mem,null,tty,tty0,tty1,tty9,urandom,zero} \ + "${TARGET_BUILD_DIR}"/dev || perror "Cannot copy devices from running system" + + # copy libc and ld-linux + tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}" + + # copy required files + tarcopy "${REQUIRED_FILES}" "${TARGET_BUILD_DIR}" } diff --git a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf index cd68e75f..02887e69 100644 --- a/remote/rootfs/rootfs-stage31/rootfs-stage31.conf +++ b/remote/rootfs/rootfs-stage31/rootfs-stage31.conf @@ -1,12 +1,15 @@ -REQUIRED_MODULES=" busybox - kernel" -REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko +REQUIRED_MODULES=" + busybox + kernel +" +REQUIRED_KERNEL_MODULES=" + kernel/drivers/video/sis/sisfb.ko kernel/drivers/video/via/viafb.ko - kernel/drivers/acpi/video.ko - kernel/drivers/ssb/ssb.ko + kernel/drivers/acpi/video.ko + kernel/drivers/ssb/ssb.ko kernel/drivers/acpi/button.ko - kernel/drivers/gpu/drm/drm*.ko - kernel/drivers/gpu/drm/*/*.ko + kernel/drivers/gpu/drm/drm*.ko + kernel/drivers/gpu/drm/*/*.ko kernel/drivers/hid/hid-generic.ko kernel/drivers/i2c/algos/i2c-algo-bit.ko kernel/drivers/i2c/i2c-core.ko @@ -45,19 +48,26 @@ REQUIRED_KERNEL_MODULES=" kernel/drivers/video/sis/sisfb.ko kernel/net/802/stp.ko kernel/net/bridge/bridge.ko kernel/ubuntu/aufs/aufs.ko - kernel/fs/aufs/aufs.ko" -REQUIRED_FIRMWARE=" 3com/ - e100/ - matrox/ - r128/ - radeon/ - RTL8192E/ - RTL8192SE/ - rtl_nic/ - tigon/" + kernel/fs/aufs/aufs.ko +" +REQUIRED_FIRMWARE=" + 3com/ + e100/ + matrox/ + r128/ + radeon/ + RTL8192E/ + RTL8192SE/ + rtl_nic/ + tigon/ +" REQUIRED_BINARIES=" grep " +REQUIRED_LIBRARIES=" + libnss_dns + libresolv +" REQUIRED_FILES=" /etc/protocols /etc/services -- cgit v1.2.3-55-g7522