Skip to content
Konrad Siek edited this page Oct 3, 2018 · 2 revisions

Installing packages

Installing system dependencies for CRAN

Debian

Installation prerequisites

I had to pin my repos in order to get some of the packages that are not in stretch from older distros:

/etc/apt/sources.list:

# deb http://ftp.debian.cz/debian stretch main

deb http://ftp.debian.cz/debian stretch main
deb-src http://ftp.debian.cz/debian stretch main

deb http://security.debian.org/debian-security stretch/updates main
deb-src http://security.debian.org/debian-security stretch/updates main

# stretch-updates, previously known as 'volatile'
deb http://ftp.debian.cz/debian stretch-updates main
deb-src http://ftp.debian.cz/debian stretch-updates main

# older release for older packages (pinned)
deb http://ftp.debian.cz/debian jessie main
deb-src http://ftp.debian.cz/debian jessie main

# even older release for even older packages (pinned)
deb http://ftp.debian.cz/debian wheezy main
deb-src http://ftp.debian.cz/debian wheezy main

/etc/apt/preferences:

Package: *
Pin: release o=Debian a=stretch
Pin-Priority: 700

Package: *
Pin: release o=Debian a=jessie
Pin-Priority: 300

Package: *
Pin: release o=Debian a=wheezy
Pin-Priority: 200

I used gdebi throughout, so install that. The alternative is to use dpkg -i instead.

sudo apt-get install gdebi

Missing packages:

  • install texlive and install-info (needed for mktexlsr in textmf)

    sudo apt-get install texlive install-info
    
  • install missing packages from http://statmath.wu.ac.at/AASC/debian/archive-amd64/

    wget http://statmath.wu.ac.at/AASC/debian/archive-amd64/aasc-base_0.5-4_all.deb \
         http://statmath.wu.ac.at/AASC/debian/archive-amd64/aasc-texmf-site_20070427-1_all.deb \
         http://statmath.wu.ac.at/AASC/debian/archive-amd64/openbugs_3.2.1-1_amd64.deb \
         http://statmath.wu.ac.at/AASC/debian/archive-amd64/mosek_6.0.0.135-2_amd64.deb
    
    sudo gdebi  aasc-base_0.5-4_all.deb
    sudo gdebi  aasc-texmf-site_20070427-1_all.deb # see below in case of problems
    sudo gdebi  openbugs_3.2.1-1_amd64.deb
    sudo gdebi  mosek_6.0.0.135-2_amd64.deb
    
  • If (or... when inadvertantly) aasc-textmf-site breaks on install with the message:

    install-info: No such file or directory for texmf-lg.info.gz
    dpkg: error processing package aasc-texmf-site (--install):
    subprocess installed post-installation script returned error exit status 1
    Errors were encountered while processing:
    aasc-texmf-site
    

    Edit /var/lib/dpkg/info/aasc-texmf-site.postinst, the path to /usr/local/share/info/texmf-lg.info.gz is wrong (give full path).

    Then: sudo dpkg --configure -a

  • mysql: install the deb containing the repo config: https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#apt-repo-fresh-install

    wget https://dev.mysql.com/get/mysql-apt-config_0.8.7-1_all.deb
    gdebi mysql-apt-config_0.8.7-1_all.deb
    sudo apt-get update
    
    

Install metapackage

Install the debian rcheck metapackage for all OS dependencies: http://statmath.wu.ac.at/AASC/debian/

sudo apt-get update
wget http://statmath.wu.ac.at/AASC/debian/rcheckserver_2.15-54_amd64.deb
sudo gdebi rcheckserver_2.15-54_amd64.deb

Alternatively install the packages independently

sudo apt-get update

