view @ 1217:1a24dc2bb3cb

Make sure PATH and CONSOLE are properly exported even when kernel command line doesn't provide the right data.
author Rob Landley <>
date Sat, 21 Aug 2010 01:33:02 -0500
parents 99c49806ea6d
children 6a4968ae5ac8
line wrap: on
line source


# 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/ || exit 1
read_arch_dir "$1"
check_for_base_arch || exit 0
check_prerequisite "${ARCH}-cc"

# Announce start of stage.

echo "=== Building $STAGE_NAME"

# Determine which directory layout we're using

if [ -z "$ROOT_NODIRS" ]
  mkdir -p "$STAGE_DIR"/{tmp,proc,sys,dev,home,mnt} &&
  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
    mkdir -p "$STAGE_DIR/usr/$i" &&
    ln -s "usr/$i" "$STAGE_DIR/$i" || dienow

  mkdir -p "$STAGE_DIR/bin" || dienow

# Copy qemu setup script and so on.

cp -r "${SOURCES}/root-filesystem/." "$STAGE_DIR/" &&
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" ]
  cd "$TOP"
  cp -r "$SIMPLE_ROOT_OVERLAY/." "$STAGE_DIR/" || dienow

# Build busybox and toybox

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.

${ARCH}-cc "$SOURCES/toys/oneit.c" -Os $CFLAGS -o "$STAGE_DIR/sbin/oneit" ||

# 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 ]
  "${ARCH}-cc" "${SOURCES}/toys/hello.c" -Os $CFLAGS -static -o "$STAGE_DIR/bin/hello-static" || dienow

# Do we need shared libraries?

if [ "$BUILD_STATIC" != all ]
  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

# Clean up and package the result

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


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