-
Notifications
You must be signed in to change notification settings - Fork 2
/
INSTALL
427 lines (386 loc) · 11.5 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
#! /bin/sh
#
# ${R_HOME}/bin/INSTALL for installing add-on packages
# Generated automatically from INSTALL.in by configure.
revision='$Revision: 1.1 $'
version=`set - ${revision}; echo ${2}`
version="R add-on package installer ${version}
Copyright (C) 2000 The R Core Development Team.
This is free software; see the GNU General Public Licence version 2
or later for copying conditions. There is NO warranty."
usage="Usage: R CMD INSTALL [options] pkgs
Install the add-on packages specified by pkgs into the default R library
tree (${R_HOME}/library) or the tree specified via \`--library'. The
elements of pkgs can be relative or absolute paths to directories with
the package (bundle) sources, or to gzipped package \`tar' archives.
Options:
-h, --help print short help message and exit
-v, --version print version info and exit
--configure-args=ARGS
set args for package's configure script (if any)
-s, --save Save the package source as an image file, and arrange for
this file to be loaded when the library is attached.
-c, --clean remove all files created during installation
-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
--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'
Report bugs to <r-bugs@r-project.org>."
R_VERSION='1.3.0'
INSTALL='/usr/bin/install -c'
MAKE=${MAKE-make}
NO_PERL5=false
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/"
PERL=${PERL-/usr/bin/perl}
tmpdir="${TMPDIR-/tmp}/R.INSTALL.$$"
umask 022
# Get one field including all continuation lines from a DCF file.
get_dcf_field () {
ws="[ ]" # space and tab
sed -n "/^${1}:/,/^[^ ]/{p;}" ${2} | \
sed -n "/^${1}:/{s/^${1}:${ws}*//;p;}
/^${ws}/{s/^${ws}*//;p;}"
}
# get the full path names to all packages contained in $1; modifies pkgs
get_packages () {
if grep -s "^Contains:" "${1}/DESCRIPTION"; then
bundlepkg=`get_dcf_field Contains "${1}/DESCRIPTION"`
for p in ${bundlepkg}; do
pkgs="${pkgs} \"`cd "${1}/${p}"; pwd`\""
if test -f "${1}/${p}/DESCRIPTION.in"; then
cat "${1}/${p}/DESCRIPTION.in" > "${1}/${p}/DESCRIPTION"
grep -v "^Contains:" "${1}/DESCRIPTION" >> "${1}/${p}/DESCRIPTION"
fi
done
else
pkgs="${pkgs} \"`cd "${1}"; pwd`\""
fi
}
lib=${R_HOME}/library
pkgs=
clean=false
debug=false
error=false
build_text=true
build_html=true
build_latex=true
build_example=true
build_help=true
build_help_opts=
use_configure=true
use_zip_data=
use_zip_help=
save="CHECK"
while test -n "${1}"; do
case ${1} in
-h|--help)
echo "${usage}"; exit 0 ;;
-v|--version)
echo "${version}"; exit 0 ;;
-c|--clean)
clean=true ;;
-s|--save)
save=true ;;
--no-save)
save=false ;;
-d|--debug)
debug=true ;;
--no-configure)
use_configure=false ;;
--no-docs)
build_text=false
build_html=false
build_latex=false
build_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=true
use_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/[^=]*=//'` ;;
*)
if test -f "${1}"; then
mkdir -p ${tmpdir}
pkgname=`basename "${1}"`
pkgname=`echo "${pkgname}" | sed 's/_.*//'`
gzip -dc "${1}" | (cd ${tmpdir} && tar -xf -)
if test -d "${tmpdir}/${pkgname}"; then
get_packages "${tmpdir}/${pkgname}"
else
echo "ERROR: cannot extract package from ${1}"
exit 1
fi
elif test -d "${1}"; then
get_packages "${1}"
else
echo "WARNING: package \`${1}' does not exist"
fi
;;
esac
shift
done
if test -z "${pkgs}"; then
echo "ERROR: no packages specified"
exit 1
fi
if test -d ${lib} -a -w ${lib} || mkdir ${lib} 2> /dev/null; then
lib=`cd ${lib}; pwd`
cp ${R_HOME}/doc/html/R.css ${lib}
else
echo "ERROR: cannot write to or create directory \`${lib}'"
exit 2
fi
if ${build_text}; then
build_help_opts="${build_help_opts} --txt"
fi
if ${build_html}; then
build_help_opts="${build_help_opts} --html"
fi
if ${build_latex}; then
build_help_opts="${build_help_opts} --latex"
fi
if ${build_example}; then
build_help_opts="${build_help_opts} --example"
fi
if test -z "${build_help_opts}"; then
build_help=false
elif ${debug}; then
build_help_opts="--debug ${build_help_opts}"
fi
do_install () {
cd "${1}"
pkg=`basename "${1}"`
depends=`get_dcf_field Depends DESCRIPTION`
depends=`echo ${depends} | grep 'R *('`
if test "${depends}"; then
depends=`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; then
echo "ERROR: This R is version ${R_VERSION}"
echo " package \`${pkg}' depends on R ${dep_version}"
exit 1;
fi
fi
mkdir -p ${lib}/${pkg} || exit 3
if test -d man; then
## Assume this is a source package.
## FIXME: Do we have a better test?
echo "Installing source package \`${pkg}' ..."
## Make the destination directories available to the developer's
## installation scripts (e.g. configure, etc.)
R_PACKAGE_DIR=${lib}/${pkg}
R_LIBRARY_DIR=${lib}
R_PACKAGE_NAME=${pkg}
export R_LIBRARY_DIR
export R_PACKAGE_DIR
export R_PACKAGE_NAME
if ${use_configure} && test -x ./configure ; then
./configure ${configure_args}
if test ${?} -ne 0; then
echo "ERROR: Configuration failed for package \`${pkg}'"
exit 4
fi
fi
if test -d src; then
echo " libs"
if ${debug}; then set -x; fi
mkdir -p ${lib}/${pkg}/libs
if test -f src/Makefile; then
cd src;
makefiles="-f ${R_HOME}/etc/Makeconf -f Makefile"
if test -r Makevars; then
makefiles="-f Makevars ${makefiles}"
fi
${MAKE} ${makefiles} \
&& cp *.so ${lib}/${pkg}/libs \
|| error=true; \
if ${clean}; then
${MAKE} clean
fi
cd ..
else
cd src;
srcs=`ls *.[cfC] *.cc *.cpp 2>/dev/null`
if test -n "${srcs}"; then
sh ${R_HOME}/bin/SHLIB -o ${pkg}.so ${srcs} \
&& cp *.so ${lib}/${pkg}/libs \
|| error=true; \
if ${clean}; then
rm -f .libs _libs *.o *.so
fi
else
echo "WARNING: no source files found"
fi
cd ..
fi
if ${error}; then
echo "ERROR: Compilation failed for package \`${pkg}'"
exit 5
fi
if ${debug}; then set +x; fi
fi
if test -d R; then
echo " R"
mkdir -p ${lib}/${pkg}/R
cat `ls R/*.[RSqrs] R/unix/*.[RSqrs] 2>/dev/null` \
> ${lib}/${pkg}/R/${pkg}
fi
if test -d data; then
echo " data"
mkdir -p ${lib}/${pkg}/data
cp data/* ${lib}/${pkg}/data
chmod 644 ${lib}/${pkg}/data/*
if test -n "${use_zip_data}" \
-a -n "${R_UNZIPCMD}" \
-a -n "${R_ZIPCMD}"; then
(cd ${lib}/${pkg}/data;
find . -type f -print > filelist
${R_ZIPCMD} -m Rdata * -x filelist 00Index)
fi
fi
if test -d exec; then
echo " exec"
mkdir -p ${lib}/${pkg}/exec
cp exec/* ${lib}/${pkg}/exec
chmod 755 ${lib}/${pkg}/exec/*
fi
if test -d inst; then
echo " inst"
cp -r inst/* ${lib}/${pkg}
fi
case $save in
CHECK) if test -r INSTALL.R; then R_SAVE_IMAGE=true; else R_SAVE_IMAGE=false; fi;;
*) R_SAVE_IMAGE=$save;;
esac
export R_SAVE_IMAGE
if ${R_SAVE_IMAGE}; then
echo " save image"
if test -s "R_PROFILE.R"; then true
else
echo "options(echo=FALSE)" > R_PROFILE.R
fi
R_PROFILE=./R_PROFILE.R
export R_PROFILE
(echo " .lib.loc <- c(\"${lib}\", .lib.loc)"; cat ${lib}/${pkg}/R/${pkg}; echo "rm(.lib.loc)") | ${R_HOME}/bin/R --save --silent|| (echo "Execution of package source for ${pkg} failed"; exit 1)
mv .RData ${lib}/${pkg}/R/all.rda
mv ${lib}/${pkg}/R/${pkg} ${lib}/${pkg}/R/${pkg}.R
if test -s INSTALL.R; then cp INSTALL.R ${lib}/${pkg}/R/${pkg}
else
cat > ${lib}/${pkg}/R/${pkg} <<EOF
.First.lib <- function(libname, pkgname) {
fullName <- paste("package", pkgname, sep=":")
myEnv <- pos.to.env(match(fullName, search()))
dataFile <- file.path(libname, pkgname, "R", "all.rda")
rm(.First.lib, envir = myEnv)
load(dataFile, myEnv)
if(exists(".First.lib", envir = myEnv, inherits = FALSE)) {
f <- get(".First.lib", envir = myEnv, inherits = FALSE)
if(is.function(f))
f(libname, pkgname)
else
stop(paste("package \"", pkgname, "\"has a non-function .First", sep=""))
}
}
EOF
fi
fi
for f in COPYING DESCRIPTION INDEX; do
if test -f ${f}; then cp ${f} ${lib}/${pkg}; fi
done
title=`grep -s "^Title:" DESCRIPTION | sed "s/^Title:[ \t]*//"`
if test "${title}"; then
${PERL} ${R_HOME}/share/perl/maketitle.pl DESCRIPTION \
> ${lib}/${pkg}/TITLE
elif test -f TITLE; then
cp TITLE ${lib}/${pkg}
fi
## stamp DESCRIPTION with build information
echo "Built: R" ${R_VERSION}\; ${R_PLATFORM}\; `date` \
>> ${lib}/${pkg}/DESCRIPTION
if test -d man; then
echo " help"
if ${build_help}; then
if ${NO_PERL5}; then
echo "${NO_PERL5_MSG}"
else
if ${debug}; then
echo " ${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}/CONTENTS
if test ${lib} = ${R_HOME}/library; then
${R_HOME}/bin/build-help --htmllists
cat ${R_HOME}/library/*/CONTENTS \
> ${R_HOME}/doc/html/search/index.txt
fi
fi
if test -n "${use_zip_help}" \
-a -n "${R_UNZIPCMD}" \
-a -n "${R_ZIPCMD}"; then
cd ${lib}/${pkg}
if test -d R-ex; then
(cd R-ex; ${R_ZIPCMD} -m Rex *.R)
fi
## NOT YET:
## if test -d latex; then
## (cd latex; ${R_ZIPCMD} -m Rhelp *.tex)
## fi
if test -d help; then
(cd help; ${R_ZIPCMD} -m Rhelp * -x 00Titles AnIndex);
fi
fi
fi
else
echo " No man pages found in package \`${pkg}'"
fi
if ${clean}; then
if test -x ./cleanup ; then
./cleanup
fi
fi
else
## Assume this is a binary package
echo "Installing binary package \`${pkg}' ..."
cp -r . ${lib}/${pkg}
fi
(cd ${lib}; cat */TITLE > LibIndex 2> /dev/null)
chmod -R a+r ${lib}/${pkg}
echo " DONE (${pkg})"
echo
}
eval "for pkg in ${pkgs}; do do_install \"\${pkg}\"; done"
if test -d "${tmpdir}"; then
cd /
rm -rf "${tmpdir}"
fi
echo "DONE (INSTALL)"
### Local Variables: ***
### mode: sh ***
### sh-indentation: 2 ***
### End: ***