view sources/root-filesystem/sbin/ @ 1828:297a5d07c73b draft

There are some uses of ${ARCH}-cc and ${ARCH}-strip remaining in Below is a patch to replace them with ${CC_PREFIX}. Also I'll first sneak in a small patch to change PS1 in to expand the HOST and CPUS vars.
author Geoff Salmon <>
date Thu, 10 Dec 2015 01:43:42 -0600
parents 8b464e266623
line wrap: on
line source


# Announce version
sed -n 's/PRETTY_NAME="\([^"]*\)"/\1/p' /etc/os-release

export HOME=/home
export PATH=/bin:/sbin

# Mount filesystems
mountpoint -q proc || mount -t proc proc proc
mountpoint -q sys || mount -t sysfs sys sys
mountpoint -q dev || mount -t devtmpfs dev dev || mdev -s
mkdir -p dev/pts
mountpoint -q dev/pts || mount -t devpts dev/pts dev/pts
# /tmp inherited from initmpfs

# If nobody said how many CPUS to use in builds, try to figure it out.
if [ -z "$CPUS" ]
  export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
  [ "$CPUS" -lt 1 ] && CPUS=1
export PS1="($HOST:$CPUS) \w \$ "

# When running under qemu, do some more setup
if [ $$ -eq 1 ]

  # Note that forwards to on the host.

  # Setup networking for QEMU (needs /proc)
  ifconfig eth0
  route add default gw

  # If we have no RTC, try rdate instead:
  [ "$(date +%s)" -lt 1000 ] && rdate # or

  # mount hda on /usr/overlay, hdb on /home, and hdc on /mnt, if available

  [ -b /dev/[hsv]da ] &&
    mkdir -p /usr/overlay && mount /dev/[hsv]da /usr/overlay
  [ -b /dev/[hsv]db ] && mount -o noatime /dev/[hsv]db /home && cd /home
  [ -b /dev/[hsv]dc ] && mount -o ro /dev/[hsv]dc /mnt

  [ -z "$CONSOLE" ] &&
    CONSOLE="$(sed -n 's@.* console=\(/dev/\)*\([^ ]*\).*@\2@p' /proc/cmdline)"

  # Call overlay/init if available
  [ -e /usr/overlay/init ] && . /usr/overlay/init

  [ -z "$HANDOFF" ] && echo Type exit when done. && HANDOFF=/bin/hush
  [ -z "$CONSOLE" ] && CONSOLE=console
  exec /sbin/oneit -c /dev/"$CONSOLE" "$HANDOFF"

# If we're not PID 1, it's probably a chroot.
  [ ! -z "$(grep "default for QEMU" /etc/resolv.conf)" ] &&
    echo "nameserver" > /etc/resolv.conf

  # If we have no RTC, try using ntp to set the clock
  [ "$(date +%s)" -lt 10000000 ] && ntpd -nq -p

  # Switch to a shell with command history.

  echo Type exit when done.
  cd /
  umount ./dev/pts
  umount ./dev
  umount ./sys
  umount ./proc