export CONDA_BUILD="1"
export PYTHONNOUSERSITE="1"
export CONDA_DEFAULT_ENV="/opt/anaconda1anaconda2anaconda3"
export ARCH="64"
export PREFIX="/opt/anaconda1anaconda2anaconda3"
export BUILD_PREFIX="/opt/conda/conda-bld/jbrowse_1550776030776/_build_env"
export SYS_PREFIX="/opt/conda"
export SYS_PYTHON="/opt/conda/bin/python"
export SUBDIR="linux-64"
export SRC_DIR="/opt/conda/conda-bld/jbrowse_1550776030776/work"
export ROOT="/opt/conda"
export CONDA_PY="27"
export PY3K="0"
export PY_VER="2.7"
export STDLIB_DIR="/opt/anaconda1anaconda2anaconda3/lib/python2.7"
export SP_DIR="/opt/anaconda1anaconda2anaconda3/lib/python2.7/site-packages"
export PYTHON="/opt/anaconda1anaconda2anaconda3/bin/python"
export NPY_VER="1.9"
export CONDA_NPY="19"
export NPY_DISTUTILS_APPEND_FLAGS="1"
export PERL_VER="5.26"
export CONDA_PERL="5.26"
export PERL="/opt/anaconda1anaconda2anaconda3/bin/perl"
export LUA_VER="5"
export CONDA_LUA="5"
export R_VER="3.5.1"
export CONDA_R="3.5.1"
export PKG_NAME="jbrowse"
export PKG_VERSION="1.16.2"
export PKG_BUILDNUM="6"
export PKG_BUILD_STRING="placeholder"
export PKG_HASH="1234567"
export RECIPE_DIR="/opt/recipe"
export CPU_COUNT="2"
export LANG="en_US.UTF-8"
export SHLIB_EXT=".so"
export PATH="/opt/conda/conda-bld/jbrowse_1550776030776/_build_env:/opt/conda/conda-bld/jbrowse_1550776030776/_build_env/bin:/opt/conda/bin:/opt/rh/devtoolset-2/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin"
export HOME="/root"
export PKG_CONFIG_PATH="/opt/anaconda1anaconda2anaconda3/lib/pkgconfig"
export CMAKE_GENERATOR="Unix Makefiles"
export LD_RUN_PATH="/opt/anaconda1anaconda2anaconda3/lib"
export BUILD="x86_64-conda_cos6-linux-gnu"
export r_base="3.5.1"
export cpu_optimization_target="nocona"
export cran_mirror="https://cran.r-project.org"
export target_platform="linux-64"
export c_compiler="gcc"
export cxx_compiler="gxx"
export fortran_compiler="gfortran"
export blas_impl="openblas"
export go_compiler="go"
export VERBOSE_AT="V=1"
export VERBOSE_CM="VERBOSE=1"
export channel_sources="conda-forge,defaults"
export channel_targets="conda-forge main"
export docker_image="condaforge/linux-anvil-comp7"
export arpack="3.6.3"
export boost="1.68.0"
export boost_cpp="1.68.0"
export bzip2="1"
export cairo="1.16"
export curl="7.59"
export dbus="1"
export expat="2.2"
export ffmpeg="4.0"
export flann="1.9.1"
export fontconfig="2.13"
export freetype="2.9.1"
export gf2x="1.2"
export gsl="2.4"
export gstreamer="1.14.4"
export gst_plugins_base="1.14.4"
export gdal="2.4"
export geos="3.7.1"
export geotiff="1.4.2"
export giflib="5.1"
export glew="2.0.0"
export glib="2.58"
export glpk="4.65"
export gmp="6"
export graphviz="2.38.0"
export harfbuzz="2"
export hdf4="4.2"
export hdf5="1.10.4"
export icu="58"
export isl="0.19"
export jasper="1.900.1"
export jpeg="9"
export libjpeg_turbo="2"
export json_c="0.13"
export jsoncpp="1.8.4"
export kealib="1.4.10"
export krb5="1.16"
export libblitz="0.10"
export libdap4="3.19"
export libevent="2.0.22"
export libffi="3.2"
export libgdal="2.4"
export libiconv="1.15"
export libkml="1.3"
export libmatio="1.5"
export libnetcdf="4.6"
export libpcap="1.8"
export libpng="1.6.35"
export libprotobuf="3.6"
export librdkafka="0.11.5"
export libsecret="0.18"
export libssh2="1.8"
export libsvm="3.21"
export libtiff="4.0.9"
export libunwind="1.2"
export libwebp="1.0.0"
export libxml2="2.9"
export libuuid="2.32.1"
export lz4_c="1.8.1"
export lzo="2"
export metis="5.1"
export mkl="2018"
export mpfr="4"
export ncurses="6.1"
export netcdf_cxx4="4.3"
export netcdf_fortran="4.4"
export nettle="3.4"
export nss="3.39"
export nspr="4.20"
export nlopt="2.5.*"
export ntl="11.3.1"
export occt="7.3"
export openblas="0.3.3"
export openjpeg="2.3"
export openssl="1.0.2"
export openturns="1.12*"
export pango="1.40"
export pixman="0.34"
export poppler="0.67.0"
export proj4="5.2.0"
export readline="7.0"
export snappy="1.1.7"
export sox="14.4.2"
export sqlite="3"
export tk="8.6"
export vlfeat="0.9.20"
export vtk="8.1.1"
export x264="1!152.*"
export xerces_c="3.2.2"
export xz="5.2"
export zeromq="4.2.5"
export zlib="1.2"
export zstd="1.3.3"
export htslib="1.9"
export bamtools="2.4.1"
export libdeflate="1.0"
export ignore_build_only_deps="python"
export pyqt="5.6"
export qt="5.6"
export zip_keys="[['pyqt', 'qt'], ['python']]"
export pin_run_as_build="OrderedDict([('python', OrderedDict([('min_pin', 'x.x'), ('max_pin', 'x.x')])), ('r-base', {'max_pin': 'x.x.x'}), ('arpack', {'max_pin': 'x.x.x'}), ('boost', {'max_pin': 'x.x.x'}), ('boost-cpp', {'max_pin': 'x.x.x'}), ('bzip2', {'max_pin': 'x'}), ('cairo', {'max_pin': 'x.x'}), ('curl', {'max_pin': 'x'}), ('dbus', {'max_pin': 'x'}), ('expat', {'max_pin': 'x.x'}), ('ffmpeg', {'max_pin': 'x.x'}), ('flann', {'max_pin': 'x.x.x'}), ('fontconfig', {'max_pin': 'x'}), ('freetype', {'max_pin': 'x'}), ('gsl', {'max_pin': 'x.x'}), ('gdal', {'max_pin': 'x.x'}), ('geos', {'max_pin': 'x.x.x'}), ('geotiff', {'max_pin': 'x.x'}), ('giflib', {'max_pin': 'x.x'}), ('glew', {'max_pin': 'x.x'}), ('glpk', {'max_pin': 'x.x'}), ('gmp', {'max_pin': 'x'}), ('graphviz', {'max_pin': 'x'}), ('harfbuzz', {'max_pin': 'x'}), ('hdf4', {'max_pin': 'x.x'}), ('icu', {'max_pin': 'x'}), ('isl', {'max_pin': 'x.x'}), ('jasper', {'max_pin': 'x'}), ('jpeg', {'max_pin': 'x'}), ('libjpeg_turbo', {'max_pin': 'x'}), ('json-c', {'max_pin': 'x.x'}), ('jsoncpp', {'max_pin': 'x.x.x'}), ('kealib', {'max_pin': 'x.x'}), ('krb5', {'max_pin': 'x.x'}), ('libblitz', {'max_pin': 'x.x'}), ('libdap4', {'max_pin': 'x.x'}), ('libevent', {'max_pin': 'x.x.x'}), ('libffi', {'max_pin': 'x.x'}), ('libgdal', {'max_pin': 'x.x'}), ('libiconv', {'max_pin': 'x.x'}), ('libkml', {'max_pin': 'x.x'}), ('libmatio', {'max_pin': 'x.x'}), ('libnetcdf', {'max_pin': 'x.x'}), ('libpcap', {'max_pin': 'x.x'}), ('libpng', {'max_pin': 'x.x'}), ('libprotobuf', {'max_pin': 'x.x'}), ('librdkafka', {'max_pin': 'x.x.x'}), ('libssh2', {'max_pin': 'x.x'}), ('libsvm', {'max_pin': 'x.x'}), ('libunwind', {'max_pin': 'x.x'}), ('libtiff', {'max_pin': 'x'}), ('libwebp', {'max_pin': 'x.x'}), ('libxml2', {'max_pin': 'x.x'}), ('libuuid', {'max_pin': 'x'}), ('lz4-c', {'max_pin': 'x.x.x'}), ('lzo', {'max_pin': 'x'}), ('metis', {'max_pin': 'x.x'}), ('mkl', {'max_pin': 'x'}), ('mpfr', {'max_pin': 'x'}), ('ncurses', {'max_pin': 'x.x'}), ('netcdf-cxx4', {'max_pin': 'x.x'}), ('netcdf-fortran', {'max_pin': 'x.x'}), ('nettle', {'max_pin': 'x.x'}), ('nlopt', {'max_pin': 'x.x.x'}), ('nss', {'max_pin': 'x'}), ('nspr', {'max_pin': 'x'}), ('occt', {'max_pin': 'x.x'}), ('openblas', {'max_pin': 'x.x.x'}), ('openturns', {'max_pin': 'x.x'}), ('openjpeg', {'max_pin': 'x.x'}), ('openssl', {'max_pin': 'x.x.x'}), ('pango', {'max_pin': 'x.x'}), ('perl', {'max_pin': 'x.x.x'}), ('pixman', {'max_pin': 'x.x'}), ('poppler', {'max_pin': 'x.x'}), ('proj4', {'max_pin': 'x.x.x'}), ('pyqt', {'max_pin': 'x.x'}), ('qt', {'max_pin': 'x.x'}), ('readline', {'max_pin': 'x'}), ('snappy', {'max_pin': 'x.x.x'}), ('sox', {'max_pin': 'x.x.x'}), ('sqlite', {'max_pin': 'x'}), ('tk', {'max_pin': 'x.x'}), ('vc', {'max_pin': 'x'}), ('vlfeat', {'max_pin': 'x.x.x'}), ('vtk', {'max_pin': 'x.x.x'}), ('xerces-c', {'max_pin': 'x.x.x'}), ('xz', {'max_pin': 'x.x'}), ('zeromq', {'max_pin': 'x.x'}), ('zlib', {'max_pin': 'x.x'}), ('zstd', {'max_pin': 'x.x.x'}), ('htslib', {'max_pin': 'x.x'}), ('bamtools', {'max_pin': 'x.x.x'}), ('libdeflate', {'max_pin': 'x.x'})])"
export CONDA_BUILD_STATE="BUILD"
export PIP_IGNORE_INSTALLED="True"
export PIP_CACHE_DIR="/opt/conda/conda-bld/jbrowse_1550776030776/pip_cache"
source "/opt/conda/bin/activate" "/opt/anaconda1anaconda2anaconda3"
unset CONDA_PATH_BACKUP
export CONDA_MAX_SHLVL=2
source "/opt/conda/bin/activate" "/opt/conda/conda-bld/jbrowse_1550776030776/_build_env"
#!/bin/bash

