Diff postgresql-16.0 with a postgresql-9999

/usr/portage/dev-db/postgresql/postgresql-9999.ebuild 2023-10-09 14:52:29.336368346 +0300
4 4
EAPI=8
5 5

  
6 6
PYTHON_COMPAT=( python3_{10,11,12} )
7
LLVM_MAX_SLOT=15
8 7

  
9
inherit flag-o-matic linux-info llvm pam python-single-r1 systemd tmpfiles
8
inherit flag-o-matic git-r3 linux-info meson pam python-single-r1 \
9
		systemd tmpfiles
10 10

  
11
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
11
KEYWORDS=""
12 12

  
13
SLOT=$(ver_cut 1)
13
SLOT="9999"
14 14

  
15
MY_PV=${PV/_/}
16
S="${WORKDIR}/${PN}-${MY_PV}"
17

  
18
SRC_URI="https://ftp.postgresql.org/pub/source/v${MY_PV}/postgresql-${MY_PV}.tar.bz2"
15
EGIT_REPO_URI="https://git.postgresql.org/git/postgresql.git"
19 16

  
20 17
LICENSE="POSTGRESQL GPL-2"
21 18
DESCRIPTION="PostgreSQL RDBMS"
22 19
HOMEPAGE="https://www.postgresql.org/"
23 20

  
24
IUSE="debug doc +icu kerberos ldap llvm lz4 nls pam perl python
25
	  +readline selinux +server systemd ssl static-libs tcl uuid xml
26
	  zlib zstd"
21
IUSE="debug +icu kerberos ldap llvm +lz4 nls pam perl python +readline
22
	selinux server systemd ssl static-libs tcl uuid xml zlib zstd"
27 23

  
28 24
REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
29 25

  
......
37 33
kerberos? ( virtual/krb5 )
38 34
ldap? ( net-nds/openldap:= )
39 35
llvm? (
40
	<sys-devel/llvm-16:=
41
	<sys-devel/clang-16:=
36
	sys-devel/llvm:=
37
	sys-devel/clang:=
42 38
)
43 39
lz4? ( app-arch/lz4 )
44 40
pam? ( sys-libs/pam )
45 41
perl? ( >=dev-lang/perl-5.8:= )
46 42
python? ( ${PYTHON_DEPS} )
47 43
readline? ( sys-libs/readline:0= )
48
server? ( systemd? ( sys-apps/systemd ) )
49 44
ssl? ( >=dev-libs/openssl-0.9.6-r1:0= )
45
systemd? ( sys-apps/systemd )
50 46
tcl? ( >=dev-lang/tcl-8:0= )
47
uuid? ( dev-libs/ossp-uuid )
51 48
xml? ( dev-libs/libxml2 dev-libs/libxslt )
52 49
zlib? ( sys-libs/zlib )
53 50
zstd? ( app-arch/zstd )
......
75 72
)"
76 73

  
77 74
DEPEND="${CDEPEND}
75
>=dev-lang/perl-5.8
76
app-text/docbook-dsssl-stylesheets
77
app-text/docbook-sgml-dtd:4.5
78
app-text/docbook-xml-dtd:4.5
79
app-text/docbook-xsl-stylesheets
80
app-text/openjade
81
dev-libs/libxml2
82
dev-libs/libxslt
78 83
sys-devel/bison
79 84
sys-devel/flex
80 85
nls? ( sys-devel/gettext )
81 86
xml? ( virtual/pkgconfig )
82 87
"
83

  
84 88
RDEPEND="${CDEPEND}
85 89
selinux? ( sec-policy/selinux-postgresql )
86 90
"
87 91

  
88
pkg_setup() {
89
	use llvm && llvm_pkg_setup
92
pkg_pretend() {
93
	if ! use server; then
94
		elog "You are using a live ebuild that uses the current source code as it is"
95
		elog "available from PostgreSQL's Git repository at emerge time. Given such,"
96
		elog "the Meson build files may be altered by upstream without notice and the"
97
		elog "documentation for this live version is not readily available"
98
		elog "online. Ergo, the ebuild maintainers will not support building a"
99
		elog "client-only and/or document-free version."
100
		ewarn "Building server anyway."
101
	fi
102
}
90 103

  
91
	use server && CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
104
pkg_setup() {
105
	CONFIG_CHECK="~SYSVIPC" linux-info_pkg_setup
92 106

  
93 107
	use python && python-single-r1_pkg_setup
94 108
}
......
103 117
	# hardened and non-hardened environments. (Bug #528786)
104 118
	sed 's/@install_bin@/install -c/' -i src/Makefile.global.in || die
105 119

  
106
	use server || eapply "${FILESDIR}/${PN}-15_beta3-no-server.patch"
107

  
108 120
	if use pam ; then
109
		sed "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
121
		sed -e "s/\(#define PGSQL_PAM_SERVICE \"postgresql\)/\1-${SLOT}/" \
110 122
			-i src/backend/libpq/auth.c || \
111 123
			die 'PGSQL_PAM_SERVICE rename failed.'
112 124
	fi
......
115 127
}
116 128

  
117 129
src_configure() {
130
	local emesonargs=()
131

  
118 132
	case ${CHOST} in
119 133
		*-darwin*|*-solaris*)
