#!/bin/bash

if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
    set -x
fi
set -eu
set -o pipefail

echo "START: installing MapR core dependencies"

if [ "$DISTRO_NAME" = "ubuntu" ]; then
    # Required for libicu48
    cat >> /etc/apt/sources.list.d/security_repo.list << EOF
deb http://security.ubuntu.com/ubuntu precise-security main
EOF
    # Required for libmysqlclient16
    cat >> /etc/apt/sources.list.d/security_repo.list << EOF
deb http://old-releases.ubuntu.com/ubuntu lucid-security main
EOF
    apt-get update
    install-packages binutils \
    daemon \
    dpkg-dev \
    dpkg-repack \
    gcc \
    gcc-4.8 \
    gcc-doc \
    gcc-multilib \
    iputils-arping \
    libasan0 \
    libatomic1 \
    libc-dev-bin \
    libc6 \
    libc6-dev \
    libcrypt-passwdmd5-perl \
    libgcc-4.8-dev \
    libgomp1 \
    libgssglue1 \
    libicu48 \
    libitm1 \
    libmysqlclient-dev \
    libmysqlclient16 \
    libmysqlclient18 \
    libnfsidmap2 \
    libquadmath0 \
    libsasl2-dev \
    libsasl2-modules-gssapi-mit \
    libssl0.9.8 \
    libtirpc1 \
    libtsan0 \
    libxslt1.1 \
    linux-libc-dev \
    manpages-dev \
    mtools \
    mysql-common \
    nfs-common \
    open-iscsi \
    openjdk-6-jre \
    rpcbind \
    sdparm \
    syslinux \
    syslinux-common \
    unzip \
    watchdog \
    zlib1g-dev \
    zip
elif [ "$DISTRO_NAME" = "centos" -o "$DISTRO_NAME" = "centos7" -o "$DISTRO_NAME" = "rhel" -o "$DISTRO_NAME" = "rhel7" ]; then
    install-packages cdparanoia-libs \
    cups \
    cups-libs \
    createrepo \
    cvs \
    cyrus-sasl-gssapi \
    cyrus-sasl-plain \
    db4-cxx \
    db4-devel \
    foomatic \
    foomatic-db \
    foomatic-db-filesystem \
    foomatic-db-ppds \
    gdbm-devel \
    gettext \
    ghostscript \
    ghostscript-fonts \
    glibc \
    glibc-common \
    glibc-devel \
    glibc-headers \
    gstreamer \
    gstreamer-plugins-base \
    gstreamer-tools \
    hdparm \
    irqbalance \
    iso-codes \
    kernel-headers \
    lcms-libs \
    libXt \
    libXv \
    libXxf86vm \
    libgomp \
    libgssglue \
    libgudev1 \
    libicu \
    libmng \
    liboil \
    libtheora \
    libtirpc \
    libvisual \
    libxslt \
    mesa-dri-drivers \
    mesa-dri-filesystem \
    mesa-dri1-drivers \
    mesa-libGL \
    mesa-libGLU \
    mesa-private-llvm \
    mtools \
    nc \
    numactl \
    openjpeg-libs \
    patch \
    pax \
    perl-CGI \
    perl-ExtUtils-MakeMaker \
    perl-ExtUtils-ParseXS \
    perl-Test-Harness \
    perl-Test-Simple \
    perl-devel \
    phonon-backend-gstreamer \
    poppler \
    poppler-data \
    poppler-utils \
    portreserve \
    qt \
    qt-sqlite \
    qt-x11 \
    qt3 \
    redhat-lsb \
    redhat-lsb-compat \
    redhat-lsb-core \
    redhat-lsb-graphics \
    redhat-lsb-printing \
    rpcbind \
    sdparm \
    soci \
    soci-mysql \
    syslinux \
    syslinux-nonlinux \
    unzip \
    urw-fonts \
    yum-utils \
    xml-common \
    zip
fi

echo "END: installing MapR core dependencies"
