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