Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: postgis #8142

Closed
sassanh opened this issue May 21, 2017 · 34 comments
Closed

Package request: postgis #8142

sassanh opened this issue May 21, 2017 · 34 comments

Comments

@sassanh
Copy link

sassanh commented May 21, 2017

Is it possible to have postgis for termux?

@its-pointless
Copy link
Contributor

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

@sassanh
Copy link
Author

sassanh commented May 22, 2017

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.

@jeanbarr
Copy link

jeanbarr commented Mar 1, 2019

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

@bencevans
Copy link

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

@bencevans
Copy link

sqlite, libsqlite and libsqlite-dev are all installed

@Grimler91
Copy link
Member

Grimler91 commented Jun 4, 2019

@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.

@bencevans
Copy link

Thanks for the top @Grimler91. It's gotten me a bit further 🚀 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

@Grimler91
Copy link
Member

@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)

@ghost

This comment has been minimized.

@ghost
Copy link

ghost commented Jun 4, 2019

  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 ce72a89.

  4. Installation:

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

@DouglasWJ
Copy link

DouglasWJ commented Jul 29, 2019

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;)

@timlinux
Copy link

@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
$

@ghost
Copy link

ghost commented Jul 30, 2019

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

@timlinux
Copy link

timlinux commented Jul 30, 2019

@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

@Progdrasil
Copy link

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

@mdouchin
Copy link
Contributor

mdouchin commented Jan 1, 2021

@timlinux hey ;) Have you already tried PostgreSQL/PostGIS inside a Android 10 environment ? Happy new year !

@jeanbarr
Copy link

jeanbarr commented Jan 1, 2021

Yes it's possible to have postgresql and postgis on android 10.
The full set of steps of timlinux has to be modified
Instead of :
pkg install wget curl libiconv-dev postgresql-dev libxml2-dev libsqlite-dev readline-dev libiconv postgresql libxml2 libsqlite proj libgeos
we have to use:
pkg install wget curl libiconv postgresql libxml2 libsqlite proj libgeos

@seabre
Copy link

seabre commented Jan 1, 2021

I built this last night using the latest stable release of PostGIS. You need to install additional packages for it to work, and raster support also seems to work, so compile options are different. Here's what I did:

pkg install build-essential
pkg install wget curl libiconv postgresql libxml2 libsqlite readline libiconv postgresql libxml2 libsqlite proj libgeos json-c libprotobuf-c
wget https://download.osgeo.org/postgis/source/postgis-3.1.0.tar.gz
tar xfz postgis-3.1.0.tar.gz
cd postgis-3.1.0
./configure --prefix=$PREFIX --with-projdir=$PREFIX
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

Then boot up psql: psql gis

Then inside the psql console run: CREATE EXTENSION postgis;
Hit enter, then you should have a functional postgis install:

image

@mdouchin
Copy link
Contributor

Hi all, thanks for your help. I could not build postgis with @seabre guidelines, but needed instead to add the --without-raster option.

@seabre
Copy link

seabre commented Jan 14, 2021

@mdouchin I wiped my termux install and tried from scratch to see what the issue was. In addition to the packages installed in the instructions above, the package gdal needs to be included. I forgot I had installed that way before attempting to compile PostGIS. Updated version is this:

pkg install build-essential
pkg install wget curl libiconv postgresql libxml2 libsqlite readline libiconv postgresql libxml2 libsqlite proj libgeos json-c libprotobuf-c gdal
wget https://download.osgeo.org/postgis/source/postgis-3.1.0.tar.gz
tar xfz postgis-3.1.0.tar.gz
cd postgis-3.1.0
./configure --prefix=$PREFIX --with-projdir=$PREFIX
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

@mdouchin
Copy link
Contributor

@seabre Thanks a lot ! Tested and approved !

Silly newbie question: how hard would it be to add postgis as a termux package, since building is working ? I could follow a step-by-step "create a package" guide and provide some help ?

@Grimler91
Copy link
Member

@mdouchin I started looking at packaging postgis, but it needs some work when cross-compiling.

Configure steps tries to run various config tools (like pg_config), which does not work since those tools are compiled for android. So, need to override all those calls in some way.

Please have a look at the github wiki pages if you are interested in learning about how to create packages and the build system: https://github.com/termux/termux-packages/wiki/Creating-new-package, https://github.com/termux/termux-packages/wiki/Building-packages

Also, moving this to science-packages since it depends on packages there.

@Grimler91 Grimler91 transferred this issue from termux/termux-packages Jan 14, 2021
@mdouchin
Copy link
Contributor

Thanks for your detailed answer. Meanwhile I created a script based on this issue answers https://github.com/mdouchin/termux-postgis-script
I need to improve it a little to check PostgreSQL before installing it, and also reference this issue.

@mdouchin
Copy link
Contributor

Hello

I just tried today on a new termux instance, and encoutered an issue with libproj not found during the configure step
./configure --prefix=$PREFIX --with-projdir=$PREFIX

The error tells

