Upgrade yt-dlp from version stable@2023.07.06 to stable@2023.09.24
[sunny256-utils.git] / build-postgis
blob7edcc6b8f315fbda294d162a2f09a5b3f1d7fa6f
1 #!/usr/bin/env bash
3 #=======================================================================
4 # build-postgis
5 # File ID: 4467f922-5330-11e5-814f-fefdb24f8e10
7 # Compile and install PostGIS
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #=======================================================================
13 progname=build-postgis
14 VERSION=0.3.0
16 srcdir="$HOME/src/other/postgis"
18 ARGS="$(getopt -o "\
22 " -l "\
23 help,\
24 quiet,\
25 verbose,\
26 version,\
27 " -n "$progname" -- "$@")"
28 test "$?" = "0" || exit 1
29 eval set -- "$ARGS"
31 opt_help=0
32 opt_quiet=0
33 opt_verbose=0
34 while :; do
35 case "$1" in
36 -h|--help) opt_help=1; shift ;;
37 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
38 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
39 --version) echo $progname $VERSION; exit 0 ;;
40 --) shift; break ;;
41 *) echo $progname: Internal error >&2; exit 1 ;;
42 esac
43 done
44 opt_verbose=$(($opt_verbose - $opt_quiet))
46 if test "$opt_help" = "1"; then
47 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
48 cat <<END
50 Compile and install PostGIS from $srcdir
52 Usage: $progname [options]
54 Options:
56 -h, --help
57 Show this help.
58 -q, --quiet
59 Be more quiet. Can be repeated to increase silence.
60 -v, --verbose
61 Increase level of verbosity. Can be repeated.
62 --version
63 Print version information.
65 END
66 exit 0
69 msg() {
70 echo >&2
71 echo $progname: $* >&2
74 if ! test -d "$srcdir/."; then
75 git clone -o o-gitlab git@gitlab.com:postgis/postgis.git $srcdir &&
76 cd "$srcdir" &&
77 git remote add o-github git@github.com:postgis/postgis.git &&
78 git fetch o-github &&
79 echo &&
80 echo $progname: No stable version is selected, you have to choose one. &&
81 echo $progname: Dropping you into a bash shell, please take care of that &&
82 echo $progname: and return to the build with \'exit\'. &&
83 echo &&
84 echo $progname: List of newest tags: &&
85 echo &&
86 git tag --sort=version:refname | grep -E '^[2-9]' | tail &&
87 bash &&
88 echo $progname: Continuing the build process... || {
89 echo $progname: Something went wrong after clone or shell, aborting
90 exit 1
94 tmpdb=postgis-test-$(date +%s)
96 cd "$srcdir" &&
97 git-wait-until-clean &&
98 msg Remove ignored files from $(pwd)/ &&
99 git clean -fxd &&
100 msg ./autogen.sh &&
101 ./autogen.sh &&
102 msg ./configure &&
103 ./configure &&
104 msg make &&
105 make &&
106 msg make install &&
107 sudo make install &&
108 msg Test that the installation works &&
109 sudo -u postgres createdb "$tmpdb" &&
110 sudo -u postgres psql "$tmpdb" -c "CREATE EXTENSION postgis;" &&
111 sudo -u postgres dropdb "$tmpdb" && {
112 msg PostGIS installation ok
113 exit 0
114 } || {
115 msg Cannot create postgis extension, something is wrong
116 exit 1