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