perl-5.40.0.ebuild 27 KB

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