view simple-root-filesystem.sh @ 1477:431d5b4ee537

Switch from busybox defconfig to baseconfig-busybox selecting just what we need, with a config variable to use defconfig instead if you really want that. Busybox defconfig doesn't build on Ubuntu 11.10 because of an app that didn't exist until recently breaking. Busybox keeps ininitely adding more and more stuff (with the Katamari Damacy theme playing), and it becomes more of a portability issue keeping it all working. Plus, most if it should not be in busybox anyway. I've revived my toybox project, and would eventually like to be able to use that here anyway, and a specific set of functionality is easier to replace than a moving target. This is an experimentally determined defconfig good enough to build aboriginal and linux from scratch, plus things like vi and shell history that I obviously missed. I'll probably add more stuff later. If I still want to do static defconfig busybox binaries for each target, I can do them as native builds via hdc.
author Rob Landley <rob@landley.net>
date Tue, 27 Dec 2011 08:58:16 -0600
parents a4673f17b7c0
children b381adcd7968
line wrap: on
line source

#!/bin/bash

# Build a basic busybox+uClibc root filesystem for a given target.

# Requires a cross-compiler (or simple-cross-compiler) in the $PATH or in
# the build directory.  In theory you can supply your own as long as the
# prefix- name is correct.

source sources/include.sh || exit 1
load_target "$1"
check_for_base_arch || exit 0
check_prerequisite "${ARCH}-cc"

# Determine which directory layout we're using

OLD_STAGE_DIR="$STAGE_DIR"
if [ -z "$ROOT_NODIRS" ]
then
  mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt,root} &&
  chmod a+rwxt "$STAGE_DIR/tmp" || dienow

  # Having lots of repeated locations at / and also under /usr is silly, so
  # symlink them together.  (The duplication happened back in the 1970's
  # when Ken and Dennis ran out of space on their first RK05 disk pack and
  # leaked the OS into the disk containing the user home directories.  It's
  # been mindlessly duplicated ever since.)
  for i in bin sbin lib etc
  do
    mkdir -p "$STAGE_DIR/usr/$i" &&
    ln -s "usr/$i" "$STAGE_DIR/$i" || dienow
  done

  STAGE_DIR="$STAGE_DIR/usr"
else
  mkdir -p "$STAGE_DIR/bin" || dienow
fi

# Copy qemu setup script and so on.

cp -r "$SOURCES/root-filesystem/." "$STAGE_DIR/" &&
echo -e "CROSS_TARGET=$CROSS_TARGET\nKARCH=$KARCH" > \
  "$STAGE_DIR/src/host-info" &&
cp "$SRCDIR"/MANIFEST "$STAGE_DIR/src" || dienow

# If user specified different files to put in the root filesystem, add them.
# (This overwrites existing files.)

if [ ! -z "$SIMPLE_ROOT_OVERLAY" ]
then
  cd "$TOP"
  tar -c -C "$SIMPLE_ROOT_OVERLAY" . | tar -x -C "$OLD_STAGE_DIR" || dienow
fi

# Build busybox

build_section busybox
cp "$WORK"/config-busybox "$STAGE_DIR"/src || dienow

# Build the world's simplest init program: spawns one task with a controlling
# TTY, waits (reaping zombies) until it exits, then shuts down the system.

TEMP=
[ "$BUILD_STATIC" == all ] && TEMP=--static
${ARCH}-cc "$SOURCES/toys/oneit.c" -Os $CFLAGS $TEMP \
  -o "$STAGE_DIR/sbin/oneit" || dienow

# Put statically and dynamically linked hello world programs on there for
# test purposes.

"${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -o "$STAGE_DIR/bin/hello-dynamic" || dienow

if [ "$BUILD_STATIC" != none ]
then
  "${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$STAGE_DIR/bin/hello-static" || dienow
fi

# Debug wrapper for use with /usr/src/record-commands.sh

"${ARCH}-cc" "$SOURCES/toys/wrappy.c" -Os $CFLAGS -o "$STAGE_DIR/bin/record-commands-wrapper" || dienow

# Do we need shared libraries?

if [ "$BUILD_STATIC" != all ]
then
  echo Copying compiler libraries...
  mkdir -p "$STAGE_DIR/lib" || dienow
  (path_search \
     "$("$ARCH-cc" --print-search-dirs | sed -n 's/^libraries: =*//p')" \
      "*.so*" 'cp -H "$DIR/$FILE" "$STAGE_DIR/lib/$FILE"' \
      || dienow) | dotprogress

  [ -z "$SKIP_STRIP" ] &&
    "${ARCH}-strip" --strip-unneeded "$STAGE_DIR"/lib/*.so
fi

# Clean up and package the result

[ -z "$SKIP_STRIP" ] &&
  "${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*}

create_stage_tarball

# Color back to normal
echo -e "\e[0mBuild complete"