-
Notifications
You must be signed in to change notification settings - Fork 432
/
Copy pathr.rb
659 lines (575 loc) · 25.4 KB
/
r.rb
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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# Maintained by:
# Jim Hester @jimhester james.hester@rstudio.com
# Jeroen Ooms @jeroen jeroen@berkeley.edu
#
module Travis
module Build
class Script
class R < Script
DEFAULTS = {
# Basic config options
cran: 'https://cloud.r-project.org',
repos: {},
warnings_are_errors: true,
# Dependencies (installed in this order)
apt_packages: [],
brew_packages: [],
r_binary_packages: [],
r_packages: [],
bioc_packages: [],
r_github_packages: [],
# Build/test options
r_build_args: '',
r_check_args: '--as-cran',
# Heavy dependencies
pandoc: true,
latex: true,
fortran: true,
pandoc_version: '2.2',
# Bioconductor
bioc: 'https://bioconductor.org/biocLite.R',
bioc_required: false,
bioc_check: false,
bioc_use_devel: false,
disable_homebrew: false,
use_devtools: false,
r: 'release'
}
def initialize(data)
# TODO: Is there a way to avoid explicitly naming arguments here?
super
@remotes_installed = false
@devtools_installed = false
@bioc_installed = false
end
def export
super
sh.export 'TRAVIS_R_VERSION', r_version, echo: false
sh.export 'TRAVIS_R_VERSION_STRING', config[:r].to_s, echo: false
sh.export 'R_LIBS_USER', '~/R/Library', echo: false
sh.export 'R_LIBS_SITE', '/usr/local/lib/R/site-library:/usr/lib/R/site-library', echo: false
sh.export '_R_CHECK_CRAN_INCOMING_', 'false', echo: false
sh.export 'NOT_CRAN', 'true', echo: false
end
def configure
super
sh.echo 'R for Travis-CI is not officially supported, '\
'but is community maintained.', ansi: :green
sh.echo 'Please file any issues at https://travis-ci.community/c/languages/r'
sh.echo 'and mention @jeroen and @jimhester in the issue'
sh.fold 'R-install' do
sh.with_options({ assert: true, echo: true, timing: true }) do
sh.echo 'Installing R', ansi: :yellow
case config[:os]
when 'linux'
if config[:arch] == 'arm64'
sh.failure 'ARM architecture not supported'
end
if config[:dist] == 'trusty'
sh.failure '"dist: trusty" is no longer supported for "language: r"'
end
# This key is added implicitly by the marutter PPA below
#sh.cmd 'apt-key adv --keyserver ha.pool.sks-keyservers.net '\
#'--recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9', sudo: true
# Add marutter's c2d4u plus ppa dependencies as listed on launchpad
if r_version_less_than('3.5.0')
sh.cmd 'sudo add-apt-repository -y "ppa:marutter/rrutter"'
sh.cmd 'sudo add-apt-repository -y "ppa:marutter/c2d4u"'
elsif r_version_less_than('4.0.0')
sh.cmd 'sudo add-apt-repository -y "ppa:marutter/rrutter3.5"'
sh.cmd 'sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"'
else
sh.cmd 'sudo add-apt-repository -y "ppa:marutter/rrutter4.0"'
sh.cmd 'sudo add-apt-repository -y "ppa:c2d4u.team/c2d4u4.0+"'
end
# Extra PPAs that do not depend on R version
sh.cmd 'sudo add-apt-repository -y "ppa:ubuntugis/ppa"'
sh.cmd 'sudo add-apt-repository -y "ppa:cran/travis"'
# Update after adding all repositories. Retry several
# times to work around flaky connection to Launchpad PPAs.
sh.cmd 'travis_apt_get_update', retry: true
# Install precompiled R
# Install only the dependencies for an R development environment except for
# libpcre3-dev or r-base-core because they will be included in
# the R binary tarball.
# Dependencies queried with `apt-cache depends -i r-base-dev`.
# qpdf and texinfo are also needed for --as-cran # checks:
# https://stat.ethz.ch/pipermail/r-help//2012-September/335676.html
optional_apt_pkgs = ""
optional_apt_pkgs << "gfortran" if config[:fortran]
sh.cmd 'sudo apt-get install -y --no-install-recommends '\
'build-essential gcc g++ libblas-dev liblapack-dev '\
'libncurses5-dev libreadline-dev libjpeg-dev '\
'libpcre3-dev libpng-dev zlib1g-dev libbz2-dev liblzma-dev libicu-dev '\
'cdbs qpdf texinfo libssh2-1-dev devscripts '\
"#{optional_apt_pkgs}", retry: true
r_filename = "r-#{r_version}_1_amd64.deb"
os_version = "$(lsb_release -rs | tr -d '.')"
r_url = "https://cdn.rstudio.com/r/ubuntu-#{os_version}/pkgs/#{r_filename}"
sh.cmd "curl -fLo /tmp/#{r_filename} #{r_url}", retry: true
sh.cmd "sudo apt-get install -y gdebi-core"
sh.cmd "sudo gdebi --non-interactive /tmp/#{r_filename}"
sh.export 'PATH', "/opt/R/#{r_version}/bin:$PATH", echo: false
sh.rm "/tmp/#{r_filename}"
sh.cmd "sudo mkdir -p /usr/local/lib/R/site-library $R_LIBS_USER"
sh.cmd 'sudo chmod 2777 /usr/local/lib/R /usr/local/lib/R/site-library $R_LIBS_USER'
when 'osx'
# We want to update, but we don't need the 800+ lines of
# output.
unless config[:disable_homebrew]
sh.cmd 'brew update >/dev/null', retry: true
sh.cmd 'brew install checkbashisms || true'
end
# R-devel builds available at mac.r-project.org
if r_version == 'devel'
r_url = "https://mac.r-project.org/high-sierra/R-devel/R-devel.pkg"
# The latest release is the only one available in /bin/macosx
elsif r_version == r_latest
r_url = "#{repos[:CRAN]}/bin/macosx/R-latest.pkg"
# 3.2.5 was never built for OS X so
# we need to use 3.2.4-revised, which is the same codebase
# https://stat.ethz.ch/pipermail/r-devel/2016-May/072642.html
elsif r_version == '3.2.5'
r_url = "#{repos[:CRAN]}/bin/macosx/old/R-3.2.4-revised.pkg"
# the old archive has moved after 3.4.0
elsif r_version_less_than('3.4.0')
r_url = "#{repos[:CRAN]}/bin/macosx/old/R-#{r_version}.pkg"
else
r_url = "#{repos[:CRAN]}/bin/macosx/el-capitan/base/R-#{r_version}.pkg"
end
# Install from latest CRAN binary build for OS X
sh.cmd "curl -fLo /tmp/R.pkg #{r_url}", retry: true
sh.echo 'Installing OS X binary package for R'
sh.cmd 'sudo installer -pkg "/tmp/R.pkg" -target /'
sh.rm '/tmp/R.pkg'
setup_fortran_osx if config[:fortran]
else
sh.failure "Operating system not supported: #{config[:os]}"
end
# Set repos in ~/.Rprofile
repos_str = repos.collect {|k,v| "#{k} = \"#{v}\""}.join(", ")
options_repos = "options(repos = c(#{repos_str}))"
sh.cmd %Q{echo '#{options_repos}' > ~/.Rprofile.site}
sh.export 'R_PROFILE', "~/.Rprofile.site", echo: false
# PDF manual requires latex
if config[:latex]
setup_latex
else
config[:r_check_args] = config[:r_check_args] + " --no-manual"
config[:r_build_args] = config[:r_build_args] + " --no-manual"
end
setup_pandoc if config[:pandoc]
# Removes preinstalled homebrew
disable_homebrew if config[:disable_homebrew]
end
end
end
def announce
super
sh.fold 'R-session-info' do
sh.echo 'R session information', ansi: :yellow
sh.cmd 'Rscript -e \'sessionInfo()\''
end
end
def install
super
sh.if '! -e DESCRIPTION' do
sh.failure "No DESCRIPTION file found, user must supply their own install and script steps"
end
setup_bioc if needs_bioc?
sh.fold "R-dependencies" do
sh.echo 'Installing package dependencies', ansi: :yellow
# Install any declared packages
apt_install config[:apt_packages]
brew_install config[:brew_packages]
r_binary_install config[:r_binary_packages]
r_install config[:r_packages]
r_install config[:bioc_packages]
r_github_install config[:r_github_packages]
# Install dependencies for the package we're testing.
install_deps
end
if @devtools_installed
sh.fold 'R-installed-versions' do
sh.echo 'Installed package versions', ansi: :yellow
sh.cmd 'Rscript -e \'devtools::session_info(installed.packages()[, "Package"])\''
end
end
end
def script
# Build the package
sh.if '! -e DESCRIPTION' do
sh.failure "No DESCRIPTION file found, user must supply their own install and script steps"
end
tarball_script =
'$version = $1 if (/^Version:\s(\S+)/);'\
'$package = $1 if (/^Package:\s*(\S+)/);'\
'END { print "${package}_$version.tar.gz" }'\
sh.export 'PKG_TARBALL', "$(perl -ne '#{tarball_script}' DESCRIPTION)", echo: false
sh.fold 'R-build' do
sh.echo 'Building package', ansi: :yellow
sh.echo "Building with: R CMD build ${R_BUILD_ARGS}"
sh.cmd "R CMD build #{config[:r_build_args]} .",
assert: true
end
# Check the package
sh.fold 'R-check' do
sh.echo 'Checking package', ansi: :yellow
# Test the package
sh.echo 'Checking with: R CMD check "${PKG_TARBALL}" '\
"#{config[:r_check_args]}"
sh.cmd "R CMD check \"${PKG_TARBALL}\" #{config[:r_check_args]}; "\
"CHECK_RET=$?", assert: false
end
export_rcheck_dir
if config[:bioc_check]
# BiocCheck the package
sh.fold 'Bioc-check' do
sh.echo 'Checking with: BiocCheck( "${PKG_TARBALL}" ) '
sh.cmd 'Rscript -e "BiocCheck::BiocCheck(\"${PKG_TARBALL}\", \'quit-with-status\'=TRUE)"'
end
end
if @devtools_installed
# Output check summary
sh.cmd 'Rscript -e "message(devtools::check_failures(path = \"${RCHECK_DIR}\"))"', echo: false
end
# Build fails if R CMD check fails
sh.if '$CHECK_RET -ne 0' do
dump_error_logs
sh.failure 'R CMD check failed'
end
# Turn warnings into errors, if requested.
if config[:warnings_are_errors]
sh.cmd 'grep -q -R "WARNING" "${RCHECK_DIR}/00check.log"', echo: false, assert: false
sh.if '$? -eq 0' do
dump_error_logs
sh.failure "Found warnings, treating as errors (as requested)."
end
end
end
def setup_cache
if data.cache?(:packages)
sh.fold 'package cache' do
sh.echo 'Setting up package cache', ansi: :yellow
directory_cache.add '$R_LIBS_USER'
end
end
end
def cache_slug
super << '--R-' << r_version
end
def use_directory_cache?
super || data.cache?(:packages)
end
private
def needs_bioc?
config[:bioc_required] || !config[:bioc_packages].empty?
end
def packages_as_arg(packages)
packages = Array(packages)
quoted_pkgs = packages.collect{|p| "\"#{p}\""}
"c(#{quoted_pkgs.join(', ')})"
end
def as_r_boolean(bool)
bool ? "TRUE" : "FALSE"
end
def r_install(packages)
return if packages.empty?
packages = Array(packages)
sh.echo "Installing R packages: #{packages.join(', ')}"
pkg_arg = packages_as_arg(packages)
install_script =
"install.packages(#{pkg_arg});"\
"if (!all(#{pkg_arg} %in% installed.packages())) {"\
' q(status = 1, save = "no")'\
'}'
sh.cmd "Rscript -e '#{install_script}'"
end
def r_github_install(packages)
return if packages.empty?
packages = Array(packages)
setup_remotes
setup_devtools if config[:use_devtools]
sh.echo "Installing R packages from GitHub: #{packages.join(', ')}"
pkg_arg = packages_as_arg(packages)
install_script = "remotes::install_github(#{pkg_arg})"
sh.cmd "Rscript -e '#{install_script}'"
end
def r_binary_install(packages)
return if packages.empty?
packages = Array(packages)
if config[:os] == 'linux'
if config[:dist] == 'precise'
sh.echo "R binary packages not supported for 'dist: precise', "\
' falling back to source install'
return r_install packages
end
sh.echo "Installing *binary* R packages: #{packages.join(', ')}"
apt_install packages.collect{|p| "r-cran-#{p.downcase}"}
else
sh.echo "R binary packages not supported on #{config[:os]}, "\
'falling back to source install'
r_install packages
end
end
def apt_install(packages)
return if packages.empty?
packages = Array(packages)
return unless (config[:os] == 'linux')
pkg_arg = packages.join(' ')
sh.echo "Installing apt packages: #{packages.join(', ')}"
sh.cmd "sudo apt-get install -y #{pkg_arg}", retry: true
end
def brew_install(packages)
return if packages.empty?
packages = Array(packages)
return unless (config[:os] == 'osx')
pkg_arg = packages.join(' ')
sh.echo "Installing brew packages: #{packages.join(', ')}"
sh.cmd "brew install #{pkg_arg}", retry: true
end
def install_deps
setup_remotes
setup_devtools if config[:use_devtools]
install_script =
'deps <- remotes::dev_package_deps(dependencies = NA);'\
'remotes::install_deps(dependencies = TRUE);'\
'if (!all(deps$package %in% installed.packages())) {'\
' message("missing: ", paste(setdiff(deps$package, installed.packages()), collapse=", "));'\
' q(status = 1, save = "no")'\
'}'
sh.cmd "Rscript -e '#{install_script}'"
end
def export_rcheck_dir
# Simply strip the tarball name until the last _ and add '.Rcheck',
# relevant R code # https://github.com/wch/r-source/blob/840a972338042b14aa5855cc431b2d0decf68234/src/library/tools/R/check.R#L4608-L4615
sh.export 'RCHECK_DIR', "$(expr \"$PKG_TARBALL\" : '\\(.*\\)_').Rcheck", echo: false
end
def dump_error_logs
dump_log("fail")
dump_log("log")
dump_log("out")
end
def dump_log(type)
sh.fold "#{type} logs" do
sh.echo "R CMD check #{type} logs", ansi: :yellow
cmd =
'for name in '\
"$(find \"${RCHECK_DIR}\" -type f -name \"*#{type}\");"\
'do '\
'echo ">>> Filename: ${name} <<<";'\
'cat ${name};'\
'done'
sh.cmd cmd
end
end
def setup_bioc
unless @bioc_installed
sh.fold 'Bioconductor' do
sh.echo 'Installing Bioconductor', ansi: :yellow
bioc_install_script =
if r_version_less_than("3.5.0")
"source(\"#{config[:bioc]}\");"\
'tryCatch('\
" useDevel(#{as_r_boolean(config[:bioc_use_devel])}),"\
' error=function(e) {if (!grepl("already in use", e$message)) {e}}'\
' );'\
'cat(append = TRUE, file = "~/.Rprofile.site", "options(repos = BiocInstaller::biocinstallRepos());")'
else
'if (!requireNamespace("BiocManager", quietly=TRUE))'\
' install.packages("BiocManager");'\
"if (#{as_r_boolean(config[:bioc_use_devel])})"\
' BiocManager::install(version = "devel", ask = FALSE);'\
'cat(append = TRUE, file = "~/.Rprofile.site", "options(repos = BiocManager::repositories());")'
end
sh.cmd "Rscript -e '#{bioc_install_script}'", retry: true
bioc_install_bioccheck =
if r_version_less_than("3.5.0")
'BiocInstaller::biocLite("BiocCheck")'
else
'BiocManager::install("BiocCheck")'
end
if config[:bioc_check]
sh.cmd "Rscript -e '#{bioc_install_bioccheck}'"
end
end
end
@bioc_installed = true
end
def setup_remotes
unless @remotes_installed
case config[:os]
when 'linux'
# We can't use remotes binaries because R versions < 3.5 are not
# compatible with R versions >= 3.5
r_install ['remotes']
else
remotes_check = '!requireNamespace("remotes", quietly = TRUE)'
remotes_install = 'install.packages("remotes")'
sh.cmd "Rscript -e 'if (#{remotes_check}) #{remotes_install}'",
retry: true
end
end
@remotes_installed = true
end
def setup_devtools
unless @devtools_installed
case config[:os]
when 'linux'
# We can't use devtools binaries because R versions < 3.5 are not
# compatible with R versions >= 3.5
r_install ['devtools']
else
devtools_check = '!requireNamespace("devtools", quietly = TRUE)'
devtools_install = 'install.packages("devtools")'
sh.cmd "Rscript -e 'if (#{devtools_check}) #{devtools_install}'",
retry: true
end
end
@devtools_installed = true
end
def setup_latex
case config[:os]
when 'linux'
texlive_filename = 'texlive.tar.gz'
texlive_url = 'https://github.com/jimhester/ubuntu-bin/releases/download/latest/texlive.tar.gz'
sh.cmd "curl -fLo /tmp/#{texlive_filename} #{texlive_url}", retry: true
sh.cmd "tar xzf /tmp/#{texlive_filename} -C ~"
sh.export 'PATH', "${TRAVIS_HOME}/texlive/bin/x86_64-linux:$PATH"
sh.cmd 'tlmgr update --self', assert: false
when 'osx'
# We use basictex due to disk space constraints.
mactex = 'BasicTeX.pkg'
# TODO: Confirm that this will route us to the nearest mirror.
sh.cmd "curl -fLo \"/tmp/#{mactex}\" --retry 3 http://mirror.ctan.org/systems/mac/mactex/"\
"#{mactex}"
sh.echo 'Installing OS X binary package for MacTeX'
sh.cmd "sudo installer -pkg \"/tmp/#{mactex}\" -target /"
sh.rm "/tmp/#{mactex}"
sh.export 'PATH', '/usr/texbin:/Library/TeX/texbin:$PATH'
sh.cmd 'sudo tlmgr update --self', assert: false
# Install common packages
sh.cmd 'sudo tlmgr install inconsolata upquote '\
'courier courier-scaled helvetic', assert: false
end
end
def setup_pandoc
case config[:os]
when 'linux'
pandoc_filename = "pandoc-#{config[:pandoc_version]}-1-amd64.deb"
pandoc_url = "https://github.com/jgm/pandoc/releases/download/#{config[:pandoc_version]}/"\
"#{pandoc_filename}"
# Download and install pandoc
sh.cmd "curl -fLo /tmp/#{pandoc_filename} #{pandoc_url}"
sh.cmd "sudo dpkg -i /tmp/#{pandoc_filename}"
# Fix any missing dependencies
sh.cmd "sudo apt-get install -f"
# Cleanup
sh.rm "/tmp/#{pandoc_filename}"
when 'osx'
# Change OS name if requested version is less than 1.19.2.2
# Name change was introduced in v2.0 of pandoc.
# c.f. "Build Infrastructure Improvements" section of
# https://github.com/jgm/pandoc/releases/tag/2.0
# Lastly, the last binary for macOS before 2.0 is 1.19.2.1
os_short_name = version_check_less_than("#{config[:pandoc_version]}", "1.19.2.2") ? "macOS" : "osx"
pandoc_filename = "pandoc-#{config[:pandoc_version]}-#{os_short_name}.pkg"
pandoc_url = "https://github.com/jgm/pandoc/releases/download/#{config[:pandoc_version]}/"\
"#{pandoc_filename}"
# Download and install pandoc
sh.cmd "curl -fLo /tmp/#{pandoc_filename} #{pandoc_url}"
sh.cmd "sudo installer -pkg \"/tmp/#{pandoc_filename}\" -target /"
# Cleanup
sh.rm "/tmp/#{pandoc_filename}"
end
end
# Install gfortran libraries the precompiled binaries are linked to
def setup_fortran_osx
return unless (config[:os] == 'osx')
if r_version_less_than('3.4')
sh.cmd 'curl -fLo /tmp/gfortran.tar.bz2 http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2', retry: true
sh.cmd 'sudo tar fvxz /tmp/gfortran.tar.bz2 -C /'
sh.rm '/tmp/gfortran.tar.bz2'
elsif r_version_less_than('3.7')
sh.cmd "curl -fLo /tmp/gfortran61.dmg #{repos[:CRAN]}/contrib/extra/macOS/gfortran-6.1-ElCapitan.dmg", retry: true
sh.cmd 'sudo hdiutil attach /tmp/gfortran61.dmg -mountpoint /Volumes/gfortran'
sh.cmd 'sudo installer -pkg "/Volumes/gfortran/gfortran-6.1-ElCapitan/gfortran.pkg" -target /'
sh.cmd 'sudo hdiutil detach /Volumes/gfortran'
sh.rm '/tmp/gfortran61.dmg'
else
sh.cmd "curl -fLo /tmp/gfortran82.dmg https://github.com/fxcoudert/gfortran-for-macOS/releases/download/8.2/gfortran-8.2-Mojave.dmg", retry: true
sh.cmd 'sudo hdiutil attach /tmp/gfortran82.dmg -mountpoint /Volumes/gfortran'
sh.cmd 'sudo installer -pkg "/Volumes/gfortran/gfortran-8.2-Mojave/gfortran.pkg" -target /'
sh.cmd 'sudo hdiutil detach /Volumes/gfortran'
sh.rm '/tmp/gfortran82.dmg'
end
end
# Uninstalls the preinstalled homebrew
# See FAQ: https://docs.brew.sh/FAQ#how-do-i-uninstall-homebrew
def disable_homebrew
return unless (config[:os] == 'osx')
sh.cmd "curl -fsSOL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh"
sh.cmd "sudo /bin/bash uninstall.sh --force"
sh.cmd "rm uninstall.sh"
sh.cmd "hash -r"
sh.cmd "git config --global --unset protocol.version || true"
end
# Abstract out version check
def version_check_less_than(version_str_new, version_str_old)
Gem::Version.new(version_str_old) < Gem::Version.new(version_str_new)
end
def r_version
@r_version ||= normalized_r_version
end
def r_version_less_than(str)
return if normalized_r_version == 'devel' # always false (devel is highest version)
version_check_less_than(str, normalized_r_version)
end
def normalized_r_version(v=Array(config[:r]).first.to_s)
case v
when 'release' then '4.0.2'
when 'oldrel' then '3.6.3'
when '3.0' then '3.0.3'
when '3.1' then '3.1.3'
when '3.2' then '3.2.5'
when '3.3' then '3.3.3'
when '3.4' then '3.4.4'
when '3.5' then '3.5.3'
when '3.6' then '3.6.3'
when '4.0' then '4.0.2'
when 'bioc-devel'
config[:bioc_required] = true
config[:bioc_use_devel] = true
config[:r] = 'release'
normalized_r_version('release')
when 'bioc-release'
config[:bioc_required] = true
config[:bioc_use_devel] = false
config[:r] = 'release'
normalized_r_version('release')
else v
end
end
def r_latest
normalized_r_version('release')
end
def repos
@repos ||= normalized_repos
end
# If CRAN is not set in repos set it with cran
def normalized_repos
v = config[:repos]
if not v.has_key?(:CRAN)
v[:CRAN] = config[:cran]
end
# If the version is less than 3.2 we need to use http repositories
if r_version_less_than('3.2')
v.each {|_, url| url.sub!(/^https:/, "http:")}
config[:bioc].sub!(/^https:/, "http:")
end
v
end
end
end
end
end