view more/chroot-splice.sh @ 1362:9d7c03814309

Move root's home directory to /home/root, which is A) known writeable space so dropbear can have a .ssh directory if it needs one, B) frees up /root to be a virtfs mount point of the host's root filesystem.
author Rob Landley <rob@landley.net>
date Tue, 24 May 2011 02:06:22 -0500
parents 095c9652525e
children aabc07905de3
line wrap: on
line source

#!/bin/bash

# Combine a root filesystem directory and a control image into an $ARCH-specific
# chroot containing native build control files, suitable for chrooting into.

if [ $# -ne 2 ]
then
  echo 'usage: ./control-in-chroot.sh $ARCH $CONTROL_IMAGE' >&2
  exit 1
fi

# Make sure prerequisites exist

for i in "build/root-filesystem-$1" "build/control-images/$2"
do
  if [ ! -d "$i" ]
  then
    echo "No $i" >&2
    exit 1
  fi
done

# Zap old stuff (if any)

if [ -e "build/chroot-$1-$2" ]
then
  more/zapchroot.sh "build/chroot-$1-$2" &&
  rm -rf "build/chroot-$1-$2" ||
    exit 1
fi

# Copy root filesystem and splice in control image
cp -la "build/root-filesystem-$1" "build/chroot-$1-$2" &&
cp -la "build/control-images/$2/." "build/chroot-$1-$2/mnt/." ||
  exit 1

# Tar it up

# Output some usage hints

echo "export CPUS=1 HOST=$1 && cd /home && /mnt/init" &&
echo "sudo chroot build/chroot-$1-$2" "/sbin/init.sh"