sudo apt-get install subversion calibre rsync anacron xvfb xkb-data build-essential gfortran \
                     libreadline-dev time libglu1-mesa-dev xorg-dev bwidget fftw-dev graphviz-dev \
                     lam-runtime lam4-dev libboost-dev libgdal-dev libgmp3-dev libgsl-dev libperl-dev \
                     portaudio19-dev libquantlib0-dev pvm-dev libgtk2.0-dev libxml2-dev libhdf5-serial-dev \
                     imagemagick ttf-sjfonts ggobi libsprng2-dev libproj-dev dieharder libdieharder-dev \
                     libgd2-xpm-dev wordnet-dev poppler-utils locate libglade2-dev texlive-full ess auctex \
                     r-base r-recommended aasc-texmf-site jags libicu-dev libspreadsheet-parseexcel-perl \
                     libtext-csv-xs-perl libqt4-dev libxslt1-dev ant kdelibs5-dev xclip libmpfr-dev \
                     libtiff5-dev libitpp-dev xserver-xorg iwidgets4 libdb-dev noweb libfftw3-dev \
                     libprotobuf-dev libprotoc-dev protobuf-compiler libarmadillo-dev libmagickwand-dev \
                     libmpich-dev libopenmpi-dev openmpi-bin libudunits2-dev coinor-libsymphony-dev \
                     libscalapack-mpi-dev pari-gp qpdf libgeos-dev lua5.1 liblua5.2-dev libnetcdf-dev \
                     netcdf-bin libmpc-dev coinor-libclp-dev libjpeg-dev libboost-program-options-dev \
                     highlight libraptor2-dev default-jdk libglpk-dev openbugs libc6-dev-i386 libev-dev \
                     cmake mosek tk-table heirloom-mailx liboctave-dev libsndfile-dev libapparmor-dev \
                     coinor-libcgl-dev coinor-libosi-dev python-dev libpoppler-glib-dev python-pygments \
                     rst2pdf python-mechanize mongodb gdal-bin biber tcl-dev tk-dev python-numpy \
                     libhiredis-dev libnlopt-dev pandoc libv8-dev libzmq3-dev curl libapt-pkg-dev \
                     libsasl2-dev pandoc-citeproc librdf-dev ipython libsbml-dev saga libboost-regex-dev \
                     libboost-system-dev libsodium-dev libboost-iostreams-dev libpoppler-cpp-dev \
                     libhunspell-dev libimage-exiftool-perl libmagick++-dev libmagic-dev

sudo apt-get install ttf-kochi-gothic

sudo apt-get install libmysqlclient-dev libmariadb-client-lgpl-dev-compat libmariadb-dev

# these were not listed in the metapackage, but are required
sudo apt-get install libssl-dev libssh2-1-dev gdal-bin libgdal-dev 

# this conflicts...
sudo apt-get install libmariadb-client-lgpl-dev 

OpenBUGS requires manual installation, AFAIK:

PPWD="$PWD"
mkdir /tmp/OpenBUGS
cd /tmp/OpenBUGS
wget 'http://www.openbugs.net/w/OpenBUGS_3_2_3?action=AttachFile&do=get&target=OpenBUGS-3.2.3.tar.gz' -O OpenBUGS-3.2.3.tar.gz
tar zxvf OpenBUGS-3.2.3.tar.gz
cd OpenBUGS-3.2.3
./configure
make
sudo make install
cd "$PPWD"

NVCC/CUDA (on ubuntu):

wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64-deb
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

BOOST (on Ubuntu):

sudo apt-get install libboost-all-dev

Ubuntu

List of ubuntu packages (rcheck.sels): https://github.com/PRL-PRG/R-dyntrace/wiki/Ubuntu-Package-List

sudo dpkg --set-selections < rcheck.sels
sudo aptitude install
sudo apt-get dselect-upgrade

Blind leading the blind?

Downloading packages from CRAN

The directory where we want to download CRAN is $CRAN_DIR. This is not the directory where it is going to be installed, just where our local repository will be located.

export CRAN_SOURCES="/data/kondziu/R/CRAN"
mkdir -p "$CRAN_SOURCES"
rsync -rtlzv --delete cran.r-project.org::CRAN/src/contrib "$CRAN_SOURCES"

Installing Packages (CRAN and BioConductor)

