changeset 1742:50c3a1575288

Split out hdainit.sh from the base root filesystem.
author Rob Landley <rob@landley.net>
date Sun, 22 Feb 2015 16:56:10 -0600
parents 189a1748c8bf
children 10b64f52ad20
files native-compiler.sh sources/root-filesystem/sbin/init.sh sources/toys/hdainit.sh
diffstat 3 files changed, 45 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/native-compiler.sh	Sun Feb 22 16:53:37 2015 -0600
+++ b/native-compiler.sh	Sun Feb 22 16:56:10 2015 -0600
@@ -53,6 +53,7 @@
   build_section make
   build_section bash
   build_section distcc
+  cp "$SOURCES/toys/hdainit.sh" "$STAGE_DIR/../init"
 fi
 
 # Delete some unneeded files and strip everything else
@@ -64,5 +65,4 @@
   "${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*}
 fi
 
-
 create_stage_tarball
--- a/sources/root-filesystem/sbin/init.sh	Sun Feb 22 16:53:37 2015 -0600
+++ b/sources/root-filesystem/sbin/init.sh	Sun Feb 22 16:56:10 2015 -0600
@@ -3,12 +3,13 @@
 export HOME=/home
 export PATH=/bin:/sbin
 
-# Populate /dev
+# 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" ]
@@ -18,7 +19,7 @@
 fi
 export PS1='($HOST:$CPUS) \w \$ '
 
-# If we're running under qemu, do some more setup
+# When running under qemu, do some more setup
 if [ $$ -eq 1 ]
 then
 
@@ -31,58 +32,21 @@
   # If we have no RTC, try rdate instead:
   [ "$(date +%s)" -lt 1000 ] && rdate 10.0.2.2 # or time-b.nist.gov
 
-  mount -t tmpfs /tmp /tmp
+  # mount hda on /usr/overlay, hdb on /home, and hdc on /mnt, if available
 
-  if [ -b /dev/[hsv]da ]
-  then
-    mkdir -p /usr/hda
-    mount /dev/[hsv]da /usr/hda
-    cp -rFs /usr/hda/. /
-  fi
-
-  # If there's a /dev/hdb or /dev/sdb, mount it on home, else tmpfs
-
-  [ -b /dev/[hsv]db ] && HOMEDEV=/dev/[hsv]db
-  if [ ! -z "$HOMEDEV" ]
-  then
-    mount -o noatime $HOMEDEV /home
-  else
-    # Only mount a tmpfs if / isn't writeable.
-    touch /.temp 2>/dev/null
-    [ $? -ne 0 ] && mount -t tmpfs /home /home || rm /.temp
-  fi
-  cd /home
-
-  # If there's a /dev/hdc mount it on /mnt
-
-  [ -b /dev/[hsv]dc ] && MNTDEV=/dev/[hsv]dc
-  [ ! -z "$MNTDEV" ] && mount -o ro $MNTDEV /mnt
+  [ -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/ash
   [ -z "$CONSOLE" ] && CONSOLE=console
-
-  if [ -z "$DISTCC_HOSTS" ]
-  then
-    echo "Not using distcc."
-  else
-    echo "Distcc acceleration enabled."
-    PATH="/usr/distcc:$PATH"
-  fi
-  echo Type exit when done.
-
-  HANDOFF=/bin/ash
-  if [ -e /mnt/init ]
-  then
-    X=xx
-    echo "Press any key for command line..."
-    read -t 3 -n 1 X
-    if [ "$X" == xx ]
-    then
-      echo "Running automated build."
-      HANDOFF=/mnt/init
-    fi
-  fi
   exec /sbin/oneit -c /dev/"$CONSOLE" "$HANDOFF"
 
 # If we're not PID 1, it's probably a chroot.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/toys/hdainit.sh	Sun Feb 22 16:56:10 2015 -0600
@@ -0,0 +1,31 @@
+# splice hda into /
+cp -rFs /usr/overlay/. /
+
+# cleanup copy of _this_ script, and plug gcc so search stops
+
+if [ -z "$DISTCC_HOSTS" ]
+then
+  echo "Not using distcc."
+else
+  echo "Distcc acceleration enabled."
+  PATH="/usr/distcc:$PATH"
+
+  # distcc does realpath() which is a problem because ccwrap won't use
+  # things added to the relocated include directory if you call the one
+  # at the original location.
+  rm /usr/bin/cc &&
+  echo -e "#!/bin/ash\nexec /usr/overlay/usr/bin/cc" > /usr/bin/cc &&
+  chmod +x /usr/bin/cc || exit 1
+fi
+
+if [ -e /mnt/init ]
+then
+  X=xx
+  echo "Press any key for command line..."
+  read -t 3 -n 1 X
+  if [ "$X" == xx ]
+  then
+    echo "Running automated build."
+    HANDOFF=/mnt/init
+  fi
+fi