aboutsummaryrefslogtreecommitdiff
path: root/0.8.0/cran/cran.bash
diff options
context:
space:
mode:
Diffstat (limited to '0.8.0/cran/cran.bash')
-rw-r--r--0.8.0/cran/cran.bash146
1 files changed, 146 insertions, 0 deletions
diff --git a/0.8.0/cran/cran.bash b/0.8.0/cran/cran.bash
new file mode 100644
index 0000000..6267e8a
--- /dev/null
+++ b/0.8.0/cran/cran.bash
@@ -0,0 +1,146 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et :
+
+# Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+#
+# Based in part upon ebuild.sh from Portage, which is Copyright 1995-2005
+# Gentoo Foundation and distributed under the terms of the GNU General
+# Public License v2.
+#
+# This file is part of the Paludis package manager. Paludis is free software;
+# you can redistribute it and/or modify it under the terms of the GNU General
+# Public License as published by the Free Software Foundation; either version
+# 2 of the License, or (at your option) any later version.
+#
+# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+# Place, Suite 330, Boston, MA 02111-1307 USA
+
+. ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+shopt -s expand_aliases
+
+CRAN_KILL_PID=$$
+alias die='diefunc "$FUNCNAME" "$LINENO"'
+trap 'echo "die trap: exiting with error." 1>&2 ; exit 250' 15
+
+for f in ${PALUDIS_BASHRC_FILES} ; do
+ if [[ -f ${f} ]] ; then
+ ebuild_notice "debug" "Loading bashrc file ${f}"
+ source ${f}
+ else
+ ebuild_notice "debug" "Skipping bashrc file ${f}"
+ fi
+done
+
+diefunc()
+{
+ local func="$1" line="$2"
+ shift 2
+ echo 1>&2
+ echo "!!! ERROR in cran/${PN:-?}:" 1>&2
+ echo "!!! In ${func:-?} at line ${line:-?}" 1>&2
+ echo "!!! ${*:-(no message provided)}" 1>&2
+ echo 1>&2
+
+ echo "!!! Call stack:" 1>&2
+ for (( n = 1 ; n < ${#FUNCNAME[@]} ; ++n )) ; do
+ funcname=${FUNCNAME[${n}]}
+ sourcefile=${BASH_SOURCE[${n}]}
+ lineno=${BASH_LINENO[$(( n - 1 ))]}
+ echo "!!! * ${funcname} (${sourcefile}:${lineno})" 1>&2
+ done
+ echo 1>&2
+
+ kill ${CRAN_KILL_PID}
+ exit 249
+}
+
+cran_command() {
+ local ret=1 command=${1}
+ shift
+
+ ebuild_section "Starting ${command}"
+
+ if type cran_do_${command} &> /dev/null ; then
+ cran_do_${command} || die "Failed to run command: ${command}"
+ else
+ die "Unknown command: ${command}"
+ fi
+
+ ebuild_section "Done ${command}"
+}
+
+cran_do_clean() {
+ [[ -e ${WORKDIR} ]] && rm -rf ${WORKDIR}
+ [[ -e ${IMAGE} ]] && rm -rf ${IMAGE}
+ return 0
+}
+
+cran_do_fetch() {
+ local mirror ret=0
+ shift
+
+ for mirror in ${PALUDIS_CRAN_MIRRORS[@]} ; do
+ mkdir -p ${DISTDIR}
+ cd ${DISTDIR}
+
+ if [[ -e ${DISTFILE} ]] ; then
+ echo "Already fetched: $(basename ${DISTFILE})"
+ return 0
+ fi
+
+ local dofetch="${PALUDIS_EBUILD_DIR}/fetchers/do$(echo ${mirror%%://*})"
+ local a="${mirror}/src/contrib/${DISTFILE}"
+ if [[ -f "${dofetch}" ]] ; then
+ ${dofetch} "${a}" "${DISTFILE}"
+ ret=$?
+ else
+ eerror "Don't know how to fetch '${a}'"
+ ret=1
+ fi
+ if [[ ${ret} == 0 ]] ; then
+ break
+ else
+ echo "Failed to run \"${command}\" for mirror ${mirror}."
+ fi
+ done
+ if [[ ${ret} != 0 ]] ; then
+ echo "Finally failed to run \"${command}\"."
+ fi
+}
+
+cran_do_install() {
+ if [[ -e "${WORKDIR}" ]] ; then
+ rm -Rf "${WORKDIR}" || die "Could not remove existing WORKDIR: ${WORKDIR}"
+ fi
+ mkdir -p "${WORKDIR}"
+ cd "${WORKDIR}" || die "Could not cd to WORKDIR: ${WORKDIR}"
+
+ local dounpack="${PALUDIS_EBUILD_DIR}/utils/dounpack"
+ ${dounpack} "${DISTFILE}"
+
+ # \todo Sandbox this?
+ R CMD INSTALL -l "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}" ${PN}
+}
+
+cran_do_merge() {
+ [[ -e "${IMAGE}/${INSTALL_TO##${ROOT}}/R.css" ]] \
+ && rm -f "${IMAGE}/${PALUDIS_CRAN_LIBRARY##${ROOT}}/R.css"
+ mkdir -p "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}"
+ ${PALUDIS_EBUILD_DIR}/utils/merge "${IMAGE}" "${ROOT}" "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS"
+}
+
+cran_do_unmerge() {
+ [[ -e "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS" ]] || die "CONTENTS file is missing for package ${PN}"
+ ${PALUDIS_EBUILD_DIR}/utils/unmerge "${ROOT}" "${PALUDIS_CRAN_LIBRARY}/paludis/${PN}/CONTENTS"
+}
+
+for cmd in $* ; do
+ cran_command ${cmd}
+done