Before running R, make sure you have DISPLAY set for an available X server, some packages need it; so if you are running on a remote server, you can do:

nohup Xvfb :6 -screen 0 1280x1024x24 >/dev/null 2>&1 &
export DISPLAY=:6

Create a fresh directory where packages should be installed, eg. /data/R/libs/. Set your R_LIBS to point to that directory:

export R_LIBS=/data/kondziu/R/installed
mkdir -p $R_LIBS

(TODO: set this variable in run_vignettes.sh etc. and add it to metadata)

Set all relevant environmental variables:

export R_COMPILE_PKGS=1
export R_DISABLE_BYTECODE=0
export R_ENABLE_JIT=0
export R_KEEP_PKG_SOURCE=yes

Then open up R and:

dir.create("/tmp/install_R_pkg")
setwd("/tmp/install_R_pkg")

contrib.url <- paste("file://", "/home/kondziu/R/sources/CRAN" ,"/contrib/", sep="")

install_all_of_these <- function(packages) {
    already.installed <- installed.packages()
    
    installed_packages <- setdiff(packages, already.installed[,"Package"])

    install.packages(
        pkgs=installed_packages,             # which packages to install
        contriburl=contrib.url,              # where to install packages from
        # lib=R_LIBS,                        # where to install packages to
        Ncpus=8,                             # run in parallel using N cores
        #keep_outputs=T,                     # keeps outputs in ".out" files in current directory
        INSTALL_opts=c(
            "--byte-compile",                # byte-compile packages
            "--example",                     # extract and keep examples
            "--install-tests",               # copy and retain test directory for the package
            "--with-keep.source",            # keep line numbers
            "--no-multiarch"),
        dependencies = c("Depends")          # also install packages this package requires
        #    "Imports",
        #    "LinkingTo",
        #    "Suggests",
        #    "Enhances"))                
    )
}

source("https://bioconductor.org/biocLite.R")
library(BiocInstaller)

install_all_of_these_bioc <- function(packages) {
    already.installed <- installed.packages()
    installed_packages <- setdiff(packages, already.installed[,"Package"])
    biocLite(
        installed_packages,                  # which packages to install
        Ncpus=8,                             # run in parallel using N cores
        INSTALL_opts=c(
            "--byte-compile",                # byte-compile packages
            "--example",                     # extract and keep examples
            "--install-tests",               # copy and retain test directory for the package
            "--with-keep.source",            # keep line numbers
            "--no-multiarch"),
        dependencies = c("Depends")          # also install packages this package requires
    )
}

packages_status <- function() {
    already_installed_packages <- installed.packages()[, "Package"]

    all_cran_packages <- available.packages(contriburl=contrib.url)[, "Package"]
    already_installed_cran_packages <- intersect(all_cran_packages, already_installed_packages)

    all_bioc_packages <- available.packages(repos = biocinstallRepos()[1])[, "Package"]
    already_installed_bioc_packages <- intersect(all_bioc_packages, already_installed_packages)

    all_packages <- union(all_cran_packages, all_bioc_packages)

    data.frame(
        all_packages=length(all_packages), 
        all_already_installed_packages=length(already_installed_packages),
        cran_packages=length(all_cran_packages),
        cran_already_installed_packages=length(already_installed_cran_packages),
        bioc_packages=length(all_bioc_packages),
        bioc_already_installed_packages=length(already_installed_bioc_packages)
    )
}

get_packages_to_install_cran <- function () {
    all.packages <- available.packages(contriburl=contrib.url)
    already.installed <- installed.packages()
    setdiff(all.packages[,"Package"], already.installed[,"Package"])
}


get_packages_to_install_bioc <- function () {
    all.packages <- available.packages(repos = biocinstallRepos()[1])
    already.installed <- installed.packages()
    setdiff(all.packages[,"Package"], already.installed[,"Package"])
}


install_all_of_these(get_packages_to_install_cran())
install_all_of_these_bioc(get_packages_to_install_cran())
install_all_of_these_bioc(get_packages_to_install_bioc())