Termux-packages: Package request: postgis

Created on 21 May 2017  路  15Comments  路  Source: termux/termux-packages

Is it possible to have postgis for termux?

package request

Most helpful comment

And now in 2019,is it possible to use postgis with postgresql on termux ?
It would be very useful for geographic jobs outside ......

All 15 comments

Probably is but there are several dependencies some of which cannot be cross compiled.

I see, I was just curious to see if I can run my django server on my android phone. Seems like postgis doesn't let me to do so.

And now in 2019,is it possible to use postgis with postgresql on termux ?
It would be very useful for geographic jobs outside ......

Made some headway on PostGIS but getting stuck compiling the PROJ dependency with the following error:

Screenshot from 2019-06-04 01-38-26

pkg install wget curl build-essential libiconv-dev postgresql-dev libxml2-dev libsqlite-dev

# rm -rf src
#mkdir src
cd src

# Download GEOS
#wget http://download.osgeo.org/geos/geos-3.7.2.tar.bz2
#bunzip2 geos-3.7.2.tar.bz2
#tar -xf geos-3.7.2.tar
#cd geos-3.7.2

#./configure --prefix=$PREFIX
#make
#make install

# Download PROJ
wget http://download.osgeo.org/proj/proj-6.1.0.tar.gz
tar -xzf proj-6.1.0.tar.gz
wget http://download.osgeo.org/proj/proj-datumgrid-1.8.zip
unzip proj-datumgrid-1.7.zip -d proj-6.1.0/data/
cd proj-6.1.0
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig:$PKG_CONFIG_PATH
./configure --prefix=$PREFIX
make
make install


# Download PostGIS
#wget https://download.osgeo.org/postgis/source/postgis-2.5.2.tar.gz
#tar -xzf postgis-2.5.2.tar.gz

#cd postgis-2.5.2
#./configure --prefix=$PREFIX
#make
#make install

sqlite, libsqlite and libsqlite-dev are all installed

@bencevans have a look in the config.log file for more information about why it can't find sqlite.

Also note that proj and geos are already available from the science repo so pkg in libgeos libgeos-dev proj proj-dev installs these dependencies.

Thanks for the top @Grimler91. It's gotten me a bit further :rocket: PostGIS build is now getting stuck at finding proj_api.h which I can't find either scanning the file system.

Screenshot from 2019-06-04 16-16-12

@bencevans I'm guessing you haven't installed proj-dev.

You probably also want to fix the /bin/sh: 0: Can't open build-aux/config.rpath error there (perhaps by changing /bin/sh to /data/data/com.termux/files/usr/bin/sh)

@Grimler91 Even if it present there will be a failure:

| #include <proj_api.h>
configure:16233: result: no
configure:16233: checking proj_api.h presence
configure:16233: gcc -E -I/data/data/com.termux/files/usr/include conftest.c
In file included from conftest.c:45:
/data/data/com.termux/files/usr/include/proj_api.h:37:2: error: 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
  1. Packages:

    pkg install build-essential gdal-dev json-c-dev postgresql-dev proj-dev libiconv-dev libgeos-dev libprotobuf-c-dev libxml2-dev
    
  2. Configure:

    ./configure --prefix=$PREFIX --with-projdir=$PREFIX CFLAGS="-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1"
    
  3. Make:

    make -j8
    

    Looks like protoc-c is broken (cannot find symbol) - fixed in ce72a893357dc7d4295c3722aae280d18eb3db96.

  4. Installation:

    make install
    

    $ pgsql2shp RELEASE: 2.5.1 (r17027) USAGE: pgsql2shp [<options>] <database> [<schema>.]<table> pgsql2shp [<options>] <database> <query>

Seems instructions now broken due to upgrade to gdal 3 in the repositories.
EDIT: IT can be built using the --without-raster switch in the configure stage, however, this removes significant functionality (raster support and installing into the database via CREATE EXTENSION postgis;)

@xeffyr I tried following your instructions but it seems like lots of the packages are not available:

td-static/stable 1.4.2-1 aarch64
$ pkg install wget curl build-essential libiconv-dev postgresql-dev libxml2-dev libsqlite-dev
Ign:1 https://dl.bintray.com/termux/termux-packages-24 stable InRelease
Ign:2 https://dl.bintray.com/grimler/game-packages-24 games InRelease
Ign:3 https://dl.bintray.com/grimler/science-packages-24 science InRelease
Get:4 https://dl.bintray.com/termux/termux-packages-24 stable Release [6061 B]
Hit:4 https://dl.bintray.com/termux/termux-packages-24 stable Release
Get:5 https://dl.bintray.com/grimler/game-packages-24 games Release [5344 B]
Hit:5 https://dl.bintray.com/grimler/game-packages-24 games Release
Get:7 https://dl.bintray.com/grimler/science-packages-24 science Release [5348 B]
Hit:7 https://dl.bintray.com/grimler/science-packages-24 science Release
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libiconv-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libiconv

Package libsqlite-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libsqlite

Package libxml2-dev is not available, but is referred to by another package.
This may mean that the package is missing, has be
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libxml2

Package postgresql-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  postgresql

E: Package 'libiconv-dev' has no installation candidate
E: Package 'postgresql-dev' has no installation candidate
E: Package 'libxml2-dev' has no installation candidate
E: Package 'libsqlite-dev' has no installation candidate
$

Now:
libiconv-dev => libiconv
postgresql-dev => postgresql
libxml2-dev => libxml2
libsqlite-dev => libsqlite

btw, message has all suggestions:

Package libiconv-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libiconv

@xeffyr Thanks so much - I got it built and working. Here is the full set of steps I followed:

pkg install build-essential
pkg install wget curl  libiconv-dev postgresql-dev libxml2-dev libsqlite-dev readline-dev libiconv postgresql libxml2 libsqlite proj libgeos
wget https://download.osgeo.org/postgis/source/postgis-2.5.2.tar.gz
tar xfz postgis-2.5.2.tar.gz
cd postgis-2.5.2
./configure --prefix=$PREFIX --with-projdir=$PREFIX CFLAGS="-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1" --without-raster
make -j8
make install
mkdir -p $PREFIX/var/lib/postgresql
initdb $PREFIX/var/lib/postgresql
pg_ctl -D $PREFIX/var/lib/postgresql start
psql -l
createdb gis
cd /data/data/com.termux/files/usr/share/postgresql/contrib/postgis-2.5/
psql gis -f postgis.sql
psql gis -f spatial_ref_sys.sql
pg_ctl -D $PREFIX/var/lib/postgresql stop
#termux-setup-storage
#mkdir TermuxData
#cd TermuxData/
#history > install-steps.txt

What are the next steps now that it can be built to package this up?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roycebank picture roycebank  路  3Comments

divyakutty picture divyakutty  路  3Comments

StephanBeer picture StephanBeer  路  3Comments

Cyb3rD3m0n picture Cyb3rD3m0n  路  3Comments

adit picture adit  路  3Comments