view common/bootstrap/build-one-package.sh @ 6:dc3d5c66e336

The perl build is crazy, and if you have a /bin/mips it tries to run it to see if it's building on an obsolete OS called "mips" rather than Linux. Except that util-linux-ng does a mips alias for setarch, which runs /bin/sh by default if given no arguments, which sits there awaiting input, and the build hangs. Fix: feed it /dev/null.
author Rob Landley <rob@landley.net>
date Sat, 17 Sep 2011 00:53:33 -0500
parents bcd2e358d57f
children a90ac7ed5d64
line wrap: on
line source

#!/bin/ash

# Yes, ash.  Because neither bash 2 nor hush support -o pipefail

set -o pipefail

source /mnt/functions.sh || exit 1

# build $1

set_titlebar "$1"

# Three types of /mnt/build scripts:
#
# $1.nosrc - no source code in /mnt/build, perform no setup/cleanup.
# $1.sh - source is symlink tree to "/mnt/build/$1".  This is faster and uses
#         less disk space but confuses some packages.
# $1.nolink - source is conventional copy of /mnt/build/$1

if [ ! -e "/mnt/build/$1.nosrc" ]
then
  [ -e "/mnt/build/$1.nolink" ] && LINKTYPE=dp || LINKTYPE=s

  # Snapshot source from /mnt/build/$1 to /home/$1

  cd /home &&
  rm -rf "/home/$1" &&
  cp -${LINKTYPE}fR "/mnt/packages/$1" "$1" &&
  cd "$1" || exit 1

  # Lobotomize config.guess so it won't complain about unknown target types.
  # 99% of packages do not care, but autoconf throws a temper tantrum if
  # the version of autoconf that created this back when the package shipped
  # didn't know what a microblaze or hexagon was.  Repeat after me:
  #   "Autoconf is useless"

  for guess in $(find . -name config.guess)
  do
    rm "$guess" &&
    echo -e "#!/bin/sh\ngcc -dumpmachine" > "$guess" || exit 1
  done
  EXT=sh
else
  EXT=nosrc
fi

# Call package build script

mkdir -p /home/log
time "/mnt/build/$1".* 2>&1 | tee "/home/log/$1.log"
if [ $? -ne 0 ]
then
  echo "$1" died >&2
  exit 1
fi

# Delete copy of source if build succeeded

if [ ! -z "$LINKTYPE" ]
then
  cd /home &&
  rm -rf "$1" &&
  sync || exit 1
fi