120 134
			use nls && append-libs intl
121 135
			;;
122 136
	esac
123 137

  
124
	export LDFLAGS_SL="${LDFLAGS}"
125
	export LDFLAGS_EX="${LDFLAGS}"
126

  
127
	local PO="${EPREFIX}"
128

  
129 138
	local i uuid_config=""
130 139
	if use uuid; then
131 140
		for i in ${UTIL_LINUX_LIBC[@]}; do
132
			use ${i} && uuid_config="--with-uuid=e2fs"
141
			use ${i} && uuid_config="-Duuid=e2fs"
133 142
		done
134
		[[ -z $uuid_config ]] && uuid_config="--with-uuid=ossp"
135
	fi
136 143

  
137
	local myconf="\
138
		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}" \
139
		--datadir="${PO}/usr/share/postgresql-${SLOT}" \
140
		--includedir="${PO}/usr/include/postgresql-${SLOT}" \
141
		--mandir="${PO}/usr/share/postgresql-${SLOT}/man" \
142
		--sysconfdir="${PO}/etc/postgresql-${SLOT}" \
143
		--with-system-tzdata="${PO}/usr/share/zoneinfo" \
144
		$(use_enable debug) \
145
		$(use_with icu) \
146
		$(use_with kerberos gssapi) \
147
		$(use_with ldap) \
148
		$(use_with llvm) \
149
		$(use_with lz4) \
150
		$(use_with pam) \
151
		$(use_with perl) \
152
		$(use_with python) \
153
		$(use_with readline) \
154
		$(use_with ssl openssl) \
155
		$(usex server "$(use_with systemd)" '--without-systemd') \
156
		$(use_with tcl) \
157
		${uuid_config} \
158
		$(use_with xml libxml) \
159
		$(use_with xml libxslt) \
160
		$(use_with zlib) \
161
		$(use_with zstd) \
162
		$(use_enable nls)"
163
	if use alpha; then
164
		myconf+=" --disable-spinlocks"
165
	else
166
		# Should be the default but just in case
167
		myconf+=" --enable-spinlocks"
144
		emesonargs+=( ${uuid_config:-"-Duuid=ossp"} )
168 145
	fi
169
	econf ${myconf}
146

  
147
	use debug && emesonargs+=( "--debug" )
148

  
149
	local PO="${EPREFIX}"