Checking for proj.h .....yes
checking for pj_get_release in -lproj... no
configure error: could not find libproj - you may need to specify the directory of a PROJ installation using --with-projdir

I checked, and proj is installed in version 8.0.1 . Perhaps PostGIS 3.1.0 cannot be built against it ?
Bizare, this worked I think last week...

I really think we should provide a PostGIS package. I will try to help, but have not much time at present :(

@Grimler91
Copy link
Member

Could be that pj_get_release was renamed or modified in some way in the 8.0.1 update, so that the check fails. Check config.log for the full error and more details

@mdouchin
Copy link
Contributor

Thanks for the answer.
I manage to solve this issue simply by using PostGIS 3.1.2 instead of 3.1.0

@IMMSPgisgroup
Copy link

I compiled PostGIS as in seabre instruction, but

~/postgis-3.1.1 $ ./configure --prefix=$PREFIX --with-projdir=$PREFIX
checking for a BSD-compatible install... /data/data/com.termux/files/usr/bin/install -c
checking build system type... aarch64-unknown-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking how to print strings... printf
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /data/data/com.termux/files/usr/bin/sed
checking for grep that handles long lines and -e... /data/data/com.termux/files/usr/bin/grep
checking for egrep... /data/data/com.termux/files/usr/bin/grep -E
checking for fgrep... /data/data/com.termux/files/usr/bin/grep -F
checking for ld used by gcc... no
configure: error: no acceptable ld found in $PATH

What I do wrong?

@Grimler91
Copy link
Member

I compiled PostGIS as in seabre instruction, but
[...]

checking for ld used by gcc... no
configure: error: no acceptable ld found in $PATH

What I do wrong?

What compiler are you using? (clang or inofficial gcc?)

Try installing build-essential if not installed already, and check what the entire error message says in config.log

@mdouchin
Copy link
Contributor

I also discovered recently you need to add these packages to make it work

binutils zstd zstd-static

@IMMSPgisgroup
Copy link

IMMSPgisgroup commented Nov 21, 2021

I added packages from mdouchin message. PostGIS 3.1.4 compiled.
image

In config.log I see about PKG_CONFIG_PATH. And I see some error messages.

...
conftest.c:9:10: fatal error: 'ac_nonexistent.h' file not found
#include <ac_nonexistent.h>
         ^~~~~~~~~~~~~~~~~~
1 error generated.
configure:7066: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| #include <ac_nonexistent.h>
configure:7091: result: gcc -E
configure:7111: gcc -E  conftest.c
configure:7111: $? = 0
configure:7125: gcc -E  conftest.c
conftest.c:9:10: fatal error: 'ac_nonexistent.h' file not found
...
configure:25590: WARNING: 
configure:25592: WARNING:  | You are building using --with-projdir. This option isn't standard and    |
configure:25594: WARNING:  | might be incompatible with future releases of PROJ.                      |
configure:25596: WARNING:  | You can instead adjust the PKG_CONFIG_PATH environment variable if you   |
configure:25598: WARNING:  | installed software in a non-standard prefix.                             |
configure:25600: WARNING:  | Alternatively, you may set the environment variables PROJ_CFLAGS and     |
configure:25602: WARNING:  | PROJ_LIBS to avoid the need to call pkg-config.   

@Grimler91 Grimler91 transferred this issue from termux/science-packages Dec 4, 2021
Grimler91 added a commit that referenced this issue Dec 5, 2021
postgis is not really set up for cross-compilation. It wants to run
cross-compiled programs to check proj and protobuf versions, so we
need to patch that in configure script.

The current patch added to do this will be annoying to maintain. I
tried patching the configure.ac script instead but got weird errors
that seemed to have more to do with the autoconf version we have in
the docker image.

Fixes #8142
Grimler91 added a commit that referenced this issue Dec 5, 2021
postgis is not really set up for cross-compilation. It wants to run
cross-compiled programs to check proj and protobuf versions, so we
need to patch that in configure script.

The current patch added to do this will be annoying to maintain. I
tried patching the configure.ac script instead but got weird errors
that seemed to have more to do with the autoconf version we have in
the docker image.

Fixes #8142
Grimler91 added a commit that referenced this issue Dec 5, 2021
postgis is not really set up for cross-compilation. It wants to run
cross-compiled programs to check proj and protobuf versions, so we
need to patch that in configure script.

The current patch added to do this will be annoying to maintain. I
tried patching the configure.ac script instead but got weird errors
that seemed to have more to do with the autoconf version we have in
the docker image.

Fixes #8142
@Grimler91
Copy link
Member

Postgis has been added, seems to work when i run simple commands on archlinux wiki, but please test it and report issues

@davemackintosh
Copy link

I managed to install successfully thanks to @seabre's pkg install.

@Grimler91
Copy link
Member

@davemackintosh you mean compilation from source on device? Was there an issue with/did you try the package available through apt/pkg?

@davemackintosh
Copy link

Screenshot_20211212-194412_Termux

🤡
It's Sunday. I'm tired. Damnit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests