-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PostGIS test generation from templates
- Loading branch information
Showing
32 changed files
with
2,524 additions
and
760 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
declare -A versions=( | ||
["10"]="3.0.9 3.1.9 3.2.5" | ||
["11"]="3.0.9 3.1.9 3.2.5 3.3.4" | ||
["12"]="3.0.9 3.1.9 3.2.5 3.3.4 3.4.0" | ||
["13"]="3.1.9 3.2.5 3.3.4 3.4.0" | ||
["14"]="3.1.9 3.2.5 3.3.4 3.4.0" | ||
["15"]="3.1.9 3.2.5 3.3.4 3.4.0" | ||
["16"]="3.4.0" | ||
) | ||
|
||
main() { | ||
local pg | ||
|
||
for pg in ${!versions[@]} ; do | ||
generate "$pg" | ||
done | ||
} | ||
|
||
generate() { | ||
local pg="$1" | ||
local template major_version short_version output | ||
|
||
echo -e "Generating recipes for PostgreSQL $pg…\n" | ||
|
||
for pstg in ${versions[$pg]} ; do | ||
major_version=${pstg:0:3} | ||
short_version=${major_version//./} | ||
template="postgis${short_version}.template" | ||
output="postgis${short_version}_${pg}.recipe" | ||
|
||
if [[ ! -f "$template" ]] ; then | ||
echo "✖ $output: No template for PostGIS $major_version ($short_version)" | ||
continue | ||
fi | ||
|
||
cat "$template" > "$output" | ||
sed -i "s/%PG_VERSION%/$pg/g" "$output" | ||
sed -i "s/%SHORT_VERSION%/$short_version/g" "$output" | ||
sed -i "s/%MAJOR_VERSION%/$major_version/g" "$output" | ||
sed -i "s/%FULL_VERSION%/$pstg/g" "$output" | ||
|
||
echo "✔ $output ($major_version)" | ||
done | ||
|
||
echo "" | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Bibop recipe for PostGIS %MAJOR_VERSION% for PostgreSQL %PG_VERSION% | ||
# See more: https://kaos.sh/bibop | ||
|
||
################################################################################ | ||
|
||
pkg postgresql%PG_VERSION%-server postgis%SHORT_VERSION%_%PG_VERSION% postgis%SHORT_VERSION%_%PG_VERSION%-client postgis%SHORT_VERSION%_%PG_VERSION%-scripts postgis%SHORT_VERSION%_%PG_VERSION%-utils | ||
|
||
require-root yes | ||
unsafe-actions yes | ||
|
||
var postgis_lib_version 3 | ||
var postgis_major_version %MAJOR_VERSION% | ||
var postgis_version %FULL_VERSION% | ||
var postgres_version %PG_VERSION% | ||
var pkg_ver %SHORT_VERSION%_{postgres_version} | ||
|
||
var postgres_service postgresql-{postgres_version} | ||
var postgres_port 5432 | ||
var postgres_data_dir /var/lib/pgsql/{postgres_version} | ||
var postgres_pid /var/run/postgresql{postgres_version}.pid | ||
|
||
var data_dir /usr/pgsql-{postgres_version}/share | ||
var lib_dir /usr/pgsql-{postgres_version}/lib | ||
var bin_dir /usr/pgsql-{postgres_version}/bin | ||
|
||
var utils_dir /usr/share/postgis{pkg_ver} | ||
|
||
var contrib_dir {data_dir}/contrib/postgis-{postgis_major_version} | ||
var extension_dir {data_dir}/extension | ||
|
||
################################################################################ | ||
|
||
command "-" "Check libraries" | ||
exist {lib_dir}/address_standardizer-{postgis_lib_version}.so | ||
exist {lib_dir}/postgis-{postgis_lib_version}.so | ||
exist {lib_dir}/postgis_raster-{postgis_lib_version}.so | ||
exist {lib_dir}/postgis_topology-{postgis_lib_version}.so | ||
|
||
mode {lib_dir}/address_standardizer-{postgis_lib_version}.so 755 | ||
mode {lib_dir}/postgis-{postgis_lib_version}.so 755 | ||
mode {lib_dir}/postgis_raster-{postgis_lib_version}.so 755 | ||
mode {lib_dir}/postgis_topology-{postgis_lib_version}.so 755 | ||
|
||
command "-" "Check linking with GDAL library" | ||
lib-linked {lib_dir}/postgis_raster-{postgis_lib_version}.so libgdal.so.* | ||
|
||
command "-" "Check data directories" | ||
exist {contrib_dir} | ||
dir {contrib_dir} | ||
mode {contrib_dir} 755 | ||
|
||
exist {extension_dir} | ||
dir {extension_dir} | ||
mode {extension_dir} 755 | ||
|
||
command "-" "Check client binaries" | ||
app pgsql2shp | ||
app raster2pgsql | ||
app shp2pgsql | ||
|
||
link /bin/pgsql2shp {bin_dir}/postgis-{postgis_major_version}/pgsql2shp | ||
link /bin/shp2pgsql {bin_dir}/postgis-{postgis_major_version}/shp2pgsql | ||
link /bin/raster2pgsql {bin_dir}/postgis-{postgis_major_version}/raster2pgsql | ||
|
||
################################################################################ | ||
|
||
command "service {postgres_service} initdb" "Database initialization" | ||
exit 0 | ||
|
||
command "systemctl start {postgres_service}" "Start PostgreSQL server" | ||
wait 1 | ||
wait-fs {postgres_pid} | ||
service-works {postgres_service} | ||
connect tcp :{postgres_port} | ||
|
||
command "postgres:{bin_dir}/psql -t -c 'CREATE EXTENSION postgis;'" "Create PostGIS extension" | ||
exit 0 | ||
|
||
command "postgres:{bin_dir}/psql -t -c 'SELECT PostGIS_Full_Version();'" "Check extension version" | ||
exit 0 | ||
output-contains 'POSTGIS="{postgis_version} ' | ||
|
||
command "systemctl stop {postgres_service}" "Stop PostgreSQL server" | ||
wait 1 | ||
!wait-fs {postgres_pid} | ||
!service-works {postgres_service} | ||
|
||
################################################################################ | ||
|
||
command:teardown "-" "Data cleanup" | ||
cleanup {postgres_data_dir}/data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.