#!/bin/sh # ${RHOME}/bin/check for checking installed add-on packages USAGE_MSG="Usage: R CMD check [options] [-l lib] pkg_1 ... pkg_n" VERSION="0.2-0" OPTS= PKGS= CLEAN=false DEBUG=false REBUILD=true START_DIR=`pwd` lib=${RHOME}/library while test -n "${1}"; do case ${1} in -h|--help|-\?) echo "${USAGE_MSG}"; exit 0 ;; -V|--version) echo "${VERSION}"; exit 0 ;; -c|--clean) CLEAN=true ;; --debug) DEBUG=true; OPTS="${OPTS} --debug" ;; --no-rebuild) REBUILD=false ;; -l) lib=${2}; shift; RLIBS="${lib}:${RLIBS}"; ;; *) PKGS="${PKGS} ${1}" ;; esac shift done if ${DEBUG}; then set -x; fi if test -z "${PKGS}"; then echo "${USAGE_MSG}" exit 1 fi if test -d ${lib}; then lib=`cd ${lib}; pwd` else echo "ERROR: library directory \`${lib}' does not exist" exit 2 fi for pkg in ${PKGS}; do cd ${START_DIR} USE_MAN=false if ${REBUILD}; then if test -d ${pkg}/man -a -w ${lib}/`basename ${pkg}`; then USE_MAN=true cd ${pkg} pkg=`basename ${pkg}` rm -rf ${lib}/${pkg}/R-ex fi fi echo "Checking package \`${pkg}' ..." if test \! -d ${lib}/${pkg}; then echo "WARNING: package \`${pkg}' not installed ... skipping" break fi if ${USE_MAN}; then ${RHOME}/bin/build-help ${OPTS} --example ../${pkg} ${lib} CHECK_DIR=check else CHECK_DIR=check-${pkg} fi test -d ${CHECK_DIR} || mkdir ${CHECK_DIR} cd ${CHECK_DIR} echo " Massaging examples into \`${pkg}-Ex.R' ..." ${RHOME}/bin/massage-Examples ${pkg} ${lib}/${pkg}/R-ex/*.R \ > ${pkg}-Ex.R echo " Running examples in package \`${pkg}' ..." RLIBS=${RLIBS} ${RHOME}/bin/R --vanilla < ${pkg}-Ex.R \ > ${pkg}-Ex.Rout if test ${?} -eq 0; then echo " OK" else echo " ERROR" && exit 1 fi if ${CLEAN}; then cd .. && rm -rf ${CHECK_DIR}; fi done