From a0526763ea7a9944dafc6daef00f860a51f6e023 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Tue, 9 Feb 2021 15:39:50 +1300 Subject: [PATCH] Copy install_geos.sh from master (from #1042) --- ci/install_geos.sh | 70 +++++++++++++++++++++++++++++++++++++++ ci/travis/install_geos.sh | 49 --------------------------- 2 files changed, 70 insertions(+), 49 deletions(-) create mode 100755 ci/install_geos.sh delete mode 100755 ci/travis/install_geos.sh diff --git a/ci/install_geos.sh b/ci/install_geos.sh new file mode 100755 index 000000000..b39e09352 --- /dev/null +++ b/ci/install_geos.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# Build and install GEOS on a POSIX system, save cache for later +# +# This script requires environment variables to be set +# - export GEOS_INSTALL=/path/to/cached/prefix -- to build or use as cache +# - export GEOS_VERSION=3.7.3 or master -- to download and compile + +set -e + +if [ -z "$GEOS_INSTALL" ]; then + echo "GEOS_INSTALL must be set" + exit 1 +elif [ -z "$GEOS_VERSION" ]; then + echo "GEOS_VERSION must be set" + exit 1 +fi + +# Create directories, if they don't exit +mkdir -p $GEOS_INSTALL + +# Download and build GEOS outside other source tree +GEOS_BUILD=$HOME/geosbuild + +prepare_geos_build_dir(){ + rm -rf $GEOS_BUILD + mkdir -p $GEOS_BUILD + cd $GEOS_BUILD +} + +build_geos(){ + echo "Building geos-$GEOS_VERSION" + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$GEOS_INSTALL .. + make -j 2 + ctest . + make install +} + +if [ "$GEOS_VERSION" = "master" ]; then + prepare_geos_build_dir + # use GitHub mirror + git clone --depth 1 https://github.com/libgeos/geos.git geos-$GEOS_VERSION + cd geos-$GEOS_VERSION + git rev-parse HEAD > newrev.txt + BUILD=no + # Only build if nothing cached or if the GEOS revision changed + if test ! -f $GEOS_INSTALL/rev.txt; then + BUILD=yes + elif ! diff newrev.txt $GEOS_INSTALL/rev.txt >/dev/null; then + BUILD=yes + fi + if test "$BUILD" = "no"; then + echo "Using cached install $GEOS_INSTALL" + else + cp newrev.txt $GEOS_INSTALL/rev.txt + build_geos + fi +else + if [ -d "$GEOS_INSTALL/include/geos" ]; then + echo "Using cached install $GEOS_INSTALL" + else + prepare_geos_build_dir + wget -q http://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2 + tar xfj geos-$GEOS_VERSION.tar.bz2 + cd geos-$GEOS_VERSION + build_geos + fi +fi diff --git a/ci/travis/install_geos.sh b/ci/travis/install_geos.sh deleted file mode 100755 index db75afcd4..000000000 --- a/ci/travis/install_geos.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# based on contribution by @rbuffat to Toblerity/Fiona -set -e - -# Cache install directory from .travis.yml -CACHE_GEOS_INST=$HOME/geosinstall - -# Create directories, if they don't exit -GEOS_INST_VERSION=$CACHE_GEOS_INST/geos-$GEOS_VERSION -mkdir -p $GEOS_INST_VERSION - -function build_geos { - echo "Building geos-$GEOS_VERSION" - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$GEOS_INST_VERSION .. - make -j 2 - ctest . - make install -} - -if [ "$GEOS_VERSION" = "master" ]; then - # use GitHub mirror - git clone --depth 1 https://github.com/libgeos/geos.git geos-$GEOS_VERSION - cd geos-$GEOS_VERSION - git rev-parse HEAD > newrev.txt - BUILD=no - # Only build if nothing cached or if the GEOS revision changed - if test ! -f $GEOS_INST_VERSION/rev.txt; then - BUILD=yes - elif ! diff newrev.txt $GEOS_INST_VERSION/rev.txt >/dev/null; then - BUILD=yes - fi - if test "$BUILD" = "no"; then - echo "Using cached install $GEOS_INST_VERSION" - else - cp newrev.txt $GEOS_INST_VERSION/rev.txt - build_geos - fi -else - if [ -d "$GEOS_INST_VERSION/include/geos" ]; then - echo "Using cached install $GEOS_INST_VERSION" - else - wget -q http://download.osgeo.org/geos/geos-$GEOS_VERSION.tar.bz2 - tar xfj geos-$GEOS_VERSION.tar.bz2 - cd geos-$GEOS_VERSION - build_geos - fi -fi