The R Project SVN R

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27846 ripley 1
# needs save lib pkg R_HOME BUILD RX_EXE
13875 ripley 2
lib=$2
3
pkg=$3
4
R_HOME=$4
27846 ripley 5
BUILD=$5
6
RX_EXE=$6
13875 ripley 7
 
8
case $1 in
15355 jmc 9
    CHECK) if test -r install.R; then R_SAVE_IMAGE=true; else R_SAVE_IMAGE=false; fi;;
13875 ripley 10
    *) R_SAVE_IMAGE=$1;;
11
esac
12
export R_SAVE_IMAGE
13
 
27846 ripley 14
if test "x${BUILD}" = "xCROSS"; then
27847 ripley 15
R_DEFAULT_PACKAGES=NULL
16
export R_DEFAULT_PACKAGES
17
R_EXE="${RX_EXE} --slave --no-site-file --no-init-file"
27850 ripley 18
## we have to install into a temporary dir to avoid libpath problems
19
lib1=/tmp/RtmpWin
27846 ripley 20
else
21
R_EXE="${R_HOME}/bin/Rterm --slave --no-site-file --no-init-file R_DEFAULT_PACKAGES=NULL"
27850 ripley 22
lib1=${lib}
27846 ripley 23
fi
24
 
25868 ripley 25
## This is apparently needed, but no one told the Windows maintainers.
26
R_PACKAGE_NAME=${pkg}
27
export R_PACKAGE_NAME
28
 
13875 ripley 29
if ${R_SAVE_IMAGE}; then
30
    echo "  save image"
27850 ripley 31
    if test "x${BUILD}" = "xCROSS"; then
32
        mkdir -p ${lib1}/${pkg}
33
        cp -r ${lib}/${pkg}/DESCRIPTION ${lib}/${pkg}/R ${lib1}/${pkg}
34
        if test -f NAMESPACE; then
35
          cp ${lib}/${pkg}/NAMESPACE ${lib1}/${pkg}
36
        fi
37
    fi
24950 luke 38
    save_image_defaults="list(compress=TRUE, safe=FALSE)"
39
    code_file="${lib}/${pkg}/R/${pkg}"
40
    rda_file="${lib}/${pkg}/R/all.rda"
23245 luke 41
    if test -f NAMESPACE; then
27850 ripley 42
        code_cmd="echo saveNamespaceImage(\"${pkg}\", \"${rda_file}\", \"${lib1}\")"
24950 luke 43
        loader_file=nsrdaload.R
27846 ripley 44
        R_SAVE_EXE=""
24950 luke 45
    else
46
        code_cmd="cat ${code_file}"
47
        loader_file=firstlib.R
27846 ripley 48
        R_SAVE_EXE="--save"
23245 luke 49
    fi
18523 ripley 50
    (echo "options(save.image.defaults=${save_image_defaults})"; \
51
      if test -s R_PROFILE.R; then cat R_PROFILE.R; fi; \
27850 ripley 52
      echo "invisible(.libPaths(c(\"${lib1}\", .libPaths())))"; \
27846 ripley 53
      ${code_cmd}) | ${R_EXE} ${R_SAVE_EXE} \
14411 ripley 54
        || (echo "Execution of package source for ${pkg} failed"; exit 1)
24950 luke 55
    if test ! -f NAMESPACE; then
56
        mv .RData ${rda_file}
57
    fi
27850 ripley 58
    if test "x${BUILD}" = "xCROSS"; then
59
        rm -rf ${lib1}
60
    fi
27636 ripley 61
    ## we used to install the dumped code but this seems a waste of space
62
    rm "${code_file}"
63
    # mv "${code_file}" "${code_file}.R"
24950 luke 64
    cat "${R_HOME}/share/R/${loader_file}" > "${code_file}"
16252 ripley 65
    ## if install.R is non-empty, arrange to evaluate the R code it
66
    ## contains after the package source (maybe for some kind of
67
    ## cleanup).
68
    if test -s install.R; then
69
      cat install.R >> ${lib}/${pkg}/R/${pkg}
70
    fi
13875 ripley 71
fi