Skip to content
Snippets Groups Projects
Select Git revision
  • ac94ad906eb2fc77e52f8dbfbcd249879fa8d2c9
  • master default protected
  • julia protected
  • 6.x protected
  • python-codegen
  • llvm-15
  • 5.x protected
  • 4.6 protected
  • uop
  • rework_pac
  • aux_vars_fix
  • julia-7.0.0
  • julia-6.4.0
  • julia-6.3.0
  • julia-6.2.0
15 results

DynareMain1.cc

Blame
  • postinstall 2.77 KiB
    #!/usr/bin/env bash
    
    # Copyright © 2019-2020 Dynare Team
    #
    # This file is part of Dynare.
    #
    # Dynare is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # Dynare is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
    
    set -ex
    
    set -o errexit
    readonly LOG_FILE="$2"/install.log
    sudo touch "$LOG_FILE"
    exec 1>"$LOG_FILE"
    exec 2>&1
    
    # Remove dummy payload
    rm -f "$2"/dummy
    
    # Test for Internet connection
    [[ -z $(curl -s -m 4 https://github.com) ]] && \
        { \
          osascript -e 'display alert "Dynare Installation Error" message "No internet connection found" as critical'; \
          echo "No internet connection found"; \
          exit 1; \
        }
    
    # Install Command Line Tools
    if [[ -z $(/usr/bin/xcode-select -print-path) ]]; then
        touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
        SUC=$(softwareupdate -l |
                  grep "\*.*Command Line" |
                  grep -m1 "" |
                  awk -F"*" '{print $2}' |
                  sed -e 's/^ *//' |
                  tr -d '\n')
        # On macOS 10.15 softwareupdate output is preceded by "Label: "
        [[ $SUC == Label:* ]] && SUC=${SUC#"Label: "}
        softwareupdate -i "$SUC" --verbose;
        rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
        softwareupdate -l
    fi
    
    # If CLT installation didn't work, exit
    [[ -z $(/usr/bin/xcode-select -print-path) ]] && \
        { \
          osascript -e 'display alert "Dynare Installation Error" message "You must install Command Line Tools to proceed with installation of GCC" as critical'; \
          echo "You must install Command Line Tools to proceed with installation of GCC"; \
          exit 1; \
        }
    
    # Install Homebrew
    BREWDIR="$2"/.brew
    [ -d "$BREWDIR" ] || mkdir -p "$BREWDIR"
    
    BREW_URL="https://github.com/Homebrew/brew"
    BREW_BRANCH="master"
    
    curl -\# -L "$BREW_URL"/tarball/"$BREW_BRANCH" | tar xz -m --strip 1 -C "$BREWDIR"
    
    # Change ownership of Dynare directory
    chown -R "$USER":staff "$2"
    
    sudo -u "$USER" "$BREWDIR"/bin/brew tap homebrew/core
    HOMEBREW_CACHE="$HOME"/Library/Caches/Homebrew-Dynare
    HOMEBREW_NO_AUTO_UPDATE=1
    [[ -z "${HOMEBREW_NO_ANALYTICS}" ]] && HOMEBREW_NO_ANALYTICS=1
    
    # Move modified formulas to Homebrew Formula directory
    mv "$2"/*.rb "$BREWDIR"/Library/Taps/homebrew/homebrew-core/Formula
    
    # Install GCC & deps
    sudo -u "$USER" "$BREWDIR"/bin/brew install gcc -v --force-bottle
    
    exit 0