Rev 8124 | Blame | Last modification | View Log | Download | RSS feed
#! /bin/sh## ${R_HOME}/bin/INSTALL for installing add-on packages# @configure_input@revision='$Revision: 1.32 $'version=`set - ${revision}; echo ${2}`version="R add-on package installer ${version}"usage="Usage: R INSTALL [options] pkgsInstall the add-on packages specified by pkgs into the default R librarytree (${R_HOME}/library) or the tree specified via \`--library'. Theelements of pkgs can be relative or absolute paths to directories withthe package (bundle) sources, or to gzipped package \`tar' archives.Options:-c, --clean remove all files created during installation-d, --debug turn on shell and build-help debugging-h, --help print short help message and exit-l, --library=LIB install packages to library tree LIB--no-docs do not build and install documentation--use-zip collect help and examples into zip archives-v, --version print version info and exitReport bugs to <R-bugs@lists.r-project.org>."R_VERSION='@VERSION@'INSTALL='@INSTALL@'MAKE=${MAKE-@MAKE@}NO_PERL5=@NO_PERL5@NO_PERL5_MSG="\*** Formatting and installing R help pages needs Perl version 5, which*** does not seem to be installed on your system or is not in your path.*** Please install either Perl 5 on your system and re-configure R or*** get the PDF reference manual from the nearest CRAN server.*** The CRAN master site can be found at*** http://cran.r-project.org/"tmpdir="${TMPDIR:-/tmp}/R.INSTALL.$$"umask 022# Get one field including all continuation lines from a DCF file.get_dcf_field () {sed -n "/^${1}:/,/^[^ ]/{p;}" ${2} | \sed -n "/^${1}:/{s/^${1}:"'[ \t]*//;p;}/^[ \t]/{s/^[ \t]*//;p;}'}# get the full path names to all packages contained in $1; modzifies pkgsget_packages () {if grep -s "^Contains:" "${1}/DESCRIPTION"; thenbundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`for p in ${bundlepkg}; dopkgs="${pkgs} \"`cd "${1}/${p}"; pwd`\""if test -f "${1}/${p}/DESCRIPTION.in"; thencat "${1}/${p}/DESCRIPTION.in" > "${1}/${p}/DESCRIPTION"grep -v "^Contains:" "${1}/DESCRIPTION" >> "${1}/${p}/DESCRIPTION"fidoneelsepkgs="${pkgs} \"`cd "${1}"; pwd`\""fi}lib=${R_HOME}/librarypkgs=clean=falsedebug=falseerror=falsebuild_text=truebuild_html=truebuild_latex=truebuild_example=truebuild_help=truebuild_help_opts=use_zip=while test -n "${1}"; docase ${1} in-h|--help)echo "${usage}"; exit 0 ;;-v|--version)echo "${version}"; exit 0 ;;-c|--clean)clean=true ;;-d|--debug)debug=true ;;--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=true ;;-l|--library)lib=${2}; shift ;;--library=*)lib=`echo "${1}" | sed -e 's/[^=]*=//'` ;;--configure-args=*)configure_args=`echo "${1}" | sed -e 's/[^=]*=//'` ;;*)if test -f "${1}"; thenmkdir -p ${tmpdir}pkgname=`basename "${1}"`pkgname=`echo "${pkgname}" | sed 's/_.*//'`gzip -dc "${1}" | (cd ${tmpdir} && tar -xf -)if test -d "${tmpdir}/${pkgname}"; thenget_packages "${tmpdir}/${pkgname}"elseecho "ERROR: cannot extract package from ${1}"exit 1fielif test -d "${1}"; thenget_packages "${1}"elseecho "WARNING: package \`${1}' does not exist"fi;;esacshiftdoneif test -z "${pkgs}"; thenecho "ERROR: no packages specified"exit 1fiif test -d ${lib} -a -w ${lib} || mkdir ${lib} 2> /dev/null; thenlib=`cd ${lib}; pwd`elseecho "ERROR: cannot write to or create directory \`${lib}'"exit 2fiif ${build_text}; thenbuild_help_opts="${build_help_opts} --nroff"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}"fido_install () {cd "${1}"pkg=`basename "${1}"`depends=`get_dcf_field Depends DESCRIPTION`depends=`echo ${depends} | grep 'R *('`if test "${depends}"; thendepends=`echo ${depends} | sed 's/.*R *(\([^)]*\)).*/\1/;s/=/= /'`dep_operator=`set - ${depends}; echo ${1}`dep_version=`set - ${depends}; echo ${2}`dep_ok=`expr ${R_VERSION} ${dep_operator} ${dep_version} `if test ${dep_ok} -eq 0; thenecho "ERROR: This R is version ${R_VERSION}"echo " package \`${pkg}' depends on R ${dep_version}"exit 1;fifimkdir -p ${lib}/${pkg} || exit 3echo "Installing package \`${pkg}' ..."if test -x ./configure ; then./configure ${configure_args}if test ${?} -ne 0; thenecho "ERROR: Configuration failed for package \`${pkg}'"exit 4fifiif test -d src; thenecho " libs"if ${debug}; then set -x; fimkdir -p ${lib}/${pkg}/libsif test -f src/Makefile; then(cd src;makefiles="-f ${R_HOME}/etc/Makeconf -f Makefile"if test -r Makevars; thenmakefiles="-f Makevars ${makefiles}"fi${MAKE} ${makefiles} \&& cp *.@SHLIBEXT@ ${lib}/${pkg}/libs \|| error=true; \if ${clean}; then ${MAKE} clean; fi)else(cd src;sh ${R_HOME}/bin/SHLIB \-o ${lib}/${pkg}/libs/${pkg}.@SHLIBEXT@ *.[cf] \|| error=true; \if ${clean}; then rm -f *.o; fi)fiif ${error}; thenecho "ERROR: Compilation failed for package \`${pkg}'"exit 5fiif ${debug}; then set +x; fifiif test -d R; then dir=R; elif test -d funs; then dir=funs; fiif test "${dir}"; thenecho " ${dir}"mkdir -p ${lib}/${pkg}/Rcat `ls ${dir}/*.[RSqrs] ${dir}/unix/*.[RSqrs] 2>/dev/null` \> ${lib}/${pkg}/R/${pkg}fidir=if test -d data; thenecho " data"mkdir -p ${lib}/${pkg}/datacp data/* ${lib}/${pkg}/datachmod 644 ${lib}/${pkg}/data/*fiif test -d exec; thenecho " exec"mkdir -p ${lib}/${pkg}/execcp exec/* ${lib}/${pkg}/execchmod 755 ${lib}/${pkg}/exec/*fiif test -d inst; thenecho " inst"cp -r inst/* ${lib}/${pkg}fifor f in COPYING DESCRIPTION INDEX; doif test -f ${f}; then cp ${f} ${lib}/${pkg}; fidoneif test -f TITLE; thencp TITLE ${lib}/${pkg}elsetitle=`grep -s "^Title:" DESCRIPTION | sed "s/^Title:[ \t]*//"`if test "${title}"; then${R_HOME}/bin/maketitle > ${lib}/${pkg}/TITLEfifi(cd ${lib}; cat */TITLE > LibIndex 2> /dev/null)if test -d man; thenecho " help"if ${build_help}; thenif ${NO_PERL5}; thenecho "${NO_PERL5_MSG}"elseif ${debug}; thenecho " ${R_HOME}/bin/build-help ${BUILD_HELP_OPTS} ../${pkg} ${lib}"fi${R_HOME}/bin/build-help ${build_help_opts} ../${pkg} ${lib}${R_HOME}/bin/Rd2contents ../${pkg} > ${lib}/${pkg}/CONTENTSif test ${lib} = ${R_HOME}/library; then${R_HOME}/bin/build-help --htmllistscat ${R_HOME}/library/*/CONTENTS \> ${R_HOME}/doc/html/search/index.txtfifiif test -n "${use_zip}" -a -n "${R_UNZIPCMD}" -a -n "${R_ZIPCMD}"; thencd ${lib}/${pkg}if test -d R-ex; then(cd R-ex; ${R_ZIPCMD} -m Rhelp *.R)fi## NOT YET:## if test -d latex; then## (cd latex; ${R_ZIPCMD} -m Rhelp *.tex)## fiif test -d help; then(cd help; ${R_ZIPCMD} -m Rhelp * -x 00Titles AnIndex);fififielseecho " No man pages found in package \`${pkg}'"fiif ${clean}; thenif test -x ./cleanup ; then./cleanupfifichmod -R a+r ${lib}/${pkg}echo " DONE (${pkg})"echo}eval "for pkg in ${pkgs}; do do_install \"\${pkg}\"; done"if test -d "${tmpdir}"; thencd /rm -rf "${tmpdir}"fiecho "DONE (INSTALL)"### Local Variables: ***### mode: sh ***### sh-indentation: 2 ***### End: ***