This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plan.sh
139 lines (117 loc) · 3.68 KB
/
plan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# shellcheck disable=SC2164
pkg_name=postgresql96
pkg_version=9.6.24
pkg_origin=core
pkg_maintainer="The Habitat Maintainers <[email protected]>"
pkg_description="PostgreSQL is a powerful, open source object-relational database system."
pkg_upstream_url="https://www.postgresql.org/"
pkg_license=('PostgreSQL')
pkg_dirname="postgresql-${pkg_version}"
pkg_source="https://ftp.postgresql.org/pub/source/v${pkg_version}/${pkg_dirname}.tar.bz2"
pkg_shasum="aeb7a196be3ebed1a7476ef565f39722187c108dd47da7489be9c4fcae982ace"
pkg_deps=(
core/bash
core/glibc
core/openssl
core/perl
core/readline
core/zlib
core/libossp-uuid
# for postgis
core/libxml2
core/geos
core/proj
core/gdal
)
pkg_build_deps=(
core/coreutils
core/gcc
core/make
# for postgis
core/perl
core/diffutils
)
pkg_bin_dirs=(bin)
pkg_include_dirs=(include)
pkg_lib_dirs=(lib)
pkg_exports=(
[port]=port
[superuser_name]=superuser.name
[superuser_password]=superuser.password
)
pkg_exposes=(port)
ext_postgis_version=2.4.2
ext_postgis_source=http://download.osgeo.org/postgis/source/postgis-${ext_postgis_version}.tar.gz
ext_postgis_filename=postgis-${ext_postgis_version}.tar.gz
ext_postgis_shasum=23625bc99ed440d53a20225721095a3f5c653b62421c4d597c8038f0d7a321d9
do_before() {
ext_postgis_dirname="postgis-${ext_postgis_version}"
ext_postgis_cache_path="$HAB_CACHE_SRC_PATH/${ext_postgis_dirname}"
}
do_download() {
do_default_download
download_file $ext_postgis_source $ext_postgis_filename $ext_postgis_shasum
}
do_verify() {
do_default_verify
verify_file $ext_postgis_filename $ext_postgis_shasum
}
do_clean() {
do_default_clean
rm -rf "$ext_postgis_cache_path"
}
do_unpack() {
do_default_unpack
unpack_file $ext_postgis_filename
}
do_build() {
# ld manpage: "If -rpath is not used when linking an ELF
# executable, the contents of the environment variable LD_RUN_PATH
# will be used if it is defined"
./configure --disable-rpath \
--with-openssl \
--prefix="$pkg_prefix" \
--with-uuid=ossp \
--with-includes="$LD_INCLUDE_PATH" \
--with-libraries="$LD_LIBRARY_PATH" \
--sysconfdir="$pkg_svc_config_path" \
--localstatedir="$pkg_svc_var_path"
make world
# PostGIS can't be built until after postgresql is installed to $pkg_prefix
}
do_install() {
make install-world
# make and install PostGIS extension
HAB_LIBRARY_PATH="$(pkg_path_for proj)/lib:${pkg_prefix}/lib"
export LIBRARY_PATH="${LIBRARY_PATH}:${HAB_LIBRARY_PATH}"
build_line "Added habitat libraries to LIBRARY_PATH: ${HAB_LIBRARY_PATH}"
export PATH="${PATH}:${pkg_prefix}/bin"
build_line "Added postgresql binaries to PATH: ${pkg_prefix}/bin"
pushd "$ext_postgis_cache_path" > /dev/null
build_line "Building ${ext_postgis_dirname}"
./configure --prefix="$pkg_prefix"
make
build_line "Installing ${ext_postgis_dirname}"
make install
popd > /dev/null
}
# Postgresql9X plans source this plan to get build instructions.
# This helper method allows those plans to copy hooks and config
# from this plan.
# This should be run in do_begin()
_copy_service_files() {
build_line "Copying hooks"
cp -a "${PLAN_CONTEXT}/../postgresql/hooks" "${PLAN_CONTEXT}/"
build_line "Copying config"
cp -a "${PLAN_CONTEXT}/../postgresql/config" "${PLAN_CONTEXT}/"
build_line "Copying default.toml"
cp -a "${PLAN_CONTEXT}/../postgresql/default.toml" "${PLAN_CONTEXT}/"
}
# Cleanup from the above function.
# This should be run in do_end()
_cleanup_copied_service_files() {
build_line "Removing copied files"
rm -rf "${PLAN_CONTEXT:?}/config"
rm -rf "${PLAN_CONTEXT:?}/hooks"
rm -f "${PLAN_CONTEXT:?}/default.toml"
}