build.sh wrapper script

まあ、みんな同じようなの作ってるよね。

#!/bin/sh

progname=$0

usage() {
  echo "Usage: ${progname} <machine> <date> <operation>"
  exit 1
}

if [ x"$1" = x ]; then
  usage
fi
target_machine=$1
shift

if [ x"$1" = x ]; then
  usage
fi
build_date=$1
shift

if [ x"$1" = x ]; then
  usage
fi
operation=$1
shift

LANG=C; export LANG
LC_ALL=C; export LC_ALL
LC_CTYPE=C; export LC_CTYPE

if [ `id -u` -ne 0 ]; then
  if [ -x /usr/pkg/bin/sudo ]; then
    sudo_cmd=/usr/pkg/bin/sudo
  else
    build_opt="${build_opt} -U"
  fi
fi

parallel_make=true
while true
do
  if [ $# -eq 0 ]; then
    break
  fi

  opt=$1
  echo ${opt} | fgrep " " > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    opt="\"${opt}\""
  fi
  build_opt="${build_opt} ${opt}"
  if [ "${opt}" = "-x" ]; then
    parallel_make=false
  fi
  shift
done
if [ "${parallel_make}" = "true" ]; then
#  build_opt="${build_opt} -j 2"
fi

${sudo_cmd} time ./build.sh -m ${target_machine} \
  -D /home/snapshot/${build_date}/root/${target_machine} \
  -R /home/snapshot/${build_date}/release \
  -T /usr/local/netbsd-tools/${target_machine} \
  ${build_opt} \
  ${operation} \
  2>&1 | tee makeBuild-${target_machine}.log
retval=$?
exit ${retval}

こんな感じに使う。

./makeBuild.sh hpcarm 20110929 release -x -u -o -V BUILD_DONE=1 -V INSTALL_DONE=1 -V DISTRIBUTION_DONE=1
広告を非表示にする