Gentoo Archives: gentoo-commits

From: "Andreas K. Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/perl/files/, dev-lang/perl/
Date: Sat, 09 Oct 2021 14:26:16
Message-Id: 1633789505.d170e2a4277744193407903b9fe8e7f23ce15f63.dilfridge@gentoo
1 commit: d170e2a4277744193407903b9fe8e7f23ce15f63
2 Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 9 14:25:05 2021 +0000
4 Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 9 14:25:05 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d170e2a4
7
8 dev-lang/perl: Fix functionality with recent gdbm
9
10 Bug: https://bugs.gentoo.org/802945
11 Bug: https://bugs.gentoo.org/797460
12 Package-Manager: Portage-3.0.20, Repoman-3.0.3
13 Signed-off-by: Andreas K. Huettel <dilfridge <AT> gentoo.org>
14
15 dev-lang/perl/files/perl-5.34.0-gdbm-1.20.patch | 40 ++
16 dev-lang/perl/perl-5.34.0-r3.ebuild | 827 ++++++++++++++++++++++++
17 2 files changed, 867 insertions(+)
18
19 diff --git a/dev-lang/perl/files/perl-5.34.0-gdbm-1.20.patch b/dev-lang/perl/files/perl-5.34.0-gdbm-1.20.patch
20 new file mode 100644
21 index 00000000000..fc4c55c6899
22 --- /dev/null
23 +++ b/dev-lang/perl/files/perl-5.34.0-gdbm-1.20.patch
24 @@ -0,0 +1,40 @@
25 +From: Sergey Poznyakoff <gray@×××.org>
26 +Date: Wed, 23 Jun 2021 10:26:50 +0300
27 +Subject: Fix GDBM_File to compile with version 1.20 and earlier
28 +
29 +* ext/GDBM_File/GDBM_File.xs (ITEM_NOT_FOUND): Define conditionally,
30 +depending on the GDBM_VERSION_MAJOR and GDBM_VERSION_MINOR.
31 +Don't assume GDBM_ITEM_NOT_FOUND is a define (it isn't since
32 +gdbm commit d3e27957).
33 +
34 +Origin: backport, https://github.com/Perl/perl5/pull/18924/commits/aacd2398e766500cb5d83c4d76b642fcf31d997a
35 +Bug: https://github.com/Perl/perl5/issues/18915
36 +Bug-Debian: https://bugs.debian.org/993514
37 +---
38 + ext/GDBM_File/GDBM_File.xs | 11 +++++------
39 + 1 file changed, 5 insertions(+), 6 deletions(-)
40 +
41 +diff --git a/ext/GDBM_File/GDBM_File.xs b/ext/GDBM_File/GDBM_File.xs
42 +index cd0bb6f..494c288 100644
43 +--- a/ext/GDBM_File/GDBM_File.xs
44 ++++ b/ext/GDBM_File/GDBM_File.xs
45 +@@ -145,14 +145,13 @@ output_datum(pTHX_ SV *arg, char *str, int size)
46 + #define gdbm_setopt(db,optflag,optval,optlen) not_here("gdbm_setopt")
47 + #endif
48 +
49 +-#ifndef GDBM_ITEM_NOT_FOUND
50 +-# define GDBM_ITEM_NOT_FOUND GDBM_NO_ERROR
51 +-#endif
52 +-
53 ++#if GDBM_VERSION_MAJOR == 1 && GDBM_VERSION_MINOR < 13
54 + /* Prior to 1.13, gdbm_fetch family functions set gdbm_errno to GDBM_NO_ERROR
55 + if the requested key did not exist */
56 +-#define ITEM_NOT_FOUND() \
57 +- (gdbm_errno == GDBM_ITEM_NOT_FOUND || gdbm_errno == GDBM_NO_ERROR)
58 ++# define ITEM_NOT_FOUND() (gdbm_errno == GDBM_NO_ERROR)
59 ++#else
60 ++# define ITEM_NOT_FOUND() (gdbm_errno == GDBM_ITEM_NOT_FOUND)
61 ++#endif
62 +
63 + #define CHECKDB(db) do { \
64 + if (!db->dbp) { \
65
66 diff --git a/dev-lang/perl/perl-5.34.0-r3.ebuild b/dev-lang/perl/perl-5.34.0-r3.ebuild
67 new file mode 100644
68 index 00000000000..2c21f1c00ae
69 --- /dev/null
70 +++ b/dev-lang/perl/perl-5.34.0-r3.ebuild
71 @@ -0,0 +1,827 @@
72 +# Copyright 1999-2021 Gentoo Authors
73 +# Distributed under the terms of the GNU General Public License v2
74 +
75 +EAPI=7
76 +
77 +inherit alternatives flag-o-matic toolchain-funcs multilib multiprocessing
78 +
79 +PATCH_VER=1
80 +CROSS_VER=1.3.6
81 +PATCH_BASE="perl-5.34.0-patches-${PATCH_VER}"
82 +PATCH_DEV=dilfridge
83 +
84 +DIST_AUTHOR=XSAWYERX
85 +
86 +# Greatest first, don't include yourself
87 +# Devel point-releases are not ABI-intercompatible, but stable point releases are
88 +# BIN_OLDVERSEN is contains only C-ABI-intercompatible versions
89 +PERL_BIN_OLDVERSEN=""
90 +
91 +# Yes we can.
92 +PERL_SINGLE_SLOT=y
93 +
94 +if [[ "${PV##*.}" == "9999" ]]; then
95 + DIST_VERSION=5.30.0
96 +else
97 + DIST_VERSION="${PV/_rc/-RC}"
98 +fi
99 +SHORT_PV="${DIST_VERSION%.*}"
100 +# Even numbered major versions are ABI intercompatible
101 +# Odd numbered major versions are not
102 +if [[ $(( ${SHORT_PV#*.} % 2 )) == 1 ]]; then
103 + SUBSLOT="${DIST_VERSION%-RC*}"
104 +else
105 + SUBSLOT="${DIST_VERSION%.*}"
106 +fi
107 +# Used only in tar paths
108 +MY_P="perl-${DIST_VERSION}"
109 +# Used in library paths
110 +MY_PV="${DIST_VERSION%-RC*}"
111 +
112 +DESCRIPTION="Larry Wall's Practical Extraction and Report Language"
113 +
114 +SRC_URI="
115 + mirror://cpan/src/5.0/${MY_P}.tar.xz
116 + mirror://cpan/authors/id/${DIST_AUTHOR:0:1}/${DIST_AUTHOR:0:2}/${DIST_AUTHOR}/${MY_P}.tar.xz
117 + https://github.com/gentoo-perl/perl-patchset/releases/download/${PATCH_BASE}/${PATCH_BASE}.tar.xz
118 + https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${PATCH_BASE}.tar.xz
119 + https://github.com/arsv/perl-cross/releases/download/${CROSS_VER}/perl-cross-${CROSS_VER}.tar.gz
120 +"
121 +HOMEPAGE="https://www.perl.org/"
122 +
123 +LICENSE="|| ( Artistic GPL-1+ )"
124 +SLOT="0/${SUBSLOT}"
125 +
126 +if [[ "${PV##*.}" != "9999" ]] && [[ "${PV/rc//}" == "${PV}" ]] ; then
127 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
128 +fi
129 +
130 +IUSE="berkdb debug doc gdbm ithreads minimal"
131 +
132 +RDEPEND="
133 + berkdb? ( sys-libs/db:= )
134 + gdbm? ( >=sys-libs/gdbm-1.8.3:= )
135 + app-arch/bzip2
136 + sys-libs/zlib
137 + virtual/libcrypt:=
138 +"
139 +DEPEND="${RDEPEND}"
140 +BDEPEND="${RDEPEND}"
141 +
142 +PDEPEND="
143 + !minimal? (
144 + >=app-admin/perl-cleaner-2.5
145 + >=virtual/perl-Encode-3.120.0
146 + >=virtual/perl-File-Temp-0.230.400-r2
147 + >=virtual/perl-Data-Dumper-2.154.0
148 + virtual/perl-Test-Harness
149 + )
150 +"
151 +# bug 390719, bug 523624
152 +# virtual/perl-Test-Harness is here for the bundled ExtUtils::MakeMaker
153 +
154 +S="${WORKDIR}/${MY_P}"
155 +
156 +dual_scripts() {
157 + src_remove_dual perl-core/Archive-Tar 2.380.0 ptar ptardiff ptargrep
158 + src_remove_dual perl-core/CPAN 2.280.0 cpan
159 + src_remove_dual perl-core/Digest-SHA 6.20.0 shasum
160 + src_remove_dual perl-core/Encode 3.80.0 enc2xs piconv
161 + src_remove_dual perl-core/ExtUtils-MakeMaker 7.620.0 instmodsh
162 + src_remove_dual perl-core/ExtUtils-ParseXS 3.430.0 xsubpp
163 + src_remove_dual perl-core/IO-Compress 2.102.0 zipdetails
164 + src_remove_dual perl-core/JSON-PP 4.60.0 json_pp
165 + src_remove_dual perl-core/Module-CoreList 5.202.105.200 corelist
166 + src_remove_dual perl-core/Pod-Checker 1.740.0 podchecker
167 + src_remove_dual perl-core/Pod-Perldoc 3.280.100 perldoc
168 + src_remove_dual perl-core/Pod-Usage 2.10.0 pod2usage
169 + src_remove_dual perl-core/Test-Harness 3.430.0 prove
170 + src_remove_dual perl-core/podlators 4.140.0 pod2man pod2text
171 + src_remove_dual_man perl-core/podlators 4.140.0 /usr/share/man/man1/perlpodstyle.1
172 +}
173 +
174 +check_rebuild() {
175 + # Fresh install
176 + if [[ -z "${REPLACING_VERSIONS}" ]]; then
177 + return 0;
178 + # Major Upgrade
179 + # doesn't matter if there's multiple copies, it still needs a rebuild
180 + # if the string is anything other than "5.CURRENTMAJOR"
181 + elif [[ "${REPLACING_VERSIONS%.*}" != "${PV%.*}" ]]; then
182 + echo ""
183 + ewarn "UPDATE THE PERL MODULES:"
184 + ewarn "After updating dev-lang/perl the installed Perl modules"
185 + ewarn "have to be re-installed. In most cases, this is done automatically"
186 + ewarn "by the package manager, but subsequent steps are still recommended"
187 + ewarn "to ensure system consistency."
188 + ewarn
189 + ewarn "You should start with a depclean to remove any unused perl dependencies"
190 + ewarn "that may confuse portage in future. Regular depcleans are also encouraged"
191 + ewarn "as part of your regular update cycle, as that will keep perl upgrades working."
192 + ewarn "Recommended: emerge --depclean -va"
193 + ewarn
194 + ewarn "You should then call perl-cleaner to clean up any old files and trigger any"
195 + ewarn "remaining rebuilds portage may have missed."
196 + ewarn "Use: perl-cleaner --all"
197 + return 0;
198 +
199 + # Reinstall w/ USE Change
200 + elif ( use ithreads && ! has_version dev-lang/perl[ithreads] ) || \
201 + ( ! use ithreads && has_version dev-lang/perl[ithreads] ) || \
202 + ( use debug && ! has_version dev-lang/perl[debug] ) || \
203 + ( ! use debug && has_version dev-lang/perl[debug] ) ; then
204 + echo ""
205 + ewarn "TOGGLED USE-FLAGS WARNING:"
206 + ewarn "You changed one of the use-flags ithreads or debug."
207 + ewarn "You must rebuild all perl-modules installed."
208 + ewarn "Use: perl-cleaner --modules ; perl-cleaner --force --libperl"
209 + fi
210 +}
211 +
212 +pkg_setup() {
213 + case ${CHOST} in
214 + *-freebsd*) osname="freebsd" ;;
215 + *-dragonfly*) osname="dragonfly" ;;
216 + *-netbsd*) osname="netbsd" ;;
217 + *-openbsd*) osname="openbsd" ;;
218 + *-darwin*) osname="darwin" ;;
219 + *-solaris*) osname="solaris" ;;
220 + *-cygwin*) osname="cygwin" ;;
221 + *) osname="linux" ;;
222 + esac
223 +
224 + myarch="${CHOST%%-*}-${osname}"
225 + if use debug ; then
226 + myarch+="-debug"
227 + fi
228 + if use ithreads ; then
229 + mythreading="-multi"
230 + myarch+="-thread"
231 + fi
232 +
233 + PRIV_BASE="/usr/$(get_libdir)/perl5"
234 + SITE_BASE="/usr/local/$(get_libdir)/perl5"
235 + VENDOR_BASE="/usr/$(get_libdir)/perl5/vendor_perl"
236 +
237 + LIBPERL="libperl$(get_libname ${MY_PV} )"
238 +
239 + # This ENV var tells perl to build with a directory like "5.30"
240 + # regardless of its patch version. This is for experts only
241 + # at this point.
242 + if [[ -z "${PERL_SINGLE_SLOT}" ]]; then
243 + PRIV_LIB="${PRIV_BASE}/${MY_PV}"
244 + ARCH_LIB="${PRIV_BASE}/${MY_PV}/${myarch}${mythreading}"
245 + SITE_LIB="${SITE_BASE}/${MY_PV}"
246 + SITE_ARCH="${SITE_BASE}/${MY_PV}/${myarch}${mythreading}"
247 + VENDOR_LIB="${VENDOR_BASE}/${MY_PV}"
248 + VENDOR_ARCH="${VENDOR_BASE}/${MY_PV}/${myarch}${mythreading}"
249 + else
250 + PRIV_LIB="${PRIV_BASE}/${SUBSLOT}"
251 + ARCH_LIB="${PRIV_BASE}/${SUBSLOT}/${myarch}${mythreading}"
252 + SITE_LIB="${SITE_BASE}/${SUBSLOT}"
253 + SITE_ARCH="${SITE_BASE}/${SUBSLOT}/${myarch}${mythreading}"
254 + VENDOR_LIB="${VENDOR_BASE}/${SUBSLOT}"
255 + VENDOR_ARCH="${VENDOR_BASE}/${SUBSLOT}/${myarch}${mythreading}"
256 + fi
257 +
258 + dual_scripts
259 +}
260 +
261 +src_remove_dual_file() {
262 + local i pkg ver
263 + pkg="$1"
264 + ver="$2"
265 + shift 2
266 + case "${EBUILD_PHASE:-none}" in
267 + postinst|postrm)
268 + for i in "$@" ; do
269 + alternatives_auto_makesym "${i}" "${i}-[0-9]*"
270 + done
271 + ;;
272 + setup)
273 + for i in "$@" ; do
274 + if [[ -f ${EROOT}${i} && ! -h ${EROOT}${i} ]] ; then
275 + has_version ${pkg} && ewarn "You must reinstall ${pkg} !"
276 + break
277 + fi
278 + done
279 + ;;
280 + install)
281 + for i in "$@" ; do
282 + if ! [[ -f "${ED}"${i} ]] ; then
283 + ewarn "${i} does not exist!"
284 + continue
285 + fi
286 + mv "${ED}"${i}{,-${ver}-${P}} || die
287 + done
288 + ;;
289 + esac
290 +}
291 +
292 +src_remove_dual_man() {
293 + local i pkg ver ff
294 + pkg="$1"
295 + ver="$2"
296 + shift 2
297 + case "${EBUILD_PHASE:-none}" in
298 + postinst|postrm)
299 + for i in "$@" ; do
300 + ff=`echo "${EROOT}${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}}"*`
301 + ff=${ff##*${i#${i%.[0-9]}}}
302 + alternatives_auto_makesym "${i}${ff}" "${i%.[0-9]}-[0-9]*"
303 + done
304 + ;;
305 + install)
306 + for i in "$@" ; do
307 + if ! [[ -f "${ED}"${i} ]] ; then
308 + ewarn "${i} does not exist!"
309 + continue
310 + fi
311 + mv "${ED}"${i} "${ED}"${i%.[0-9]}-${ver}-${P}${i#${i%.[0-9]}} || die
312 + done
313 + ;;
314 + esac
315 +}
316 +
317 +src_remove_dual() {
318 + local i pkg ver
319 + pkg="$1"
320 + ver="$2"
321 + shift 2
322 + for i in "$@" ; do
323 + src_remove_dual_file "${pkg}" "${ver}" "/usr/bin/${i}"
324 + src_remove_dual_man "${pkg}" "${ver}" "/usr/share/man/man1/${i}.1"
325 + done
326 +}
327 +
328 +src_prepare_perlcross() {
329 + cp -a ../perl-cross-${CROSS_VER}/* . || die
330 +
331 + # bug 794463, needs further analysis what is exactly wrong here
332 + eapply "${FILESDIR}/perl-5.34.0-crossfit.patch"
333 +
334 + # bug 604072
335 + MAKEOPTS+=" -j1"
336 + export MAKEOPTS
337 +}
338 +src_prepare_dynamic() {
339 + ln -s ${LIBPERL} libperl$(get_libname ${SHORT_PV}) || die
340 + ln -s ${LIBPERL} libperl$(get_libname ) || die
341 +}
342 +
343 +# Copy a patch into the patch series
344 +# add_patch SRC_PATH DEST_NAME ['description'] ['bug'] ['bug']
345 +# - description is optional, but recommended
346 +# - all arguments after descriptions are bug URLs
347 +add_patch() {
348 + local patchdir="${WORKDIR}/patches"
349 + local infodir="${WORKDIR}/patch-info"
350 + local src_name dest_name desc
351 + src_name="$1"
352 + dest_name="$2"
353 + desc="$3"
354 + shift; shift; shift;
355 + einfo "Adding ${dest_name} to patch bundle"
356 + cp "${src_name}" "${patchdir}/${dest_name}" || die "Couldn't copy ${src_name} to ${dest_name}"
357 + if [[ -n "${desc}" ]]; then
358 + printf "%s" "${desc}" > "${infodir}/${dest_name}.desc" || die "Couldn't write ${dest_name}.desc"
359 + fi
360 + if [[ $# -gt 0 ]]; then
361 + # Note: when $@ is more than one element, this emits a
362 + # line for each element
363 + printf "%s\n" "$@" > "${infodir}/${dest_name}.bugs" || die "Couldn't write ${dest_name}.bugs"
364 + fi
365 +}
366 +# Remove a patch using a glob expr
367 +# eg:
368 +# rm_patch *-darin-Use-CC*
369 +#
370 +rm_patch() {
371 + local patchdir="${WORKDIR}/patches"
372 + local expr="$1"
373 + local patch="$( cd "${patchdir}"; echo $expr )"
374 + einfo "Removing $patch ($expr) from patch bundle"
375 + if [[ -e "${patchdir}/${patch}" ]]; then
376 + rm -f "${patchdir}/${patch}" || die "Can't remove ${patch} ( $expr )"
377 + else
378 + ewarn "No ${expr} found in ${patchdir} to remove"
379 + fi
380 +}
381 +# Yes, this is a reasonable amount of code for something seemingly simple
382 +# but this is far easier to debug when things go wrong, and things went wrong
383 +# multiple times while I was getting the exact number of slashes right, which
384 +# requires circumnavigating both bash and sed escape mechanisms.
385 +c_escape_string() {
386 + local slash dquote
387 + slash='\'
388 + dquote='"'
389 + re_slash="${slash}${slash}"
390 + re_dquote="${slash}${dquote}"
391 +
392 + # Convert \ to \\,
393 + # " to \"
394 + echo "$1" |\
395 + sed "s|${re_slash}|${re_slash}${re_slash}|g" |\
396 + sed "s|${re_dquote}|${re_slash}${re_dquote}|g"
397 +}
398 +c_escape_file() {
399 + c_escape_string "$(cat "$1")"
400 +}
401 +
402 +apply_patchdir() {
403 + local patchdir="${WORKDIR}/patches"
404 + local infodir="${WORKDIR}/patch-info"
405 + local patchoutput="patchlevel-gentoo.h"
406 +
407 + # Inject Patch-Level info into description for patchlevel.h patch
408 + # to show in -V
409 + local patch_expr="*List-packaged-patches*"
410 + local patch="$( cd "${patchdir}"; echo $patch_expr )";
411 + einfo "Injecting patch-level info into ${patch}.desc ( $patch_expr )"
412 +
413 + if [[ -e "${patchdir}/${patch}" ]]; then
414 + printf "List packaged patches for %s(%s) in patchlevel.h" "${PF}" "${PATCH_BASE}"\
415 + >"${infodir}/${patch}.desc" || die "Can't rewrite ${patch}.desc"
416 + else
417 + eerror "No $patch_expr found in ${patchdir}"
418 + fi
419 +
420 + # Compute patch list to apply
421 + # different name other than PATCHES to stop default
422 + # reapplying it
423 + # Single depth is currently only supported, as artifacts can reside
424 + # from the old layout being multiple-directories, as well as it grossly
425 + # simplifying the patchlevel_gentoo.h generation.
426 + local PERL_PATCHES=($(
427 + find "${patchdir}" -maxdepth 1 -mindepth 1 -type f -printf "%f\n" |\
428 + grep -E '[.](diff|patch)$' |\
429 + sort -n
430 + ))
431 +
432 + for patch in "${PERL_PATCHES[@]}"; do
433 + eapply "${WORKDIR}"/patches/${patch}
434 + done
435 +
436 + einfo "Generating $patchoutput"
437 +
438 + # This code creates a header file, each iteration
439 + # creates one-or-more-lines for each entry found in PERL_PATCHES
440 + # and STDOUT is redirected to the .h file
441 + for patch in "${PERL_PATCHES[@]}"; do
442 + local desc_f="${infodir}/${patch}.desc"
443 + local bugs_f="${infodir}/${patch}.bugs"
444 +
445 + printf ',"%s"\n' "${patch}"
446 + if [[ ! -e "${desc_f}" ]]; then
447 + ewarn "No description provided for ${patch} (expected: ${desc_f} )"
448 + else
449 + local desc="$(c_escape_file "${desc_f}")"
450 + printf ',"- %s"\n' "${desc}"
451 + fi
452 + if [[ -e "${bugs_f}" ]]; then
453 + while read -d $'\n' -r line; do
454 + local esc_line="$(c_escape_string "${line}")"
455 + printf ',"- Bug: %s"\n' "${esc_line}"
456 + done <"${bugs_f}"
457 + fi
458 + done > "${S}/${patchoutput}"
459 + printf "%s\n" "${patchoutput}" >> "${S}/MANIFEST"
460 +
461 +}
462 +src_prepare() {
463 + local patchdir="${WORKDIR}/patches"
464 +
465 + # Prepare Patch dir with additional patches / remove unwanted patches
466 + # Inject bug/desc entries for perl -V
467 + # Old example:
468 + # add_patch "${FILESDIR}/${PN}-5.26.2-hppa.patch" "100-5.26.2-hppa.patch"\
469 + # "Fix broken miniperl on hppa"\
470 + # "https://bugs.debian.org/869122" "https://bugs.gentoo.org/634162"
471 +
472 + add_patch "${FILESDIR}/${P}-gdbm-1.20.patch" "0101-Fix-build-with-gdb120.patch"\
473 + "Fix GDBM_File to compile with version 1.20 and earlier"\
474 + "https://bugs.gentoo.org/802945"
475 +
476 + if [[ ${CHOST} == *-solaris* ]] ; then
477 + # do NOT mess with nsl, on Solaris this is always necessary,
478 + # when -lsocket is used e.g. to get h_errno
479 + rm_patch "*-nsl-and-cl*"
480 + fi
481 +
482 + apply_patchdir
483 +
484 + tc-is-cross-compiler && src_prepare_perlcross
485 +
486 + tc-is-static-only || src_prepare_dynamic
487 +
488 + if use gdbm; then
489 + sed -i "s:INC => .*:INC => \"-I${EROOT}/usr/include/gdbm\":g" \
490 + ext/NDBM_File/Makefile.PL || die
491 + fi
492 +
493 + # Use errno.h from prefix rather than from host system, bug #645804
494 + if use prefix && [[ -e "${EPREFIX}"/usr/include/errno.h ]] ; then
495 + sed -i "/my..sysroot/s:'':'${EPREFIX}':" ext/Errno/Errno_pm.PL || die
496 + fi
497 +
498 + if [[ ${CHOST} == *-solaris* ]] ; then
499 + # set a soname, fix linking against just built libperl
500 + sed -i -e 's/netbsd\*/netbsd*|solaris*/' Makefile.SH || die
501 + fi
502 +
503 + if [[ ${CHOST} == *-darwin* ]] ; then
504 + # fix install_name (soname) not to reference $D
505 + sed -i -e '/install_name `pwd/s/`pwd`/\\$(shrpdir)/' Makefile.SH || die
506 + fi
507 +
508 + default
509 +}
510 +
511 +myconf() {
512 + # the myconf array is declared in src_configure
513 + myconf=( "${myconf[@]}" "$@" )
514 +}
515 +
516 +# Outputs a list of versions which have been seen in any of the
517 +# primary perl @INC prefix paths, such as:
518 +# /usr/lib64/perl5/<NUMBER>
519 +# /usr/local/lib64/perl5/<NUMBER>
520 +# /usr/lib64/perl5/vendor_perl/<NUMBER>
521 +#
522 +# All values of NUMBER must be like "5.x.y", unless PERL_SUPPORT_SINGLE_SLOT
523 +# is enabled, where it will also allow numbers like "5.x"
524 +#
525 +# PERL_SUPPORT_SINGLE_SLOT should only be used to transition *away* from PERL_SINGLE_SLOT
526 +# if you used that.
527 +find_candidate_inc_versions() {
528 + local regex='.*/5[.][0-9]+[.][0-9]+$';
529 + if [[ ! -z "${PERL_SUPPORT_SINGLE_SLOT}" || ! -z "${PERL_SINGLE_SLOT}" ]]; then
530 + regex='.*/5[.][0-9]+\([.][0-9]+\|\)$'
531 + fi
532 + local dirs=(
533 + "${EROOT}${PRIV_BASE}"
534 + "${EROOT}${SITE_BASE}"
535 + "${EROOT}${VENDOR_BASE}"
536 + )
537 + for dir in "${dirs[@]}"; do
538 + if [[ ! -e "${dir}" ]]; then
539 + continue
540 + fi
541 + # Without access to readdir() on these dirs, find will not be able
542 + # to reveal any @INC directories inside them, and will subsequently prune
543 + # them from the built perl's @INC support, breaking our compatiblity options
544 + # entirely.
545 + if [[ ! -r "${dir}" || ! -x "${dir}" ]]; then
546 + eerror "Bad permissions on ${dir}, this will probably break things"
547 + eerror "Ensure ${dir} is +rx for at least uid=$EUID"
548 + eerror "Recommended permission is +rx for all"
549 + eerror "> chmod o+rx ${dir}"
550 + fi
551 + done
552 + einfo "Scanning for old @INC dirs matching '$regex' in: ${dirs[*]}"
553 + find "${dirs[@]}" -maxdepth 1 -mindepth 1 -type d -regex "${regex}" -printf "%f " 2>/dev/null
554 +}
555 +# Sort versions passed versiony-ly, remove self-version if present
556 +# dedup. Takes each version as an argument
557 +sanitize_inc_versions() {
558 + local vexclude="${DIST_VERSION%-RC}"
559 + if [[ ! -z "${PERL_SINGLE_SLOT}" ]]; then
560 + vexclude="${SUBSLOT}"
561 + fi
562 + einfo "Normalizing/Sorting candidate list: $*"
563 + einfo " to remove '${vexclude}'"
564 + # Note, general numeric sort has to be used
565 + # for the last component, or unique will convert
566 + # 5.30.0 + 5.30 into just 5.30
567 + printf "%s\n" "$@" |\
568 + grep -vxF "${vexclude}" |\
569 + sort -u -nr -t'.' -k1,1rn -k2,2rn -k3,3rg
570 +}
571 +
572 +versions_to_inclist() {
573 + local oldv="${PERL_BIN_OLDVERSEN}"
574 + if [[ ! -z "${PERL_SINGLE_SLOT}" ]]; then
575 + oldv="${DIST_VERSION%-RC} ${PERL_BIN_OLDVERSEN}"
576 + fi
577 + for v; do
578 + has "${v}" ${oldv} && echo -n "${v}/${myarch}${mythreading}/ ";
579 + echo -n "${v}/ ";
580 + done
581 +}
582 +versions_to_gentoolibdirs() {
583 + local oldv="${PERL_BIN_OLDVERSEN}"
584 + local root
585 + local v
586 + if [[ ! -z "${PERL_SINGLE_SLOT}" ]]; then
587 + oldv="${DIST_VERSION%-RC} ${PERL_BIN_OLDVERSEN}"
588 + fi
589 + for v; do
590 + for root in "${PRIV_BASE}" "${VENDOR_BASE}" "${SITE_BASE}"; do
591 + local fullpath="${EROOT}${root}/${v}"
592 + if [[ -e "${fullpath}" ]]; then
593 + has "${v}" ${oldv} && printf "%s:" "${fullpath}/${myarch}${mythreading}";
594 + printf "%s:" "${fullpath}"
595 + fi
596 + done
597 + done
598 +}
599 +
600 +src_configure() {
601 + declare -a myconf
602 +
603 + export LC_ALL="C"
604 + [[ ${COLUMNS:-1} -ge 1 ]] || unset COLUMNS # bug #394091
605 +
606 + # Perl has problems compiling with -Os in your flags with glibc
607 + use elibc_uclibc || replace-flags "-Os" "-O2"
608 +
609 + # xlocale.h is going away in glibc-2.26, so it's counterproductive
610 + # if we use it and include it in CORE/perl.h ... Perl builds just
611 + # fine with glibc and locale.h only.
612 + # However, the darwin prefix people have no locale.h ...
613 + use elibc_glibc && myconf -Ui_xlocale
614 +
615 + # This flag makes compiling crash in interesting ways
616 + filter-flags "-malign-double"
617 +
618 + # Generic LTO broken since 5.28, triggers EUMM failures
619 + filter-flags "-flto"
620 +
621 + use sparc && myconf -Ud_longdbl
622 +
623 + export BUILD_BZIP2=0
624 + export BZIP2_INCLUDE=${EROOT}/usr/include
625 + export BZIP2_LIB=${EROOT}/usr/$(get_libdir)
626 +
627 + export BUILD_ZLIB=False
628 + export ZLIB_INCLUDE=${EROOT}/usr/include
629 + export ZLIB_LIB=${EROOT}/usr/$(get_libdir)
630 +
631 + # allow either gdbm to provide ndbm (in <gdbm/ndbm.h>) or db1
632 + myndbm='U'
633 + mygdbm='U'
634 + mydb='U'
635 + if use gdbm ; then
636 + mygdbm='D'
637 + if use berkdb ; then
638 + myndbm='D'
639 + fi
640 + fi
641 + if use berkdb ; then
642 + mydb='D'
643 + has_version '=sys-libs/db-1*' && myndbm='D'
644 + fi
645 +
646 + myconf "-${myndbm}i_ndbm" "-${mygdbm}i_gdbm" "-${mydb}i_db"
647 +
648 + if use alpha && [[ "$(tc-getCC)" = "ccc" ]] ; then
649 + ewarn "Perl will not be built with berkdb support, use gcc if you needed it..."
650 + myconf -Ui_db -Ui_ndbm
651 + fi
652 +
653 + use ithreads && myconf -Dusethreads
654 +
655 + if use debug ; then
656 + append-cflags "-g"
657 + myconf -DDEBUGGING
658 + elif [[ ${CFLAGS} == *-g* ]] ; then
659 + myconf -DDEBUGGING=-g
660 + else
661 + myconf -DDEBUGGING=none
662 + fi
663 +
664 + # modifying 'optimize' prevents cross configure script from appending required flags
665 + if tc-is-cross-compiler; then
666 + append-cflags "-fwrapv -fno-strict-aliasing"
667 + fi
668 +
669 + # Autodiscover all old version directories, some of them will even be newer
670 + # if you downgrade
671 + if [[ -z ${PERL_OLDVERSEN} ]]; then
672 + PERL_OLDVERSEN="$( find_candidate_inc_versions )"
673 + fi
674 +
675 + # Fixup versions, removing self match, fixing order and dupes
676 + PERL_OLDVERSEN="$( sanitize_inc_versions ${PERL_OLDVERSEN} )"
677 +
678 + # Experts who want a "Pure" install can set PERL_OLDVERSEN to an empty string
679 + if [[ -n "${PERL_OLDVERSEN// }" ]]; then
680 + local inclist="$( versions_to_inclist ${PERL_OLDVERSEN} )"
681 + einfo "This version of perl may partially support modules previously"
682 + einfo "installed in any of the following paths:"
683 + for incpath in ${inclist}; do
684 + [[ -e "${EROOT}${VENDOR_BASE}/${incpath}" ]] && einfo " ${EROOT}${VENDOR_BASE}/${incpath}"
685 + [[ -e "${EROOT}${PRIV_BASE}/${incpath}" ]] && einfo " ${EROOT}${PRIV_BASE}/${incpath}"
686 + [[ -e "${EROOT}${SITE_BASE}/${incpath}" ]] && einfo " ${EROOT}${SITE_BASE}/${incpath}"
687 + done
688 + einfo "This is a temporary measure and you should aim to cleanup these paths"
689 + einfo "via world updates and perl-cleaner"
690 + # myconf -Dinc_version_list="${inclist}"
691 + myconf -Dgentoolibdirs="$( versions_to_gentoolibdirs ${PERL_OLDVERSEN} )"
692 + fi
693 +
694 + [[ ${ELIBC} == "FreeBSD" ]] && myconf "-Dlibc=/usr/$(get_libdir)/libc.a"
695 +
696 + # Make sure we can do the final link #523730, need to set deployment
697 + # target to override hardcoded 10.3 which breaks on modern OSX
698 + [[ ${CHOST} == *-darwin* ]] && \
699 + myconf "-Dld=env MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} $(tc-getCC)"
700 +
701 + # Older macOS with non-Apple GCC chokes on inline in system headers
702 + # using c89 mode as injected by cflags.SH
703 + [[ ${CHOST} == *-darwin* && ${CHOST##*darwin} -le 9 ]] && tc-is-gcc && \
704 + append-cflags -Dinline=__inline__
705 +
706 + # flock on 32-bit sparc Solaris is broken, fall back to fcntl
707 + [[ ${CHOST} == sparc-*-solaris* ]] && \
708 + myconf -Ud_flock
709 +
710 + # Prefix: the host system needs not to follow Gentoo multilib stuff, and in
711 + # Prefix itself we don't do multilib either, so make sure perl can find
712 + # something compatible.
713 + if use prefix ; then
714 + # Set a hook to check for each detected library whether it actually works.
715 + export libscheck="
716 + ( echo 'main(){}' > '${T}'/conftest.c &&
717 + $(tc-getCC) -o '${T}'/conftest '${T}'/conftest.c -l\$thislib >/dev/null 2>/dev/null
718 + ) || xxx=/dev/null"
719 +
720 + # Use all host paths that might contain useful stuff, the hook above will filter out bad choices.
721 + local paths="/lib/*-linux-gnu /usr/lib/*-linux-gnu /lib64 /lib/64 /usr/lib64 /usr/lib/64 /lib32 /usr/lib32 /lib /usr/lib"
722 + myconf "-Dlibpth=${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir) ${paths}"
723 + elif [[ $(get_libdir) != "lib" ]] ; then
724 + # We need to use " and not ', as the written config.sh use ' ...
725 + myconf "-Dlibpth=/usr/local/$(get_libdir) /$(get_libdir) /usr/$(get_libdir)"
726 + fi
727 +
728 + # don't try building ODBM, bug #354453
729 + disabled_extensions="ODBM_File"
730 +
731 + if ! use gdbm ; then
732 + # workaround for bug #157774: don't try building GDBM related stuff with USE="-gdbm"
733 + disabled_extensions="${disabled_extensions} GDBM_File NDBM_File"
734 + fi
735 +
736 + myconf -Dnoextensions="${disabled_extensions}"
737 +
738 + [[ "${PV##*.}" == "9999" ]] && myconf -Dusedevel -Uversiononly
739 +
740 + [[ -n "${EXTRA_ECONF}" ]] && ewarn During Perl build, EXTRA_ECONF=${EXTRA_ECONF}
741 + # allow fiddling via EXTRA_ECONF, bug 558070
742 + eval "local -a EXTRA_ECONF=(${EXTRA_ECONF})"
743 +
744 + # setting -Dld= to tc-getLD breaks perl and all perl things
745 + # https://github.com/Perl/perl5/issues/17791#issuecomment-630145202
746 + myconf \
747 + -Duseshrplib \
748 + -Darchname="${myarch}" \
749 + -Dcc="$(tc-getCC)" \
750 + -Dar="$(tc-getAR)" \
751 + -Dnm="$(tc-getNM)" \
752 + -Dcpp="$(tc-getCPP)" \
753 + -Dranlib="$(tc-getRANLIB)" \
754 + -Doptimize="${CFLAGS}" \
755 + -Dldflags="${LDFLAGS}" \
756 + -Dprefix="${EPREFIX}"'/usr' \
757 + -Dsiteprefix="${EPREFIX}"'/usr/local' \
758 + -Dvendorprefix="${EPREFIX}"'/usr' \
759 + -Dscriptdir="${EPREFIX}"'/usr/bin' \
760 + -Dprivlib="${EPREFIX}${PRIV_LIB}" \
761 + -Darchlib="${EPREFIX}${ARCH_LIB}" \
762 + -Dsitelib="${EPREFIX}${SITE_LIB}" \
763 + -Dsitearch="${EPREFIX}${SITE_ARCH}" \
764 + -Dvendorlib="${EPREFIX}${VENDOR_LIB}" \
765 + -Dvendorarch="${EPREFIX}${VENDOR_ARCH}" \
766 + -Dman1dir="${EPREFIX}"/usr/share/man/man1 \
767 + -Dman3dir="${EPREFIX}"/usr/share/man/man3 \
768 + -Dsiteman1dir="${EPREFIX}"/usr/local/man/man1 \
769 + -Dsiteman3dir="${EPREFIX}"/usr/local/man/man3 \
770 + -Dvendorman1dir="${EPREFIX}"/usr/share/man/man1 \
771 + -Dvendorman3dir="${EPREFIX}"/usr/share/man/man3 \
772 + -Dman1ext='1' \
773 + -Dman3ext='3pm' \
774 + -Dlibperl="${LIBPERL}" \
775 + -Dlocincpth="${EPREFIX}"'/usr/include ' \
776 + -Dglibpth="${EPREFIX}/$(get_libdir) ${EPREFIX}/usr/$(get_libdir)"' ' \
777 + -Duselargefiles \
778 + -Dd_semctl_semun \
779 + -Dcf_by='Gentoo' \
780 + -Dmyhostname='localhost' \
781 + -Dperladmin='root@localhost' \
782 + -Ud_csh \
783 + -Dsh="${EPREFIX}"/bin/sh \
784 + -Dtargetsh="${EPREFIX}"/bin/sh \
785 + -Uusenm \
786 + "${myconf[@]}" \
787 + "${EXTRA_ECONF[@]}"
788 +
789 + if tc-is-cross-compiler; then
790 + ./configure \
791 + --target="${CHOST}" \
792 + --build="${CBUILD}" \
793 + -Dinstallprefix='' \
794 + -Dinstallusrbinperl='undef' \
795 + -Dusevendorprefix='define' \
796 + "${myconf[@]}" \
797 + || die "Unable to configure"
798 + else
799 + sh Configure \
800 + -des \
801 + -Dinstallprefix="${EPREFIX}"'/usr' \
802 + -Dinstallusrbinperl='n' \
803 + "${myconf[@]}" \
804 + || die "Unable to configure"
805 + fi
806 +}
807 +
808 +src_test() {
809 + export NO_GENTOO_NETWORK_TESTS=1;
810 + export GENTOO_ASSUME_SANDBOXED="${GENTOO_ASSUME_SANDBOXED:-1}"
811 + export GENTOO_NO_PORTING_TESTS="${GENTOO_NO_PORTING_TESTS:-1}"
812 + if [[ ${EUID} == 0 ]] ; then
813 + ewarn "Test fails with a sandbox error (#328793) if run as root. Skipping tests..."
814 + return 0
815 + fi
816 + use elibc_uclibc && export MAKEOPTS+=" -j1"
817 + TEST_JOBS="$(makeopts_jobs)" make test_harness || die "test failed"
818 +}
819 +
820 +src_install() {
821 + local i
822 + local coredir="${ARCH_LIB}/CORE"
823 +
824 + emake DESTDIR="${D}" install
825 +
826 + rm -f "${ED}/usr/bin/perl${MY_PV}"
827 + ln -s perl "${ED}"/usr/bin/perl${MY_PV} || die
828 +
829 + if ! tc-is-static-only ; then
830 + dolib.so "${ED}"${coredir}/${LIBPERL}
831 + rm -f "${ED}"${coredir}/${LIBPERL}
832 + ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname ${SHORT_PV}) || die
833 + ln -sf ${LIBPERL} "${ED}"/usr/$(get_libdir)/libperl$(get_libname) || die
834 +
835 + ln -sf ../../../../${LIBPERL} "${ED}"${coredir}/${LIBPERL} || die
836 + ln -sf ../../../../${LIBPERL} "${ED}"${coredir}/libperl$(get_libname ${SHORT_PV}) || die
837 + ln -sf ../../../../${LIBPERL} "${ED}"${coredir}/libperl$(get_libname) || die
838 + fi
839 +
840 + rm -rf "${ED}"/usr/share/man/man3 || die "Unable to remove module man pages"
841 +
842 + # This removes ${D} from Config.pm
843 + for i in $(find "${D}" -iname "Config.pm" ) ; do
844 + einfo "Removing ${D} from ${i}..."
845 + sed -i -e "s:${D}::" "${i}" || die "Sed failed"
846 + done
847 +
848 + dodoc Changes* README AUTHORS
849 +
850 + if use doc ; then
851 + # HTML Documentation
852 + # We expect errors, warnings, and such with the following.
853 +
854 + dodir /usr/share/doc/${PF}/html
855 + LD_LIBRARY_PATH=. ./perl installhtml \
856 + --podroot='.' \
857 + --podpath='lib:ext:pod:vms' \
858 + --recurse \
859 + --htmldir="${ED}/usr/share/doc/${PF}/html"
860 + fi
861 +
862 + [[ -d ${ED}/usr/local ]] && rm -r "${ED}"/usr/local
863 +
864 + dual_scripts
865 +}
866 +
867 +pkg_preinst() {
868 + check_rebuild
869 +}
870 +
871 +pkg_postinst() {
872 + dual_scripts
873 +
874 + if [[ "${ROOT}" = "/" ]] ; then
875 + local INC DIR file
876 + INC=$(perl -e 'for $line (@INC) { next if $line eq "."; next if $line =~ m/'${SHORT_PV}'|etc|local|perl$/; print "$line\n" }')
877 + einfo "Removing old .ph files"
878 + for DIR in ${INC} ; do
879 + if [[ -d "${DIR}" ]] ; then
880 + for file in $(find "${DIR}" -name "*.ph" -type f ) ; do
881 + rm -f "${file}"
882 + einfo "<< ${file}"
883 + done
884 + fi
885 + done
886 + # Silently remove the now empty dirs
887 + for DIR in ${INC} ; do
888 + if [[ -d "${DIR}" ]] ; then
889 + find "${DIR}" -depth -type d -print0 | xargs -0 -r rmdir &> /dev/null
890 + fi
891 + done
892 +
893 + fi
894 +}
895 +
896 +pkg_postrm() {
897 + dual_scripts
898 +}