update_openfpm 1.89 KB
Newer Older
incardon's avatar
incardon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /bin/bash

source script/show_solutions

function update_openfpm()
{
  echo -e "\033[1;5;31m WARNING: the update will destroy any changes in the OpenFPM source code  \033[0m"
  
  commands[0]="Continue"
  commands[0]="${commands[@]}"
  possible_solutions "${commands[@]}"

  ## Get the name of the updating branch

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

incardon's avatar
incardon committed
26
  actual_branch=$(git branch | grep \* | cut -d ' ' -f2)
incardon's avatar
incardon committed
27

incardon's avatar
incardon committed
28
  if [ x"$branch" == x"$actual_branch" ]; then
incardon's avatar
incardon committed
29
30

   git remote update
incardon's avatar
incardon committed
31
   n_commit=$(git rev-list --count origin/$branch...$branch)
incardon's avatar
incardon committed
32

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

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


incardon's avatar
incardon committed
49
50
  git stash -u
  git submodule foreach 'git stash'
incardon's avatar
incardon committed
51

incardon's avatar
incardon committed
52
53
54
  git pull origin
  git checkout $branch
  git submodule update
incardon's avatar
incardon committed
55

incardon's avatar
incardon committed
56
57
58
59
60
61
62
63
64
65
66
67
68
  if [ x"$1" == x"update" ]; then
    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
    ./install $dir_prev_inst $for_opt
incardon's avatar
incardon committed
71
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"
    fi
incardon's avatar
incardon committed
77
  fi
incardon's avatar
incardon committed
78

incardon's avatar
incardon committed
79
80
  #### end

incardon's avatar
incardon committed
81
82
83
}