Rev 46659 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!@R_SHELL@## ${R_HOME}/bin/INSTALL for installing add-on packages# @configure_input@## Trap interrupts, most importantly 2 (^C from keyboard)trap do_exit_on_error 1 2 15revision='$Rev: 46906 $'version=`set - ${revision}; echo ${2}`version="R add-on package installer ${version}Copyright (C) 2000-2008 The R Core Development Team.This is free software; see the GNU General Public License version 2or later for copying conditions. There is NO warranty."usage="Usage: R CMD INSTALL [options] pkgsInstall the add-on packages specified by pkgs. The elements of pkgs canbe relative or absolute paths to directories with the package (bundle)sources, or to gzipped package 'tar' archives. The library tree toinstall to can be specified via '--library'. By default, packages areinstalled in the library tree rooted at the first directory in.libPaths() for an R session run in the current environmentOptions:-h, --help print short help message and exit-v, --version print INSTALL version info and exit--configure-args=ARGSset arguments for the package's configure script(if any)--configure-vars=VARSset variables for the configure script (if any)-c, --clean remove files created during installation--preclean remove files created during a previous run-d, --debug turn on shell and build-help debugging-l, --library=LIB install packages to library tree LIB--no-configure do not use the package's configure script--no-docs do not build and install documentation--with-package-versionsallow for multiple versions of the same package--use-zip-data collect data files in zip archive--use-zip-help collect help and examples into zip archives--use-zip combine '--use-zip-data' and '--use-zip-help'--fake do minimal install for testing purposes--no-lock install on top of any existing installationwithout using a lock directory--libs-only only install the libs directory--build build binary tarball(s) of the installed package(s)Report bugs to <r-bugs@r-project.org>."## <NOTE>## This is a *shell* script.## According to the R Coding Standards (see R-exts), Perl can be assumed## for *source*, but not for *binary* installations.## </NOTE>## <NOTE>## We try to be defensive about possible white space in file names,## hence all the strange quoting ...## </NOTE>umask 022R_VERSION='@VERSION@'GETWD='@GETWD@'R_GZIPCMD='@R_GZIPCMD@': ${R_ARCH=@R_ARCH@}SED=@SED@if mkdir -p . 2>/dev/null; thenMKDIR_P="mkdir -p"elseMKDIR_P="${R_HOME}/bin/mkinstalldirs"fiwarning () { echo "WARNING: $*" >&2 ; }error () { echo "ERROR: $*" >&2 ; }startdir=`${GETWD}`: ${TMPDIR=/tmp}{ tmpdir=`(mktemp -d -q "${TMPDIR}/R.INSTALL.XXXXXX") 2>/dev/null` \&& test -n "${tmpdir}" && test -d "${tmpdir}" ; } ||{ test -n "${RANDOM}" && tmpdir=${TMPDIR}/R.INSTALL$$-${RANDOM} \&& (${MKDIR_P} "${tmpdir}") ; } ||{ tmpdir=${TMPDIR}/R.INSTALL.$$-`date +%m%d%H%M%S` && (${MKDIR_P} "${tmpdir}") ; } ||{ tmpdir=${TMPDIR}/R.INSTALL.$$ && (${MKDIR_P} "${tmpdir}") ; } ||(error "cannot create temporary directory" && exit 1)tmpdir=`cd "${tmpdir}" && ${GETWD}`: ${R_OSTYPE=unix}## <NOTE>## Unix only ... but Windows has INSTALL as a Perl script.R_EXE="${R_HOME}/bin/R"## </NOTE>## record R_LIBS at this pointR_LIBS0=${R_LIBS}## <NOTE>## This could be made a bit more general: if R CMD INSTALL is run by## another tool (e.g., when building or checking a package, its messages## should be a section level deeper (at least). So we could have an## argument to set the initial secnumdepth (0 by default), and work## against this ...message () { echo "${stars} $*"; }stars="*"## </NOTE>. "${R_SHARE_DIR}/sh/dcf.sh" # get_dcf_field()tilde_expand () {h=`echo "${HOME}" | ${SED} 's,/,\\\/,g'`## (Need to escape whatever we use as sed delimiter.)echo "$1" | ${SED} "s/^~/${h}/"}get_packages () {## get the full path names to all packages contained in $1.## NOTE: modifies pkgs!if grep "^Contains:" "${1}/DESCRIPTION" >/dev/null; thencontains=`get_dcf_field Contains "${1}/DESCRIPTION"`## Be careful whether package listed in the Contains field really## "exist". Refrain from installing the bundle in case of an entry## without corresponding package subdirectory, but be nice in case## of a subdirectorues without DESCRIPTION.in files (handled by the## R code).bundle_name=`get_dcf_field Bundle "${1}/DESCRIPTION"`bundle_pkgs=for p in ${contains}; doif test -d "${1}/${p}"; thenbundle_pkgs="${bundle_pkgs} \"`cd "${1}/${p}" && ${GETWD}`\""elsewarning "incorrect Contains metadata for bundle '${bundle_name}': there is no package '${p}'"warning "skipping installation of bundle '${bundle_name}'"bundle_pkgs=breakfidoneif test -n "${bundle_pkgs}"; then## Create the package level DESCRIPTION files from the bundle## level DESCRIPTION and the package level DESCRIPTION.in ones.echo "tools:::.vcreate_bundle_package_descriptions(\"${1}\", \"${contains}\")" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla >/dev/null## Should really check on the exit status ...pkgs="${pkgs} ${bundle_pkgs}"fielsepkgs="${pkgs} \"`cd "${1}" && ${GETWD}`\""fi}parse_description_field () { # fieldnametmp=`get_dcf_field ${1} DESCRIPTION`if test "x$tmp" != "x" ; thencase "$tmp" inyes|Yes|true|True|TRUE)value=true;;no|No|false|False|FALSE)value=false;;*)error "invalid value of ${1} field in DESCRIPTION"do_exit_on_error;;esacelsevalue="missing"fi}do_cleanup_tmpdir () {## Solaris will not remove any directory in the current pathcd "${startdir}"if test -d "${tmpdir}"; thenrm -rf "${tmpdir}"fi}###### Setup and command line processing.pkgs=lib=clean=falsepreclean=falsedebug=falsebuild_text=truebuild_html=truebuild_latex=truebuild_example=truebuild_help=truebuild_help_opts=use_configure=trueuse_zip_data=use_zip_help=configure_args=configure_vars=with_package_versions=falsefake=falselazy=truelazy_data=falselock=truelibs_only=falsetar_up=falseshargs=while test -n "${1}"; do##DBG echo " in 'R INSTALL' --arg checking-- \$1 = '${1}'" # Debuggingcase ${1} in-h|--help)echo "${usage}"; do_cleanup_tmpdir; exit 0 ;;-v|--version)echo "${version}"; do_cleanup_tmpdir; exit 0 ;;-c|--clean)clean=trueshargs="${shargs} ${1}";;--preclean)preclean=trueshargs="${shargs} --preclean";;-d|--debug)debug=true ;;--with-package-versions)with_package_versions=true ;;--no-configure)use_configure=false ;;--no-docs)build_text=falsebuild_html=falsebuild_latex=falsebuild_example=false ;;--no-text)build_text=false ;;--no-html)build_html=false ;;--no-latex)build_latex=false ;;--no-example)build_example=false ;;--use-zip)use_zip_data=trueuse_zip_help=true ;;--use-zip-data)use_zip_data=true ;;--use-zip-help)use_zip_help=true ;;-l|--library)lib="${2}"; shift ;;--library=*)lib=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;--configure-args=*)configure_args=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;--configure-vars=*)configure_vars=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;--fake)fake=true ;;--no-lock)lock=false ;;--libs-only)libs_only=true ;;--build)tar_up=true ;;*)if test -f "${1}"; then##DBG echo " in 'R INSTALL' --arg checking-- FILE '${1}'"pkgname=`basename "${1}"`## Also allow for 'package.tgz' ...pkgname=`basename "${pkgname}" .tgz`pkgname=`echo "${pkgname}" | ${SED} 's/_.*//'`## Note that we use '-m' so that modification dates are *not*## preserved when untarring the sources. This is necessary to## ensure that the preformatted help pages are always rebuilt.## Otherwise, the build date for an older version may be newer## than the modification date for the new sources as recorded in## the tarball ...${R_GZIPCMD} -dc "${1}" | (cd "${tmpdir}" && ${TAR} -mxf -)## If we have a binary bundle distribution, the DESCRIPTION file## is at top level.if test -f "${tmpdir}/DESCRIPTION"; thenif grep "^Contains:" "${tmpdir}/DESCRIPTION" >/dev/null; thenmessage "Looks like a binary bundle"get_packages "${tmpdir}"elseerror "unknown package layout"do_cleanup_tmpdir;exit 1fielif test -f "${tmpdir}/${pkgname}/DESCRIPTION"; thenget_packages "${tmpdir}/${pkgname}"elseerror "cannot extract package from '${1}'"do_cleanup_tmpdir;exit 1fielif test -f "${1}/DESCRIPTION"; then##DBG echo " in 'R INSTALL' -f DESCRIPTION --> 'get_packages ${1}'"get_packages "${1}"elsewarning "invalid package '${1}'"fi;;esacshiftdonelib=`tilde_expand "${lib}"`if test -z "${lib}"; thenlib=`echo "cat('\n~~~', .libPaths()[1], '\n', sep = '')" | \R_DEFAULT_PACKAGES=NULL "${R_EXE}" --no-restore --slave | \grep '^~~~' | ${SED} 's/.*~~~//'`message "Installing to library '$lib'"## $lib gets checked later.elselib0=${lib}if test ! -d "${lib}"; thenerror "-l or --library value '${lib}' does not exist or is not a directory"do_cleanup_tmpdir;exit 2fiif test ! -w "${lib}"; thenerror "-l or --library value '${lib}' does not have write access"do_cleanup_tmpdir;exit 2ficd "${lib}"lib=`${GETWD}`cd "${startdir}"fiif (${tar_up} && ${fake}); thenerror "building a fake installation is disallowed"do_cleanup_tmpdir;exit 1fiif ${libs_only} ; thenlock=falsetar_up=falsemore_than_libs=falseelsemore_than_libs=truefiif ${debug} ; thenecho "'R CMD INSTALL': in startdir= $startdir with tmpdir= $tmpdir"echo " lib= '$lib', pkgs= '$pkgs'"fiif test -z "${pkgs}"; thenerror "no packages specified"do_cleanup_tmpdir;exit 1fiif (test -d "${lib}" && test -w "${lib}") || \${MKDIR_P} "${lib}" 2> /dev/null; thenlib=`cd "${lib}" && ${GETWD}`elseerror "cannot write to or create directory '${lib}'"do_cleanup_tmpdir;exit 2fiif ${lock} ; thenlockdir="${lib}/00LOCK"if ${debug} ; then echo " before checking lockdir= '${lockdir}'" ; fiif test -d "${lockdir}" || test -f "${lockdir}"; thenerror "failed to lock directory '${lib}' for modifying"echo "Try removing '${lockdir}'" >&2do_cleanup_tmpdir;exit 3else${MKDIR_P} "${lockdir}"if test ${?} -ne 0; then## This should not really happen ...error "failed to lock directory '${lib}' for modifying"do_cleanup_tmpdir;exit 3fifiif ${debug} ; then echo ' after checking lockdir' ; fifiif ${fake}; thenuse_configure=falsebuild_text=truebuild_html=falsebuild_latex=truebuild_example=falsefiif ${build_text}; thenbuild_help_opts="${build_help_opts} --txt"fiif ${build_html}; thenbuild_help_opts="${build_help_opts} --html"fiif ${build_latex}; thenbuild_help_opts="${build_help_opts} --latex"fiif ${build_example}; thenbuild_help_opts="${build_help_opts} --example"fiif test -z "${build_help_opts}"; thenbuild_help=falseelif ${debug}; thenbuild_help_opts="--debug ${build_help_opts}"fiif ${debug} ; then echo " build_help_opts= '${build_help_opts}'" ; fiis_first_package=yes###### Install a *binary* package (not bundle) from the current directory.do_install_binary () {pkg="${1}"R_PACKAGE_DIR="${2}"R_PACKAGE_NAME="${3}"if test "${pkg}" = "${R_PACKAGE_NAME}"; thenmessage "Installing *binary* package '${pkg}' ..."elsemessage "Installing *binary* package '${pkg}' as '${R_PACKAGE_NAME}' ..."fiif test -f "${R_PACKAGE_DIR}/DESCRIPTION"; then## Back up previous version.if ${lock}; then mv "${R_PACKAGE_DIR}" "${lockdir}/${R_PACKAGE_NAME}" ; fi${MKDIR_P} "${R_PACKAGE_DIR}"ficp -r . "${R_PACKAGE_DIR}" || \(${TAR} cf - . | (cd "${R_PACKAGE_DIR}" && ${TAR} xf -))if test ${?} -ne 0; thenerror "installing binary package failed"do_exit_on_errorfiif ${tar_up} ; thenecho "${pkg} was already a binary package and will not be rebuilt"fi}###### Install a *source* package from the current directory.do_install_source () {pkg_name="${1}"pkg_dir="${4}"## (The basename of ${pkg_dir} might be different from ${pkg_name},## e.g., when building Debian packages from R packages.)## Make the destination directories available to the developer's## installation scripts (e.g. configure, etc.)R_PACKAGE_DIR="${2}"R_PACKAGE_NAME="${3}"R_LIBRARY_DIR="${lib}"export R_LIBRARY_DIRexport R_PACKAGE_DIRexport R_PACKAGE_NAMEif test -n "${lib0}" ; then## set R_LIBS to include the current installation directoryif test -n "${R_LIBS}"; thenR_LIBS="${lib}:${R_LIBS}"elseR_LIBS="${lib}"fiexport R_LIBSfiType=`get_dcf_field Type DESCRIPTION`if test "$Type" = "Frontend" ; thenmessage "Installing *Frontend* package '${pkg_name}' ..."if ${preclean}; then${MAKE} cleanfiif ${use_configure}; thenif test -x ./configure ; theneval ${configure_vars} ./configure ${configure_args}if test ${?} -ne 0; thenerror "configuration failed for package '${pkg_name}'"do_exit_on_errorfielif test -f ./configure ; thenerror "'configure' exists but is not executable -- see the 'R Installation and Adminstration Manual'"do_exit_on_errorfifiif test -f ./Makefile ; then${MAKE}if test ${?} -ne 0; thenerror "make failed for package '${pkg_name}'"do_exit_on_errorfiif ${clean}; then${MAKE} cleanfireturnfireturnfiif test "$Type" = "Translation" ; thenmessage "Installing *Translation* package '${pkg_name}' ..."if test -d "share"; thencp -r ./share/* ${R_SHARE_DIR}fiif test -d "library"; thencp -r ./library ${R_HOME}fireturnfiOS_type=`get_dcf_field OS_type DESCRIPTION`if test "$OS_type" = "windows" && test "${fake}" != "true"; thenerror "windows-only package"do_exit_on_errorfiif test "${pkg_name}" = "${R_PACKAGE_NAME}"; thenmessage "Installing *source* package '${pkg_name}' ..."elsemessage "Installing *source* package '${pkg_name}' as '${R_PACKAGE_NAME}' ..."fistars="**"if test -f "${R_PACKAGE_DIR}/DESCRIPTION"; then## Back up previous version.if ${lock} ; thenmv "${R_PACKAGE_DIR}" "${lockdir}/${R_PACKAGE_NAME}"elseif ${more_than_libs}; then## this is only used for recommended packages installed from .tgzrm -rf "${R_PACKAGE_DIR}"fifi${MKDIR_P} "${R_PACKAGE_DIR}"## Preserve man pages to speed up installation? Only makes sense## if we install from a non-temporary directory.if ${lock} && test "`cd .. && ${GETWD}`" != \"`cd \"${tmpdir}\" && ${GETWD}`"; then(cd "${lockdir}/${R_PACKAGE_NAME}" \&& ${TAR} cf - R-ex help html latex 2>/dev/null) | \(cd "${R_PACKAGE_DIR}" && ${TAR} xf -)fi## check if we are in a bundle so we can back out the whole bundleif grep "^Bundle:" DESCRIPTION >/dev/null; thenif ${tar_up} ; thenerror "cannot build (nor INSTALL) binary versions of bundles"do_exit_on_errorfibundlepkg=`get_dcf_field Contains ../DESCRIPTION`elsebundlepkg=${pkg_name}fifiif ${preclean}; thenif test -d src; thencd srcif test -f Makefile; then${MAKE} cleanelse## we will be using SHLIB --precleanrm -f *@SHLIB_EXT@ficd ..fiif test -x ./cleanup ; then./cleanupelif test -f ./cleanup ; thenwarning "'cleanup' exists but is not executable -- see the 'R Installation and Adminstration Manual'"fifiif ${use_configure}; thenif test -x ./configure ; theneval ${configure_vars} ./configure ${configure_args}if test ${?} -ne 0; thenerror "configuration failed for package '${pkg_name}'"do_exit_on_errorfielif test -f ./configure ; thenerror "'configure' exists but is not executable -- see the 'R Installation and Adminstration Manual'"do_exit_on_errorfifiif ${more_than_libs}; thenfor f in NAMESPACE LICENSE LICENCE COPYING NEWS; doif test -f "${f}"; thencp "${f}" "${R_PACKAGE_DIR}"chmod 644 "${R_PACKAGE_DIR}/${f}"fidone## Install DESCRIPTION file with build information.echo "tools:::.install_package_description(\".\", \"${R_PACKAGE_DIR}\")" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla >/dev/nullif test ${?} -ne 0; thenerror "installing package DESCRIPTION failed"do_exit_on_errorfifisystem_makefile="${R_HOME}/etc${R_ARCH}/Makeconf"if test -d src && test "${fake}" != "true"; thenmessage "libs"if test ! -f "${R_INCLUDE_DIR}/R.h" ; then## maybe even an error? But installing Fortran-based packages should workwarning "R include directory is empty -- perhaps need to install R-devel.rpm or similar"fihas_error=false## prepend ${lib} to library path.CLINK_CPPFLAGS=`echo "invisible(.libPaths(c(\"${lib}\", .libPaths())));tools:::.find_cinclude_paths(file='DESCRIPTION')" | \"${R_EXE}" --vanilla --slave`export CLINK_CPPFLAGSif ${debug}; then set -x; fi${MKDIR_P} "${R_PACKAGE_DIR}/libs${R_ARCH}"if test -f src/Makefile; thenarch=`echo ${R_ARCH} | ${SED} -e 's+^/++'`message "arch - ${arch}"cd src;makefiles="-f \"${system_makefile}\" -f Makefile"if test -r "${HOME}/.R/Makevars-${R_PLATFORM}"; thenmakefiles="${makefiles} -f \"${HOME}/.R/Makevars-${R_PLATFORM}\""elif test -r "${HOME}/.R/Makevars"; thenmakefiles="${makefiles} -f \"${HOME}/.R/Makevars\""fieval ${MAKE} ${makefiles} \&& cp *@SHLIB_EXT@ "${R_PACKAGE_DIR}/libs${R_ARCH}" \|| has_error=true; \cd ..elsecd src;srcs=`ls *.[cfmCM] *.cc *.cpp *.f90 *.f95 *.mm 2>/dev/null`## This allows Makevars to set OBJECTS or its own targets.if test -r Makevars; thenallfiles="Makevars ${srcs}"elseallfiles=${srcs}fiarchs=`(cd ${R_HOME}/bin/exec; ls)`R_ARCH_keep=${R_ARCH}if test -n "${allfiles}"; then## if there is a configure script we install only the main## sub-architectureif test -x ../configure; thenif test -n "${R_ARCH}"; thenarch=`echo ${R_ARCH} | ${SED} -e 's+^/++'`message "arch - ${arch}"fish "${R_HOME}/bin/SHLIB" ${shargs} -o "${pkg_name}@SHLIB_EXT@" ${srcs} \&& cp *@SHLIB_EXT@ "${R_PACKAGE_DIR}/libs${R_ARCH}" \|| has_error=true;chmod 755 "${R_PACKAGE_DIR}/libs${R_ARCH}/"*elsefor arch in ${archs}; dorm -f *.o *.so *.sl *.dylibif test "${arch}" = "R"; thenR_ARCH=${R_ARCH_keep}export R_ARCHsh "${R_HOME}/bin/SHLIB" ${shargs} -o "${pkg_name}@SHLIB_EXT@" ${srcs} \&& cp *@SHLIB_EXT@ "${R_PACKAGE_DIR}/libs" \|| has_error=true;elif test "${arch}" = "Rgnome"; thenR_ARCH=${R_ARCH_keep}elsemessage "arch - ${arch}"R_ARCH="/${arch}"export R_ARCH${MKDIR_P} "${R_PACKAGE_DIR}/libs${R_ARCH}"sh "${R_HOME}/bin/SHLIB" ${shargs} -o "${pkg_name}@SHLIB_EXT@" ${srcs} \&& cp *@SHLIB_EXT@ "${R_PACKAGE_DIR}/libs${R_ARCH}" \|| has_error=true;chmod 755 "${R_PACKAGE_DIR}/libs${R_ARCH}/"*fidoneR_ARCH=${R_ARCH_keep}fielsewarning "no source files found"ficd ..fiif ${has_error}; thenerror "compilation failed for package '${pkg_name}'"do_exit_on_errorfichmod 755 "${R_PACKAGE_DIR}/libs${R_ARCH}/"*if ${debug}; then set +x; fifiif ${more_than_libs}; thenif test -d R; thenmessage "R"${MKDIR_P} "${R_PACKAGE_DIR}/R"rm -f "${R_PACKAGE_DIR}/R/"*## this uses the locale to find a suitable charsetecho "tools:::.install_package_code_files(\".\", \"${R_PACKAGE_DIR}\")" | \R_DEFAULT_PACKAGES=NULL LC_COLLATE=C "${R_EXE}" --vanilla >/dev/nullif test ${?} -ne 0; thenerror "unable to collate files for package '${pkg_name}'"do_exit_on_errorfiif test -f "R/sysdata.rda"; thenecho "tools:::sysdata2LazyLoadDB(\"R/sysdata.rda\", \"${R_PACKAGE_DIR}/R\")" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla > /dev/null ; \if test ${?} -ne 0; then \error "unable to build sysdata DB for package '${pkg_name}'" ; \do_exit_on_error ; \fi ; \fiif ${fake}; thenif test -f NAMESPACE; then(echo; echo ".onLoad <- .onAttach <- function(lib, pkg) NULL") >> \"${R_PACKAGE_DIR}/R/${R_PACKAGE_NAME}"## <NOTE>## Tweak fake installation to provide an 'empty' useDynLib() for## the time being. Completely removing the directive results in## checkFF() being too aggresive in the case where the presence## of the directive enables unambiguous symbol resolution w/out## 'PACKAGE' arguments. However, empty directives are not## really meant to work ...${SED} -e 's/useDynLib.*/useDynLib("")/' NAMESPACE > \"${R_PACKAGE_DIR}/NAMESPACE"## </NOTE>else(echo; echo ".First.lib <- function(lib, pkg) NULL") >> \"${R_PACKAGE_DIR}/R/${R_PACKAGE_NAME}"fififiif test -d data; thenmessage "data"${MKDIR_P} "${R_PACKAGE_DIR}/data"rm -f "${R_PACKAGE_DIR}/data/"*cp data/* "${R_PACKAGE_DIR}/data" 2>/dev/nullchmod 644 "${R_PACKAGE_DIR}/data/"*parse_description_field LazyDataif test "$value" = "missing" ; thenthislazy=${lazy_data}elsethislazy=${value}fiif ${thislazy}; thenmessage " moving datasets to lazyload DB"## it is possible that data in a package will make use of the## code in the package, so ensure the package we have just## installed is on the library path.echo "options(warn=1); invisible(.libPaths(c(\"${lib}\", .libPaths()))); tools:::data2LazyLoadDB(\"${R_PACKAGE_NAME}\", \"${lib}\")" | \R_DEFAULT_PACKAGES= LC_ALL=C "${R_EXE}" --vanilla > /dev/nullif test ${?} -ne 0; thenerror "lazydata failed for package '${pkg_name}'"do_exit_on_errorfielseif test -n "${use_zip_data}" \&& test -n "${R_UNZIPCMD}" \&& test -n "${R_ZIPCMD}"; then(cd "${R_PACKAGE_DIR}/data";find . -type f -print > filelist${R_ZIPCMD} -q -m Rdata * -x filelist 00Index)fififiif test -d demo && test "${fake}" != "true"; thenmessage "demo"${MKDIR_P} "${R_PACKAGE_DIR}/demo"rm -f "${R_PACKAGE_DIR}/demo/"*echo "tools:::.install_package_demos('.', '${R_PACKAGE_DIR}')" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla --slave > /dev/nullif test ${?} -ne 0; thenerror "installing demos failed"do_exit_on_errorfichmod 644 "${R_PACKAGE_DIR}/demo/"*fiif test -d exec && test "${fake}" != "true"; thenmessage "exec"${MKDIR_P} "${R_PACKAGE_DIR}/exec"rm -f "${R_PACKAGE_DIR}/exec/"*cp exec/* "${R_PACKAGE_DIR}/exec" 2>/dev/nullchmod 755 "${R_PACKAGE_DIR}/exec/"*fiif test -d inst && test "${fake}" != "true"; thenmessage "inst"cp -r inst/* "${R_PACKAGE_DIR}" || \(cd inst && ${TAR} cf - . | \(cd "${R_PACKAGE_DIR}" && ${TAR} xf -))fiif test -r install.R; thenwarning "use of install.R is no longer supported"fiif test -r R_PROFILE.R; thenwarning "use of R_PROFILE.R is no longer supported"fiparse_description_field SaveImageif test "$value" != "missing" ; thenif ${value}; thenwarning "'SaveImage' is defunct: ignored, and please remove it"elsewarning "'SaveImage' is defunct: please remove it"fifiparse_description_field LazyLoadif test "$value" = "missing" ; thenthislazy=${lazy}elsethislazy=${value}fiif test ! -d R ; thenthislazy=falsefiif ${thislazy}; thenmessage "preparing package for lazy loading"(echo "options(warn=1); invisible(.libPaths(c(\"${lib}\", .libPaths()))); .getRequiredPackages(); tools:::makeLazyLoading(\"${R_PACKAGE_NAME}\", \"${lib}\")") | \R_DEFAULT_PACKAGES= LC_ALL=C "${R_EXE}" --vanilla --slaveif test ${?} -ne 0; thenerror "lazy loading failed for package '${pkg_name}'"do_exit_on_errorfirm -f ${R_PACKAGE_DIR}/R/all.rdafiif test -d man; thenmessage "help"## Install man sources ...echo "tools:::.install_package_man_sources('.', '${R_PACKAGE_DIR}')" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla --slave > /dev/nullif test ${?} -ne 0; thenerror "installing man sources failed"do_exit_on_errorfichmod 644 "${R_PACKAGE_DIR}/man/${pkg_name}.Rd.gz"## Maybe build preformatted help pages ...if ${build_help}; thenif ${debug}; thenecho "DEBUG: build-help ${build_help_opts} ${pkg_dir} ${lib} ${R_PACKAGE_DIR} ${pkg_name}"fi"${R_CMD}" perl "${R_SHARE_DIR}/perl/build-help.pl" \${build_help_opts} \"${pkg_dir}" "${lib}" "${R_PACKAGE_DIR}" "${pkg_name}"if test ${?} -ne 0; thenerror "building help failed for package '${pkg_name}'"do_exit_on_errorfiif test -n "${use_zip_help}" \&& test -n "${R_UNZIPCMD}" \&& test -n "${R_ZIPCMD}"; then(cd "${R_PACKAGE_DIR}"if test -d R-ex; then(cd R-ex; ${R_ZIPCMD} -q -m Rex *.R)fiif test -d help; then(cd help; ${R_ZIPCMD} -q -m Rhelp * -x AnIndex);fiif test -d latex; then(cd latex; ${R_ZIPCMD} -q -m Rhelp *.tex)fi)fifielseecho "No man pages found in package '${pkg_name}'"fimessage "building package indices ..."echo "invisible(.libPaths(c(\"${lib}\", .libPaths()))); tools:::.install_package_indices(\".\", \"${R_PACKAGE_DIR}\")" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla >/dev/nullif test ${?} -ne 0; thenerror "installing package indices failed"do_exit_on_errorfi## Install a dump of the parsed NAMESPACE fileif test -f NAMESPACE && test "${fake}" != "true"; thenecho "tools:::.install_package_namespace_info(\".\", \"${R_PACKAGE_DIR}\")" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla >/dev/nullif test ${?} -ne 0; thenerror "installing namespace metadata failed"do_exit_on_errorfififi ## ${more_than_libs}## <NOTE>## Remove stuff we should not have installed in the first place.## When installing from a source directory under version control, we## should really exclude the subdirs CVS, .svn (Subversion) and## .arch-ids (arch).for d in CVS .svn .arch-ids .git; dofind "${R_PACKAGE_DIR}" -name ${d} -type d -prune \-exec rm -rf \{\} \; 2>/dev/nulldone## </NOTE>if ${clean}; thenif test -d src; thencd srcif test -f Makefile; then${MAKE} cleanelse## we used SHLIB --cleanrm -f *@SHLIB_EXT@ficd ..fiif test -x ./cleanup ; then./cleanupelif test -f ./cleanup ; thenwarning "'cleanup' exists but is not executable -- see the 'R Installation and Adminstration Manual'"fifi## now repackage as a tarball if requestedif ${tar_up} ; thenversion=`get_dcf_field Version DESCRIPTION`## R_PLATFORM is set by R CMDfilename="${R_PACKAGE_NAME}_${version}_R_${R_PLATFORM}.tar"filepath="${startdir}/$filename"${TAR} -chf "$filepath" -C "${R_LIBRARY_DIR}" ${R_PACKAGE_NAME}${R_GZIPCMD} -9f "$filepath"echo "packaged installation of '${R_PACKAGE_NAME}' as ${filename}.gz"fistars="*"}###### Install a package.do_install () {cd "${1}"pkg_dir="${1}"pkg_name=`get_dcf_field Package DESCRIPTION`## (The basename of ${pkg_dir} might be different from ${pkg_name},## e.g., when building Debian packages from R packages.)if test -z "${pkg_name}"; thenerror "no 'Package' field in 'DESCRIPTION'"do_exit_on_error nofi## Set R_PACKAGE_DIR here at the top level. If a version is being## specified, tack that on.version=""if ${with_package_versions}; thenversion=`get_dcf_field Version DESCRIPTION`if test -z "${version}"; thenerror "no 'Version' field in 'DESCRIPTION'"do_exit_on_error nofiR_PACKAGE_NAME="${pkg_name}_${version}"R_PACKAGE_DIR="${lib}/${pkg_name}_${version}"elseR_PACKAGE_NAME="${pkg_name}"R_PACKAGE_DIR="${lib}/${pkg_name}"fiexport R_PACKAGE_DIRexport R_PACKAGE_NAMEecho "options(warn=1); tools:::.test_package_depends_R_version()" | \R_DEFAULT_PACKAGES=NULL LC_ALL=C "${R_EXE}" --vanilla --slaveif test ${?} -ne 0; thendo_exit_on_errorfi${MKDIR_P} "${R_PACKAGE_DIR}" || do_exit_on_error no## Make sure we do not attempt installing to srcdir.if test "`cd \"${R_PACKAGE_DIR}\" && ${GETWD}`" = "`${GETWD}`"; thenerror "cannot install to srcdir"do_exit_on_error nofi## Figure out whether this is a source or binary package.if grep "^Built:" DESCRIPTION >/dev/null ; then## If DESCRIPTION has a @samp{Built:} entry this is a binary## package. This is the right test, but not available for packages## installed prior to 1.4.0 -- but 2.0.0 requires packages to be## reinstalled.is_source_package=falseelseis_source_package=truefitest "${is_first_package}" = no && echoif ${is_source_package}; then## This is a source package ... hopefully.do_install_source \"${pkg_name}" "${R_PACKAGE_DIR}" "${R_PACKAGE_NAME}" "${pkg_dir}"else## This is a binary package ... hopefully.do_install_binary \"${pkg_name}" "${R_PACKAGE_DIR}" "${R_PACKAGE_NAME}"fifind "${R_PACKAGE_DIR}" -exec chmod a+r \{\} \;message "DONE (${pkg_name})"is_first_package=no}###### Exit and cleanup.do_exit_on_error () {remove_R_package_dir=${1-yes}## If we are not yet processing a package, we will not have## set pkg_dir. It's the first thing in do_install.if test -n "${pkg_dir}"; then## Find out if this is a bundle. If we are installing multiple## 'packages' the existing bundlepkg is unreliable.bundlepkg=`get_dcf_field Contains "${pkg_dir}/DESCRIPTION"`if test -z "${bundlepkg}"; thenbundlepkg=${pkg_name}fifor p in ${bundlepkg}; doif ${with_package_versions}; thenp=${p}_${version}fipkgdir="${lib}/$p"if test "${remove_R_package_dir}" = yes && test -n "${pkgdir}"; thenmessage "Removing '${pkgdir}'"rm -rf "${pkgdir}"fiif test -n "$p" \&& test -d "${lockdir}/$p"; thenmessage "Restoring previous '${pkgdir}'"mv "${lockdir}/$p" "${pkgdir}"fidonefido_cleanupexit 1}do_cleanup () {do_cleanup_tmpdirif test "${is_first_package}" = no; then## Only need to do this in case we successfully installed at least## *one* package ... well not so sure for bundles.cp "${R_DOC_DIR}/html/R.css" "${lib}"chmod 644 "${lib}/R.css" 2>/dev/nullif test "${lib}" = "`cd \"${R_HOME}/library\" && ${GETWD}`"; thencat "${R_HOME}"/library/*/CONTENTS \> "${R_DOC_DIR}"/html/search/index.txtif ${build_help} && test "${NO_PERL5}" = "false"; thenecho "tools:::unix.packages.html(.Library, docdir=\"${R_DOC_DIR}\")" | \R_DEFAULT_PACKAGES=NULL LC_COLLATE=C "${R_EXE}" --vanilla >/dev/nullfififiif ${lock}; thenrm -rf "${lockdir}"fi}###### Main loop.if ${debug} ; thenecho "'R CMD INSTALL': now doing 'eval ... do_install':"fieval "for pkg in ${pkgs}; do do_install \"\${pkg}\"; done"do_cleanup### Local Variables: ***### mode: sh ***### sh-indentation: 2 ***### End: ***