update_openfpm 1.67 KB
Newer Older
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

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

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

28
  if [ x"$branch" == x"$actual_branch" ]; then
29
30

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

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

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


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

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

Pietro Incardona's avatar
Pietro Incardona 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
Pietro Incardona's avatar
Pietro Incardona committed
69
  else
Pietro Incardona's avatar
Pietro Incardona committed
70
    ./install $dir_prev_inst $foward_options
Pietro Incardona's avatar
Pietro Incardona committed
71
  fi
72
73
74
75

}