150
	emesonargs+=(
151
		--prefix="${PO}/usr/$(get_libdir)/postgresql-${SLOT}"
152
		--datadir="${PO}/usr/share/postgresql-${SLOT}"
153
		--includedir="${PO}/usr/include/postgresql-${SLOT}"
154
		--mandir="${PO}/usr/share/postgresql-${SLOT}/man"
155
		--sysconfdir="${PO}/etc/postgresql-${SLOT}"
156
		-Dsystem_tzdata="${PO}/usr/share/zoneinfo"
157
		$(meson_feature icu)
158
		$(meson_feature kerberos gssapi)
159
		$(meson_feature ldap)
160
		$(meson_feature llvm)
161
		$(meson_feature lz4)
162
		$(meson_feature nls)
163
		$(meson_feature pam)
164
		$(meson_feature perl plperl)
165
		$(meson_feature python plpython)
166
		$(meson_feature readline)
167
		$(meson_feature systemd)
168
		$(meson_feature tcl pltcl)
169
		$(meson_feature xml libxml)
170
		$(meson_feature xml libxslt)
171
		$(meson_feature zlib)
172
		$(meson_feature zstd)
173
	)
174

  
175
	use ssl && emesonargs+=( "-Dssl=openssl" )
176
	use alpha && emesonargs+=( "-Dspinlocks=false" )
177

  
178
	export LDFLAGS_SL="${LDFLAGS}"
179
	export LDFLAGS_EX="${LDFLAGS}"
180

  
181
	meson_src_configure
170 182
}
171 183

  
172 184
src_compile() {
173
	emake
174
	emake -C contrib
185
	meson_src_compile
186
	meson_src_compile {docs,man}
175 187
}
176 188

  
177 189
src_install() {
178
	emake DESTDIR="${D}" install
179
	emake DESTDIR="${D}" install -C contrib
190
	meson_src_install
180 191

  
181
	dodoc README HISTORY
192
	dodoc README HISTORY doc/TODO
193
	dodoc -r "${BUILD_DIR}"/doc/src/sgml/html
182 194

  
183
	# man pages are already built, but if we have the target make them,
184
	# they'll be generated from source before being installed so we
185
	# manually install man pages.
186
	# We use ${SLOT} instead of doman for postgresql.eselect
195
	# postgresql.eselect places the man files of the selected slot, which may
196
	# not be this ${SLOT}, hence doins instead of doman
187 197
	insinto /usr/share/postgresql-${SLOT}/man/
188
	doins -r doc/src/sgml/man{1,3,7}
189
	if ! use server; then
190
		# Remove man pages for non-existent binaries
191
		serverman=(
192
			initdb
193
			pg_{archivecleanup,controldata,ctl,resetwal,rewind,standby}
194
			pg_{test_{fsync,timing},upgrade,waldump}
195
			post{gres,master}
196
		)
197
		for m in ${serverman[@]} ; do
198
			rm "${ED}/usr/share/postgresql-${SLOT}/man/man1/${m}.1"
199
		done
200
	fi
198
	doins -r "${BUILD_DIR}"/doc/src/sgml/man{1,3,7}
201 199
	docompress /usr/share/postgresql-${SLOT}/man/man{1,3,7}
202 200

  
201
	insinto /etc/postgresql-${SLOT}
202
	newins src/bin/psql/psqlrc.sample psqlrc
203

  
204
	# Don't delete libpg{port,common}.a (Bug #571046). They're always
205
	# needed by extensions utilizing PGXS.
206
	use static-libs || \
207
		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
208
			 -delete
209

  
210
	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
211
		"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
212

  
213
	sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
214
		"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
215

  
216
	if use systemd; then
217
		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
218
			"${FILESDIR}/${PN}.service-9.6-r1" | \
219
			systemd_newunit - ${PN}-${SLOT}.service
220
		newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
221
	fi
222

  
223
	newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
224

  
225
	use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
226

  
227
	local f bn
228
	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
229
					-mindepth 1 -maxdepth 1)
230
	do
231
		bn=$(basename "${f}")
232
		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