mkdir -p $PREFIX/etc/conda/activate.d/
echo "export JBROWSE_SOURCE_DIR=$PREFIX/opt/jbrowse" > $PREFIX/etc/conda/activate.d/jbrowse-sourcedir.sh
chmod a+x $PREFIX/etc/conda/activate.d/jbrowse-sourcedir.sh

mkdir -p $PREFIX/etc/conda/deactivate.d/
echo "unset JBROWSE_SOURCE_DIR" > $PREFIX/etc/conda/deactivate.d/jbrowse-sourcedir.sh
chmod a+x $PREFIX/etc/conda/deactivate.d/jbrowse-sourcedir.sh

cd $SRC_DIR

# Doing a full setup as we need to include some plugins, because it's not possible yet to load them at runtime
# See https://github.com/GMOD/jbrowse/issues/1288
# When/If this issue is fixed, we should get back to a quicker install from pre-compiled package:
# see https://github.com/bioconda/bioconda-recipes/tree/a2fc63ddb0a762e49c22255ff6916d7704ebd65c/recipes/jbrowse

# Add BlastView plugin
git clone https://github.com/TAMU-CPT/blastview.git plugins/BlastView/
echo "[ plugins.BlastView ]" >> jbrowse.conf
echo "location = ../plugin/BlastView/" >> jbrowse.conf

