auto-install-hpp.sh 4.28 KB
Newer Older
1
2
#!/bin/bash

Guilhem Saurel's avatar
Guilhem Saurel committed
3
4
# Exit on error
set -e
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
HOST_DIST=$(lsb_release -s -c)
case $HOST_DIST in
  trusty)
    APT_DEP="autoconf g++ cmake libboost-dev liburdfdom-dev libassimp-dev \
      ros-indigo-xacro ros-indigo-kdl-parser ros-indigo-common-msgs \
      ros-indigo-tf ros-indigo-tf-conversions ros-indigo-libccd ros-indigo-octomap \
      ros-indigo-resource-retriever ros-indigo-srdfdom ros-indigo-pr2-description flex \
      bison asciidoc source-highlight git libomniorb4-dev omniorb-nameserver \
      omniidl omniidl-python libltdl-dev python-matplotlib libtinyxml2-dev \
      liblog4cxx10-dev libltdl-dev qt4-dev-tools libqt4-opengl-dev \
      libqtgui4 oxygen-icon-theme libopenscenegraph-dev"
    APT_BUILD_DEP=""
    CONFIG_FILE="ubuntu-14.04-indigo.sh"
    ;;
  xenial)
    APT_DEP="autoconf g++ cmake doxygen libboost-dev liburdfdom-dev \
      libassimp-dev ros-kinetic-xacro ros-kinetic-kdl-parser ros-kinetic-common-msgs \
      ros-kinetic-tf ros-kinetic-tf-conversions libccd-dev ros-kinetic-octomap \
      ros-kinetic-resource-retriever ros-kinetic-srdfdom ros-kinetic-pr2-description flex \
      bison asciidoc source-highlight git libomniorb4-dev omniorb-nameserver omniidl \
      omniidl-python libltdl-dev python-matplotlib libxml2 libtinyxml2-dev \
      liblog4cxx10-dev libltdl-dev qt4-dev-tools libqt4-opengl-dev libqtgui4 oxygen-icon-theme \
      libopenscenegraph-dev openscenegraph libpcre3-dev"
    APT_BUILD_DEP=""
    CONFIG_FILE="ubuntu-16.04-kinetic.sh"
    ;;
  *)
    echo "Unknow host distribution."
    exit 1
    ;;
esac
36

Joseph Mirabel's avatar
Joseph Mirabel committed
37
MAKE_TARBALL=false
Guilhem Saurel's avatar
Guilhem Saurel committed
38
TARGET=all
Joseph Mirabel's avatar
Joseph Mirabel committed
39

40
BRANCH=""
Joseph Mirabel's avatar
Joseph Mirabel committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if [ -z ${DEVEL_DIR} ]; then
  export DEVEL_DIR=/local/devel/hpp
fi
if [ -z ${BUILD_TYPE} ]; then
  export BUILD_TYPE=Release
fi

while test $# -gt 0
do
  case $1 in
    --mktar)
      MAKE_TARBALL=true
      ;;
    --show-dep)
      echo "Will install"
      echo "${APT_DEP}"
      echo "\nWill install build dependencies of"
      echo "${APT_BUILD_DEP}"
      exit 0
      ;;
Guilhem Saurel's avatar
Guilhem Saurel committed
61
62
63
64
65
    --target)
      shift
      TARGET=$1
      echo "Target set to $TARGET"
      ;;
66
67
68
69
70
    --branch)
      shift
      BRANCH=$1
      echo "Branch set to $BRANCH"
      ;;
Joseph Mirabel's avatar
Joseph Mirabel committed
71
72
    --help)
      echo "Options are"
73
      echo "--branch:         \tbranch which should be installed"
Guilhem Saurel's avatar
Guilhem Saurel committed
74
75
76
77
      echo "--mktar:          \tmake tar balls after compilation"
      echo "--show-dep:       \tshow dependencies resolved by aptitude"
      echo "--target TARGET:  \tinstall TARGET (default: all)"
      echo "-v:               \tshow variables and ask for confirm (must be last arg)"
Joseph Mirabel's avatar
Joseph Mirabel committed
78
79
80
      exit 0
      ;;
    -v)
81
      for v in "DEVEL_DIR" "BUILD_TYPE" "MAKE_TARBALL" "BRANCH"
Joseph Mirabel's avatar
Joseph Mirabel committed
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
      do
        echo "$v=${!v}"
      done
      read -p "Continue (y/N)?" choice
      case "$choice" in 
        y|Y )
          echo "yes"
          ;;
        * ) echo "no"
          exit 1
          ;;
      esac
      ;;
    *)
      echo "Option $1 not understood. Use --help"
      exit 1
      ;;
  esac
  shift
done

103
104
105
106
107
if [ -z "${BRANCH}" ]; then
  echo "A branch must be specified with argument --branch"
  exit 1
fi

Joseph Mirabel's avatar
Joseph Mirabel committed
108
# standard HPP installation
Guilhem Saurel's avatar
Guilhem Saurel committed
109
sudo apt-get update -qqy
Joseph Mirabel's avatar
Joseph Mirabel committed
110
sudo apt-get --assume-yes install ${APT_DEP}
Guilhem Saurel's avatar
Guilhem Saurel committed
111
[[ -z $APT_BUILD_DEP ]] || sudo apt-get --assume-yes build-dep ${APT_BUILD_DEP}
112

113
114
115
116
117
118
# Setup environment
mkdir --parents $DEVEL_DIR
mkdir --parents $DEVEL_DIR/src
mkdir --parents $DEVEL_DIR/install

# Get config script
119
wget -q -O $DEVEL_DIR/config.sh https://raw.githubusercontent.com/humanoid-path-planner/hpp-doc/${BRANCH}/doc/config/${CONFIG_FILE}
Guilhem Saurel's avatar
Guilhem Saurel committed
120
wget -q -O $DEVEL_DIR/src/Makefile https://raw.githubusercontent.com/humanoid-path-planner/hpp-doc/${BRANCH}/doc/Makefile
121
122
123
124
125

source $DEVEL_DIR/config.sh

cd $DEVEL_DIR/src

Guilhem Saurel's avatar
make -s    
Guilhem Saurel committed
126
make -s -e robot_state_chain_publisher.install
127
source ../config.sh
Guilhem Saurel's avatar
make -s    
Guilhem Saurel committed
128
make -s -e $TARGET
Joseph Mirabel's avatar
Joseph Mirabel committed
129
130
131
132
133

if [ ${MAKE_TARBALL} = true ]; then
  cd $DEVEL_DIR/
  mkdir tarball
  SUFFIX="${BRANCH}-`date +%Y%m%d`-${BUILD_TYPE}"
134
135
  tar czf "tarball/hpp.src.${SUFFIX}.tar.gz" src/ install/ config.sh
  tar czf "tarball/hpp.${SUFFIX}.tar.gz" install/ config.sh
Joseph Mirabel's avatar
Joseph Mirabel committed
136
137
138
139
140
141
142
143
144
  INSTALL="$DEVEL_DIR/tarball/check.${SUFFIX}.sh"
  echo "#!/bin/bash" > ${INSTALL}
  echo "# Dependencies" >> ${INSTALL}
  echo "sudo apt-get install $APT_DEP" >> ${INSTALL}
  echo "sudo apt-get build-dep $APT_BUILD_DEP" >> ${INSTALL}
  echo "" >> ${INSTALL}
  echo "# config.sh" >> ${INSTALL}
  echo "echo \"Configure using 'config.sh' file\"" >> ${INSTALL}
fi