233
			  "/usr/bin/${bn}${SLOT/.}"
234
	done
235

  
203 236
	# Create slot specific man pages
204 237
	local bn f mansec slotted_name
205 238
	for mansec in 1 3 7 ; do
......
224 257
		popd > /dev/null
225 258
	done
226 259

  
227
	insinto /etc/postgresql-${SLOT}
228
	newins src/bin/psql/psqlrc.sample psqlrc
229

  
230
	# Don't delete libpg{port,common}.a (Bug #571046). They're always
231
	# needed by extensions utilizing PGXS.
232
	use static-libs || \
233
		find "${ED}" -name '*.a' ! -name libpgport.a ! -name libpgcommon.a \
234
			 -delete
235

  
236
	# Make slot specific links to programs
237
	local f bn
238
	for f in $(find "${ED}/usr/$(get_libdir)/postgresql-${SLOT}/bin" \
239
					-mindepth 1 -maxdepth 1)
240
	do
241
		bn=$(basename "${f}")
242
		dosym "../$(get_libdir)/postgresql-${SLOT}/bin/${bn}" \
243
			  "/usr/bin/${bn}${SLOT/.}"
244
	done
245

  
246
	if use doc ; then
247
		docinto html
248
		dodoc doc/src/sgml/html/*
249
	fi
250

  
251
	if use server; then
252
		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
253
			"${FILESDIR}/${PN}.confd-9.3" | newconfd - ${PN}-${SLOT}
254

  
255
		sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
256
			"${FILESDIR}/${PN}.init-9.3-r1" | newinitd - ${PN}-${SLOT}
257

  
258
		if use systemd; then
259
			sed -e "s|@SLOT@|${SLOT}|g" -e "s|@LIBDIR@|$(get_libdir)|g" \
260
				"${FILESDIR}/${PN}.service-9.6-r1" | \
261
				systemd_newunit - ${PN}-${SLOT}.service
262
			newbin "${FILESDIR}"/${PN}-check-db-dir ${PN}-${SLOT}-check-db-dir
263
			newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}-${SLOT}.conf
264
		fi
265

  
266
		use pam && pamd_mimic system-auth ${PN}-${SLOT} auth account session
267

  
268
		if use prefix ; then
269
			keepdir /run/postgresql
270
			fperms 1775 /run/postgresql
271
		fi
260
	if use prefix ; then
261
		keepdir /run/postgresql
262
		fperms 1775 /run/postgresql
272 263
	fi
273 264
}
274 265

  
275 266
pkg_postinst() {
276
	use server && use systemd && tmpfiles_process ${PN}-${SLOT}.conf
267
	use systemd && tmpfiles_process ${PN}-${SLOT}.conf
277 268
	postgresql-config update
278 269

  
279 270
	elog "If you need a global psqlrc-file, you can place it in:"
280 271
	elog "    ${EROOT}/etc/postgresql-${SLOT}/"
281 272

  
282
	if use server ; then
283
		elog
284
		elog "Gentoo specific documentation:"
285
		elog "https://wiki.gentoo.org/wiki/PostgreSQL"
286
		elog
287
		elog "Official documentation:"
288
		elog "https://www.postgresql.org/docs/${SLOT}/static/index.html"
289
		elog
290
		elog "The default location of the Unix-domain socket is:"
291
		elog "    ${EROOT}/run/postgresql/"
292
		elog
293
		elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
294
		elog "so that it contains your preferred locale in:"
295
		elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
296
		elog
297
		elog "Then, execute the following command to setup the initial database"
298
		elog "environment:"
299
		elog "    emerge --config =${CATEGORY}/${PF}"
300

  
301
		if [[ -n ${REPLACING_VERSIONS} ]] ; then
302
			ewarn "If your system is using 'pg_stat_statements' and you are running a"
303
			ewarn "version of PostgreSQL ${SLOT}, we advise that you execute"
304
			ewarn "the following command after upgrading:"
305
			ewarn
306
			ewarn "ALTER EXTENSION pg_stat_statements UPDATE;"
307
		fi
308
	fi
273
	elog
274
	elog "Gentoo specific documentation:"
275
	elog "https://wiki.gentoo.org/wiki/PostgreSQL"
276
	elog
277
	elog "Official documentation:"
278
	elog "${EROOT}/usr/share/doc/${PF}/html"
279
	elog
280
	elog "The default location of the Unix-domain socket is:"
281
	elog "    ${EROOT}/run/postgresql/"
282
	elog
283
	elog "Before initializing the database, you may want to edit PG_INITDB_OPTS"
284
	elog "so that it contains your preferred locale, and other options, in:"
285
	elog "    ${EROOT}/etc/conf.d/postgresql-${SLOT}"
286
	elog
287
	elog "Then, execute the following command to setup the initial database"
288
	elog "environment:"
289
	elog "    emerge --config =${CATEGORY}/${PF}"
309 290
}
310 291

  
311 292
pkg_prerm() {
312
	if use server && [[ -z ${REPLACED_BY_VERSION} ]] ; then
293
	if [[ -z ${REPLACED_BY_VERSION} ]] ; then
313 294
		ewarn "Have you dumped and/or migrated the ${SLOT} database cluster?"
314 295
		ewarn "\thttps://wiki.gentoo.org/wiki/PostgreSQL/QuickStart#Migrating_PostgreSQL"
315 296

  
......
324 305
}
325 306

  
326 307
pkg_config() {
327
	use server || die "USE flag 'server' not enabled. Nothing to configure."
328

  
329 308
	[[ -f "${EROOT}/etc/conf.d/postgresql-${SLOT}" ]] \
330 309
		&& source "${EROOT}/etc/conf.d/postgresql-${SLOT}"
331 310
	[[ -z "${PGDATA}" ]] && PGDATA="${EROOT}/etc/postgresql-${SLOT}/"
......
387 366

  
388 367
	einfo "Creating the data directory ..."
389 368
	if [[ ${EUID} == 0 ]] ; then
390
		mkdir -p "$(dirname ${DATA_DIR%/})" || die "Couldn't parent dirs"
391
		mkdir -m 0700 "${DATA_DIR%/}" || die "Couldn't make DATA_DIR"
392
		chown -h postgres:postgres "${DATA_DIR%/}" || die "Couldn't chown"
369
		mkdir -p "${DATA_DIR}"
370
		chown -Rf postgres:postgres "${DATA_DIR}"
371
		chmod 0700 "${DATA_DIR}"
393 372
	fi
394 373

  
395 374
	einfo "Initializing the database ..."
......
446 425
}
447 426

  
448 427
src_test() {
449
	if use server && [[ ${UID} -ne 0 ]] ; then
428
	if [[ ${UID} -ne 0 ]] ; then
450 429
		# Some ICU tests fail if LC_CTYPE and LC_COLLATE aren't the same. We set
451 430
		# LC_CTYPE to be equal to LC_COLLATE since LC_COLLATE is set by Portage.
452 431
		local old_ctype=${LC_CTYPE}
453 432
		export LC_CTYPE=${LC_COLLATE}
454
		emake check
433
		meson_src_test
455 434
		export LC_CTYPE=${old_ctype}
435

  
456 436
		einfo "If you think other tests besides the regression tests are necessary, please"
457 437
		einfo "submit a bug including a patch for this ebuild to enable them."
458 438
	else
459
		use server || \
460
			ewarn 'Tests cannot be run without the "server" use flag enabled.'
461
		[[ ${UID} -eq 0 ]] || \
462
			ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
463

  
439
		ewarn 'Tests cannot be run as root. Enable "userpriv" in FEATURES.'
464 440
		ewarn 'Skipping.'
465 441
	fi
466 442
}
Thank you!