update_openfpm 1.92 KB
Newer Older
1 2 3 4 5 6
#! /bin/bash

source script/show_solutions

function update_openfpm()
{
incardon's avatar
incardon committed
7
  echo -e "\033[1;5;31m WARNING: the update will destroy any changes you made in the OpenFPM source code  \033[0m"
8 9 10 11 12
  
  possible_solutions "${commands[@]}"

  ## Get the name of the updating branch

13
  url_update=$(cat $1)
14
  echo "Checking for update from $url_update"
incardon's avatar
incardon committed
15 16
  rm tmp_brc
  wget -O tmp_brc $url_update
incardon's avatar
incardon committed
17 18 19
  repo=$(cat tmp_brc)
  echo "Update repo $repo"
  if [ x"$repo" == x"" ]; then
20 21 22 23 24
    echo -e "\033[1m There are no-updates \033[0m"
    return
  fi


incardon's avatar
incardon committed
25
  git remote set-url origin "$repo"
26

incardon's avatar
incardon committed
27 28
  git remote update
  n_commit=$(git rev-list --count origin/master...master)
29

incardon's avatar
incardon committed
30 31 32
  if [ $n_commit -eq 0 ]; then
    echo -e "\033[1m There are no-updates \033[0m"
    return
33 34
  fi

incardon's avatar
incardon committed
35

incardon's avatar
incardon committed
36 37 38
  dir_prev_inst=$(cat dependencies_dir)
  for_opt=$(cat foward_options)
  if [ x"$dir_prev_inst" != x"" ]; then
incardon's avatar
incardon committed
39
    dir_prev_inst="-i $dir_prev_inst"
incardon's avatar
incardon committed
40
  fi
incardon's avatar
incardon committed
41
  if [ x"$for_opt" != x"" ]; then
incardon's avatar
incardon committed
42
    for_opt="-c $for_opt"
incardon's avatar
incardon committed
43 44 45
  fi


incardon's avatar
incardon committed
46 47
  git stash -u
  git submodule foreach 'git stash'
48

incardon's avatar
incardon committed
49 50
  git pull origin
  git submodule update
51

incardon's avatar
incardon committed
52 53 54
  #### Check if we have to force upgrade
  force_up=$(cat force_upgrade)

incardon's avatar
incardon committed
55
  if [ x"$1" == x"update" -a x"$force_up" == x"" ]; then
incardon's avatar
incardon committed
56
    source $HOME/openfpm_vars
incardon's avatar
incardon committed
57 58 59 60 61 62 63 64 65 66 67 68
    sh autogen.sh
    ./config.status
    if [ $? -ne 0 ]; then
      echo -e "Update summary\033[91;5;1m FAILED \033[0m"
    fi
    make
    if [ $? -ne 0 ]; then
      echo -e "Update summary\033[91;5;1m FAILED \033[0m"
    else
      echo -e "Update summary\033[92;5;1m SUCCEED \033[0m"
      echo -e "To make the update active do: \033[1m make install \033[0m"
    fi
incardon's avatar
incardon committed
69
  else
incardon's avatar
incardon committed
70
    #### Remove .deps for fresh install
incardon's avatar
incardon committed
71
    ./install $dir_prev_inst $for_opt
incardon's avatar
incardon committed
72 73 74 75 76
    if [ $? -ne 0 ]; then
      echo -e "Upgrade summary\033[91;5;1m FAILED \033[0m"
    else
      echo -e "Upgrade summary\033[92;5;1m SUCCEED \033[0m"
      echo -e "To make the upgrade active do: \033[1m make install \033[0m"
incardon's avatar
incardon committed
77
      rm force_upgrade
incardon's avatar
incardon committed
78
    fi
incardon's avatar
incardon committed
79
  fi
incardon's avatar
incardon committed
80 81
  
  ## end
82 83 84
}