view sources/ @ 1529:90da269bc09c

Minor cleanup and remove hardlinking for chroot-splice: it's slower and uses more disk space but doesn't damage external copy if something goes wrong.
author Rob Landley <>
date Sun, 10 Jun 2012 20:34:04 -0500
parents 8e98296410f3
children e2f722cc97a6
line wrap: on
line source

#!/bin/echo "This file is sourced, not run"

if ! already_included_this 2>/dev/null
alias already_included_this=true

# Set up all the environment variables and functions for a build stage.
# This file is sourced, not run.

# Include config and source shell function files.

[ -e config ] && source config

source sources/
source sources/
source sources/

# Avoid trouble from unexpected environment settings

[ -z "$NO_SANITIZE_ENVIRONMENT" ] && sanitize_environment

# List of fallback mirrors to download package source from


# Where are our working directories?

export_if_blank TOP=`pwd`
export_if_blank SOURCES="$TOP/sources"
export_if_blank SRCDIR="$TOP/packages"
export_if_blank PATCHDIR="$SOURCES/patches"
export_if_blank BUILD="$TOP/build"
export_if_blank SRCTREE="$BUILD/packages"
export_if_blank HOSTTOOLS="$BUILD/host"
export_if_blank WRAPDIR="$BUILD/wrapdir"

# Set a default non-arch

export WORK="${BUILD}/host-temp"
export ARCH_NAME=host

# What host compiler should we use?

export_if_blank CC=cc

# How many processors should make -j use?

MEMTOTAL="$(awk '/MemTotal:/{print $2}' /proc/meminfo)"
if [ -z "$CPUS" ]
  export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
  [ "$CPUS" -lt 1 ] && CPUS=1

  # If we're not using hyper-threading, and there's plenty of memory,
  # use 50% more CPUS than we actually have to keep system busy

  [ -z "$(cat /proc/cpuinfo | grep '^flags' | head -n 1 | grep -w ht)" ] &&
    [ $(($CPUS*512*1024)) -le $MEMTOTAL ] &&

export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`
[ ! -z "$BUILD_VERBOSE" ] && VERBOSITY="V=1"

export_if_blank BUILD_STATIC=busybox,binutils,gcc-core,gcc-g++,make

# Adjust $PATH

# If set up a wrapper directory, adjust $PATH again.

export PATH
if [ -z "$OLDPATH" ]
  export OLDPATH="$PATH"
  [ -f "$HOSTTOOLS/busybox" ] &&
    PATH="$(hosttools_path)" ||

  if [ -f "$WRAPDIR/wrappy" ]
    mkdir -p "$BUILD/logs"
    [ $? -ne 0 ] && echo "Bad $WRAPDIR" >&2 && dienow
    export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.$ARCH_NAME.early"

# Create files with known permissions
umask 022

# Tell bash not to cache the $PATH because we modify it.  (Without this, bash
# won't find new executables added after startup.)
set +h

# Disable internationalization so sort and sed and such can cope with ASCII.

export LC_ALL=C

fi # already_included_this