+ su $SUDO_USER -c "git clone ${GIT_URL} ${BASEFOLDER}" || ! echo "Error cannot clone from '$GIT_URL'" >&2 || exit 1
+ if [[ -n $COMMIT_ID ]] ; then
+ echo -e "Installing osm-RO from refspec: $COMMIT_ID"
+ su $SUDO_USER -c "git -C ${BASEFOLDER} checkout $COMMIT_ID" ||
+ ! echo "Error cannot checkout '$COMMIT_ID' from '$GIT_URL'" >&2 || exit 1
+ elif [[ -z $DEVELOP ]]; then
+ LATEST_STABLE_TAG=`git -C "${BASEFOLDER}" tag -l "v[0-9]*" | sort -V | tail -n1`
+ echo -e "Installing osm-RO from refspec: tags/${LATEST_STABLE_TAG}"
+ su $SUDO_USER -c "git -C ${BASEFOLDER} checkout tags/${LATEST_STABLE_TAG}" ||
+ ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '$GIT_URL'" >&2 || exit 1
+ else
+ echo -e "Installing osm-RO from refspec: master"
+ fi
+ su $SUDO_USER -c "cp ${BASEFOLDER}/.gitignore-common ${BASEFOLDER}/.gitignore"
+fi
+
+echo -e "\n"\
+ "#################################################################\n"\
+ "##### INSTALLING OSM-IM LIBRARY #####\n"\
+ "#################################################################"
+su $SUDO_USER -c "git -C ${BASEFOLDER} clone ${GIT_OSMIM_URL} IM" ||
+ ! echo "Error cannot clone from '${GIT_OSMIM_URL}'" >&2 || exit 1
+if [[ -n $COMMIT_ID ]] ; then
+ echo -e "Installing osm-IM from refspec: $COMMIT_ID"
+ su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout $COMMIT_ID" ||
+ ! echo "Error cannot checkout '$COMMIT_ID' from '${GIT_OSMIM_URL}'" >&2 || exit 1
+elif [[ -z $DEVELOP ]]; then
+ LATEST_STABLE_TAG=`git -C "${BASEFOLDER}/IM" tag -l "v[0-9]*" | sort -V | tail -n1`
+ echo -e "Installing osm-IM from refspec: tags/${LATEST_STABLE_TAG}"
+ su $SUDO_USER -c "git -C ${BASEFOLDER}/IM checkout tags/${LATEST_STABLE_TAG}" ||
+ ! echo "Error cannot checkout 'tags/${LATEST_STABLE_TAG}' from '${GIT_OSMIM_URL}'" >&2 || exit 1
+else
+ echo -e "Installing osm-IM from refspec: master"
+fi
+
+# Install debian dependencies before setup.py
+if [[ -z "$NO_PACKAGES" ]]
+then
+ [ "$_DISTRO" == "Ubuntu" ] && install_packages "tox debhelper python-bitarray python-lxml python-six"
+ # TODO check packages for CentOS and RedHat
+ [ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && install_packages "tox debhelper python-bitarray python-lxml python-six"
+ pip install --upgrade stdeb pyangbind || exit 1