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

Add postgis installation #35

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions bin/pgenv
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ The pgenv commands are:
available Show which versions can be downloaded
check Check all program dependencies
config View, edit, delete the program configuration
extensions Install extension

For full documentation, see: https://github.com/theory/pgenv#readme
EOF
}

pgenv_extensions_help() {
cat <<EOF
Usage: pgenv extensions <command> [<args>]

The extensions commands are:
available Show which versions can be downloaded
build Build a specific version of an extension
help Show this usage statement and command summary

For full documentation, see: https://github.com/theory/pgenv#readme
EOF
Expand Down Expand Up @@ -827,6 +841,79 @@ case $1 in
exit
;;

extensions)
v=$( pgenv_current_postgresql_or_exit )
action=$2
case "$action" in
# TODO: Add clean action
available)
for version in $( curl -s http://download.osgeo.org/postgis/source/ \
| grep -o '<a href=['"'"'"][^"'"'"']*['"'"'"]' \
| sed -e 's/^<a href=["'"'"']//' -e 's/["'"'"']$//' \
| sed 's/\.tar\.gz//g' \
| grep 'postgis' \
| sed 's/\/$//')
do
#TODO: Add nice format
echo $version
done
;;
build)
# $extension must be in format name-version
extension=$3
# Only postgis installation is supported
if [[ $extension != "postgis"* ]]; then
echo "$extension is not available"
exit
fi

# Extension is build for the current postgres version
v=$( pgenv_current_version_number )

# sanity checks before building
pgenv_check_dependencies

# Switch to the src directory.
if [ ! -e "src" ]; then
mkdir src
fi
cd src

# Download the source if wee don't already have it.
POSGIS_TARBALL="$extension.tar.gz"
POSTIS_TAR_OPTS="zxf"
if [ ! -f $POSGIS_TARBALL ]; then
curl -fLO "http://download.osgeo.org/postgis/source/$POSGIS_TARBALL"
fi
# Unpack the source.
rm -rf "$extension"
$PGENV_TAR $POSTIS_TAR_OPTS $POSGIS_TARBALL
cd $extension

# configure make and make install
pgenv_debug "configure command line [--prefix=$PGENV_ROOT/pgsql-$v] + [$PGENV_CONFIGURE_OPTS]"
./configure --prefix=$PGENV_ROOT/pgsql-$v $PGENV_CONFIGURE_OPTS
$PGENV_MAKE $PGENV_MAKE_OPTS
$PGENV_MAKE install

echo "PostgreSQL extension $extension for $v built"
exit
;;
help)
pgenv_extensions_help
exit
;;
*)
if [ $# -gt 0 ]; then
echo "Unknown command \`$@\`"
fi
pgenv_extensions_help
exit 1
;;
esac
exit
;;

available)
# load executables
pgenv_check_dependencies
Expand Down