# Add GCContent plugin
git clone https://github.com/elsiklab/gccontent.git plugins/GCContent/
echo "[ plugins.GCContent ]" >> jbrowse.conf
echo "location = ../plugin/GCContent/" >> jbrowse.conf

# Add ComboTrackSelector plugin
git clone https://github.com/Arabidopsis-Information-Portal/ComboTrackSelector.git plugins/ComboTrackSelector/
echo "[ plugins.ComboTrackSelector ]" >> jbrowse.conf
echo "location = ../plugin/ComboTrackSelector/" >> jbrowse.conf
cd plugins/ComboTrackSelector/
patch -p1 < $RECIPE_DIR/combotrackselector.patch
cd ../../

# Add MultiBigWig plugin
git clone https://github.com/elsiklab/multibigwig.git plugins/MultiBigWig/
echo "[ plugins.MultiBigWig ]" >> jbrowse.conf
echo "location = ../plugin/MultiBigWig/" >> jbrowse.conf

# Add bookmarks plugin
git clone https://github.com/TAMU-CPT/bookmarks-jbrowse.git plugins/bookmarks/
echo "[ plugins.bookmarks ]" >> jbrowse.conf
echo "location = ../plugin/bookmarks/" >> jbrowse.conf

# Add NeatFeatures tracktypes
echo "[ plugins.NeatCanvasFeatures ]" >> jbrowse.conf
echo "location = ../plugin/NeatCanvasFeatures/" >> jbrowse.conf
echo "[ plugins.NeatHTMLFeatures ]" >> jbrowse.conf
echo "location = ../plugin/NeatHTMLFeatures/" >> jbrowse.conf

# For cpanm on osx
export HOME=/tmp

./setup.sh

# Remove temp dirs
rm -rf node_modules/ browser/ build/ css/ extlib/ tests/ utils/ website/ setup.log
rm -rf plugins/MultiBigWig/test/

mkdir -p $PREFIX/bin/
cp bin/*.pl $PREFIX/bin/
chmod a+x $PREFIX/bin/*.pl
sed -i.bak 's|../src/perl5|../opt/jbrowse/src/perl5|g' $PREFIX/bin/*.pl
rm $PREFIX/bin/*.pl.bak

mkdir -p $PREFIX/opt/jbrowse/
cp -r * $PREFIX/opt/jbrowse/
