Skip to content
Snippets Groups Projects
bootstrap_epics 4.29 KiB
Newer Older
  • Learn to ignore specific revisions
  • #!/bin/bash
    
    #set -o nounset
    
    #set -o errexit
    
    
    function print_the_help {
      echo "USAGE: bootstrap_epics "
      echo "  OPTIONS: "
      #echo "            -n,--name  NAME    IOC name (must begin with letter)"
      exit 
    }
    
    function yes_or_no {
      while true; do
        read -p "$* [y/n]: " yn
        case $yn in
          [Yy]*) return 0 ;;
          [Nn]*) echo "No entered" ; return 1 ;;
        esac
      done
    }
    
    NAME=
    
    #if [[ $# -eq 0 ]] ; then
    #  print_the_help
    #  exit 
    #fi
    
    
    POSITIONAL=()
    while [[ $# -gt 0 ]]
    do
      key="$1"
    
      case $key in
        -h|--help)
          shift # past argument
          print_the_help
          ;;
        -n|--name)
          NAME="$2"
          shift # past argument
          shift # past value
          ;;
        #-a|--all)
        #  LOG_ALL_PLOTS=1
        #  shift # past argument
        #  #shift # past value
        #  ;;
        #-o|--online-only)
        #  ONLINE_ONLY=1
        #  shift # past argument
        #  #shift # past value
        #  ;;
        *)    # unknown option
          #POSITIONAL+=("$1") # save it in an array for later
          echo "unknown option $1"
          print_the_help
          shift # past argument
          ;;
      esac
    done
    set -- "${POSITIONAL[@]}" # restore positional parameters
    
    #if [[ -z "${NAME}" ]] ; then 
    #  echo "Error: ioc NAME must be supplied"
    #  print_the_help
    #  exit 
    #fi
    
    #if [ -d "${NAME}" ] 
    #then
    #  echo "Directory ${NAME} exists." 
    #  echo "Error: cannot overrite ${NAME}"
    #else
    #  echo "Making directory ${NAME}"
    #  mkdir "${NAME}"
    #fi
    #cd "${NAME}"
    
    
    source setup.sh
    
    
    yes_or_no "build epics base"
    if [[ $?  ]] ; then 
    
      lsb_release -d | grep -i "ubuntu" 
    
      if [[ "$?" == "0" ]] ; then 
        sudo apt-get install -y \
          re2c  libreadline-dev libusb-dev \
    
          libusb-java libusb-1.0-0-dev libnet1-dev  libavl-dev \
          python-pip \
    
          libpcap-dev libx11-dev libxext-dev python-numpy
        if [[ "$(uname -m)" == "aarch64" ]] ; then
          sudo apt-get install -y python-rpi.gpio python3-rpi.gpio
        fi
        sudo pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org spidev
      fi
    
      git clone --recursive -b 7.0 https://git.launchpad.net/epics-base base-7.0
      ln -s base-7.0 base
    
      pushd base
      make 
      popd
    
      wget -qO- https://epics.anl.gov/bcda/synApps/tar/synApps_6_0.tar.gz | tar -zxf - 
    
      pushd synApps/support
      ln -s calc-R3-7-1 calc 
      ln -s asyn-R4-33 asyn 
      ln -s stream-R2-7-7c stream 
      sed -i '1d' configure/RELEASE
      sed -i '1iSUPPORT = /opt/epics/synApps/support' configure/RELEASE
      sed -i '3d' configure/RELEASE
      sed -i '3iEPICS_BASE=/opt/epics/base' configure/RELEASE
      sed -i '17d' configure/RELEASE
      sed -i '17i#DXP=$(SUPPORT)/dxp-R5-0' configure/RELEASE
    
      sed -i '34d' configure/RELEASE
      sed -i '34i#SSCAN=$(SUPPORT)/sscan-R2-11-1' configure/RELEASE
    
    
      sed -i '46d' configure/RELEASE
      sed -i '45d' configure/RELEASE
      sed -i '44d' configure/RELEASE
      sed -i '43d' configure/RELEASE
      sed -i '42d' configure/RELEASE
      sed -i '41d' configure/RELEASE
      echo '#AREA_DETECTOR=$(SUPPORT)/areaDetector-R3-3-1' >> configure/RELEASE
      echo '#ADCORE=$(AREA_DETECTOR)/ADCore' >> configure/RELEASE
      echo '#ADSUPPORT=$(AREA_DETECTOR)/ADSupport' >> configure/RELEASE
      echo '#ADSIMDETECTOR=$(AREA_DETECTOR)/ADSimDetector' >> configure/RELEASE
      echo '#SNCSEQ=$(SUPPORT)/seq-2-2-5' >> configure/RELEASE
      echo '#ALLEN_BRADLEY=$(SUPPORT)/allenBradley-2-3' >> configure/RELEASE
    
      make release
      make 
    
      popd
    
    fi
    
    yes_or_no "Build extenstions"
    if [[ "$?"  ]] ; then 
      # Extensions
      git clone https://github.com/epics-extensions/extensions
    
      pushd extensions/src
      git clone https://github.com/mdavidsaver/pyDevSup.git
      pushd pyDevSup
      sed -i '26d' configure/RELEASE
      sed -i '26iINSTALL_LOCATION=/opt/epics/extensions' configure/RELEASE
      sed -i '39d' configure/RELEASE
      sed -i '39iEPICS_BASE = /opt/epics/base' configure/RELEASE
      popd 
      popd
    
      pushd extensions
      sed -i '65iPYDEVSUP = pyDevSup' src/Makefile
      sed -i '127iDIRS += $(PYDEVSUP)' src/Makefile
    
      sed -i '26d' src/pyDevSup/configure/CONFIG_SITE
      sed -i '26iINSTALL_LOCATION=/opt/epics/extensions' src/pyDevSup/configure/CONFIG_SITE
      sed -i '15iinclude /opt/epics/extensions/configure/os/CONFIG_PY.Common.$(EPICS_HOST_ARCH)' src/pyDevSup/configure/CONFIG_PY
    
    yes_or_no "caQtDM"
    if [[ $?  ]] ; then 
    
      pushd extensions/src
      wget https://github.com/caqtdm/caqtdm/archive/V4.2.4.tar.gz -O - | tar -zx
      pushd caqtdm-4.2.4
      ./caQtDM_BuildAll
      ./caQtDM_Install
      popd
      popd
    
    fi