Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
languagebash
#!/bin/bash

BLD_PARALLEL="4"
WORKDIRWORKSPACE=/export/home/admin;
WORKSPACE=${WORKDIR}/du2;

while read COMP; do
  if [[ "" == "$COMP" ]]; then
    continue
  fi/du2
#STOP_ON_ERROR=1
STOP_ON_ERROR=0
#GCC_COMPILER="gcc-6"
GCC_COMPILER=""

# Build a component: $1 - component name, $2 - stop-on-error flag
function build_component {
  local START_TIME
  local END_TIME
  local BLD_RESULT
  
  BLD_RESULT="/data/repo/du/$COMP$1"
  test -z "$COMP$1" && exit 1
  test -d ${BLD_RESULT} && rm -rf ${BLD_RESULT}

  apt-get update && apt-get upgrade -y || exit 1

#  apt-get
install -y build-essential illumos-dev dpkg-dev gmake || exit 1

  DEB_BUILD_OPTIONS="nocheck notest parallel=${BLD_PARALLEL}"
  export DEB_BUILD_OPTIONS
   test -d ${WORKSPACE}/$COMP$1 && rm -rf ${WORKSPACE}/$COMP
$1
  mkdir -p ${WORKSPACE}/$COMP$1
  cd ${WORKSPACE}/$COMP$1
  START_TIME=$(date +%s)
  echo "====================== $1 ======================"  | tee berror.log
  if [[ $2 -eq 0 ]]; then
    apt-get build-dep -y $COMP $1 >> berror.log || exitreturn 0 2>&1
  #DEB_BUILD_OPTIONS="nocheck notest parallel=4" apt-get source --compile $COMP $1 >> berror.log || return 0 2>&1
  else
    apt-get build-dep -y $1 >> berror.log || return exit1 2>&1
    apt-get source --compile $COMP$1 >> berror.log || return exit1 2>&1
  fi
  END_TIME=$(date +%s)
  printf "%06d %s\n" $(($END_TIME - $START_TIME)) $1 >> ${WORKSPACE}/tmpbt.log
  mkdir -p ${BLD_RESULT}
  cp -ax *.deb ${BLD_RESULT}/ || exit 1
  cp -ax *.changes ${BLD_RESULT}/ || exit 1
  cp -ax *.buildinfo ${BLD_RESULT}/ || exit 1
done <
}

if [[ "$GCC_COMPILER" != "" ]]; then
  echo "====================== Building GCC ======================"
  build_component $GCC_COMPILER 1
  if [[ $? -eq 1 ]]; then
    exit 1
  fi
  dpkg -i $WORKSPACE/$GCC_COMPILER/*.deb
fi

if [[ ! -f $WORKSPACE/build_components ]]; then
  cp /data/repo/pkg/list_component $WORKSPACE/build_components
fi
rm -f tmpbt.log
while read COMP; do
  if [[ "" == "$COMP" ]] || [[ "$GCC_COMPILER" == "$COMP" ]]; then
    continue
  fi
  build_component $COMP $STOP_ON_ERROR
  if [[ $? -eq 1 ]]; then
    exit 1
  fi
done < $WORKSPACE/build_components
sort tmpbt.log > build_components
sed -i 's/^[0-9]* //g' build_components