view root-filesystem.sh @ 1532:a2e491cd0800

Fix source/target confusion that bites Fedora host = target builds. The gcc build exports an LD_LIBRARY_PATH full of target libraries and then calls /bin/sh in the configure stage. If you configure before building, this doesn't cause a problem because the libraries aren't there yet, but c++ has dependencies that trigger a C build before running configuration even if you reorder the steps. On ubuntu this doesn't cause a problem because /bin/sh doesn't link against anything in this LD_LIBRARY PATH, and when building a different architecture the foreign binaries are ignored by the dynamic linker. But on Fedora when host == target /bin/sh links against libgcc_s.so.1 which is in LD_LIBRARY_PATH linked against libc.so.0 which isn't installed on the host, and the attempt to run the shell dies saying it can't find uClibc. The fix is to override the make variable SHELL = sh so it calls ash out of build/host.
author Rob Landley <rob@landley.net>
date Thu, 16 Aug 2012 21:59:27 -0500
parents f1d2afdf2034
children
line wrap: on
line source

#!/bin/bash

# Combine the output of simple-root-filesystem and native-compiler.

. sources/include.sh || exit 1

load_target "$1"

check_for_base_arch || exit 0

[ ! -d "$BUILD/simple-root-filesystem-$ARCH" ] &&
  echo "No $BUILD/simple-root-filesystem-$ARCH" >&2 &&
  exit 1

[ ! -d "$BUILD/native-compiler-$ARCH" ] &&
  echo "No $BUILD/native-compiler-$ARCH" >&2 &&
  exit 1

cp -al "$BUILD/simple-root-filesystem-$ARCH/." "$STAGE_DIR" || dienow

# Remove shared libraries copied from cross compiler, and let /bin/sh point
# to bash out of native compiler instead of busybox shell.

rm -rf "$BUILD/root-filesystem-$ARCH/"{usr/lib,bin/sh} 2>/dev/null

# Copy native compiler, but do not overwrite existing files (which could
# do bad things to busybox).

[ -z "$ROOT_NODIRS" ] && USRDIR="/usr" || USRDIR=""
yes 'n' | cp -ial "$BUILD/native-compiler-$ARCH/." \
  "$BUILD/root-filesystem-$ARCH$USRDIR" 2>/dev/null || dienow

# Strip everything again, just to be sure.

if [ -z "$SKIP_STRIP" ]
then
  "${ARCH}-strip" --strip-unneeded "$STAGE_DIR"/lib/*.so
  "${ARCH}-strip" "$STAGE_DIR"/{bin/*,sbin/*}
fi

create_stage_tarball