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