Gentoo Archives: gentoo-commits

From: "Andreas Hüttel" <dilfridge@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sat, 28 Nov 2015 20:52:45
Message-Id: 1448743134.ba4702709755b69cab98d7ab284c42ebe18f830d.dilfridge@gentoo
1 commit: ba4702709755b69cab98d7ab284c42ebe18f830d
2 Author: Andreas K. Huettel (dilfridge) <dilfridge <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 22 20:52:23 2015 +0000
4 Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org>
5 CommitDate: Sat Nov 28 20:38:54 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ba470270
7
8 perl-modules.eclass: Separate phases and helpers into two eclasses
9
10 eclass/perl-functions.eclass | 252 +++++++++++++++++++++++++++++++++++++++++++
11 eclass/perl-module.eclass | 230 +--------------------------------------
12 2 files changed, 256 insertions(+), 226 deletions(-)
13
14 diff --git a/eclass/perl-functions.eclass b/eclass/perl-functions.eclass
15 new file mode 100644
16 index 0000000..7ba47d1
17 --- /dev/null
18 +++ b/eclass/perl-functions.eclass
19 @@ -0,0 +1,252 @@
20 +# Copyright 1999-2015 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +# $Id$
23 +
24 +# @ECLASS: perl-functions.eclass
25 +# @MAINTAINER:
26 +# perl@g.o
27 +# @AUTHOR:
28 +# Seemant Kulleen <seemant@g.o>
29 +# Andreas K. Huettel <dilfridge@g.o>
30 +# @BLURB: helper functions eclass for perl modules
31 +# @DESCRIPTION:
32 +# The perl-functions eclass is designed to allow easier installation of perl
33 +# modules, and their incorporation into the Gentoo Linux system.
34 +# It provides helper functions, no phases or variable manipulation in
35 +# global scope.
36 +
37 +[[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
38 +
39 +case "${EAPI:-0}" in
40 + 5)
41 + ;;
42 + *)
43 + die "EAPI=${EAPI} is not supported by perl-functions.eclass"
44 + ;;
45 +esac
46 +
47 +perlinfo_done=false
48 +
49 +# @FUNCTION: perl_set_version
50 +# @USAGE: perl_set_version
51 +# @DESCRIPTION:
52 +# Extract version information and installation paths from the current Perl
53 +# interpreter.
54 +#
55 +# This sets the following variables: PERL_VERSION, SITE_ARCH, SITE_LIB,
56 +# ARCH_LIB, VENDOR_LIB, VENDOR_ARCH
57 +#
58 +# This function used to be called perlinfo as well.
59 +perl_set_version() {
60 + debug-print-function $FUNCNAME "$@"
61 + debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
62 + ${perlinfo_done} && return 0
63 + perlinfo_done=true
64 +
65 + local f version install{{site,vendor}{arch,lib},archlib}
66 + eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
67 + PERL_VERSION=${version}
68 + SITE_ARCH=${installsitearch}
69 + SITE_LIB=${installsitelib}
70 + ARCH_LIB=${installarchlib}
71 + VENDOR_LIB=${installvendorlib}
72 + VENDOR_ARCH=${installvendorarch}
73 +}
74 +
75 +# @FUNCTION: perl_delete_localpod
76 +# @USAGE: perl_delete_localpod
77 +# @DESCRIPTION:
78 +# Remove stray perllocal.pod files in the temporary install directory D.
79 +#
80 +# This function used to be called fixlocalpod as well.
81 +perl_delete_localpod() {
82 + debug-print-function $FUNCNAME "$@"
83 +
84 + find "${D}" -type f -name perllocal.pod -delete
85 + find "${D}" -depth -mindepth 1 -type d -empty -delete
86 +}
87 +
88 +# @FUNCTION: perl_fix_osx_extra
89 +# @USAGE: perl_fix_osx_extra
90 +# @DESCRIPTION:
91 +# Look through ${S} for AppleDouble encoded files and get rid of them.
92 +perl_fix_osx_extra() {
93 + debug-print-function $FUNCNAME "$@"
94 +
95 + local f
96 + find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
97 + einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
98 + rm -f "${f}"
99 + f=${f#${S}/}
100 + grep -q "${f}" "${S}"/MANIFEST && \
101 + elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
102 + done
103 +}
104 +
105 +# @FUNCTION: perl_delete_module_manpages
106 +# @USAGE: perl_delete_module_manpages
107 +# @DESCRIPTION:
108 +# Bump off manpages installed by the current module such as *.3pm files as well
109 +# as empty directories.
110 +perl_delete_module_manpages() {
111 + debug-print-function $FUNCNAME "$@"
112 +
113 + if [[ -d "${ED}"/usr/share/man ]] ; then
114 + find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
115 + find "${ED}"/usr/share/man -depth -type d -empty -delete
116 + fi
117 +}
118 +
119 +# @FUNCTION: perl_delete_packlist
120 +# @USAGE: perl_delete_packlist
121 +# @DESCRIPTION:
122 +# Look through ${D} for .packlist files, empty .bs files and empty directories,
123 +# and get rid of items found.
124 +perl_delete_packlist() {
125 + debug-print-function $FUNCNAME "$@"
126 + perl_set_version
127 + if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
128 + find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
129 + -o \( -name '*.bs' -a -empty \) \) -delete
130 + find "${D}" -depth -mindepth 1 -type d -empty -delete
131 + fi
132 +}
133 +
134 +# @FUNCTION: perl_remove_temppath
135 +# @USAGE: perl_remove_temppath
136 +# @DESCRIPTION:
137 +# Look through ${D} for text files containing the temporary installation
138 +# folder (i.e. ${D}). If the pattern is found (i.e. " text"), replace it with `/'.
139 +perl_remove_temppath() {
140 + debug-print-function $FUNCNAME "$@"
141 +
142 + find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
143 + if file "${f}" | grep -q -i " text" ; then
144 + grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
145 + sed -i -e "s:${D}:/:g" "${f}"
146 + fi
147 + done
148 +}
149 +
150 +# @FUNCTION: perl_rm_files
151 +# @USAGE: perl_rm_files "file_1" "file_2"
152 +# @DESCRIPTION:
153 +# Remove certain files from a Perl release and remove them from the MANIFEST
154 +# while we're there.
155 +#
156 +# Most useful in src_prepare for nuking bad tests, and is highly recommended
157 +# for any tests like 'pod.t', 'pod-coverage.t' or 'kwalitee.t', as what they
158 +# test is completely irrelevant to end users, and frequently fail simply
159 +# because the authors of Test::Pod... changed their recommendations, and thus
160 +# failures are only useful feedback to Authors, not users.
161 +#
162 +# Removing from MANIFEST also avoids needless log messages warning
163 +# users about files "missing from their kit".
164 +perl_rm_files() {
165 + debug-print-function $FUNCNAME "$@"
166 + local skipfile="${T}/.gentoo_makefile_skip"
167 + local manifile="${S}/MANIFEST"
168 + local manitemp="${T}/.gentoo_manifest_temp"
169 + oldifs="$IFS"
170 + IFS="\n"
171 + for filename in "$@"; do
172 + einfo "Removing un-needed ${filename}";
173 + # Remove the file
174 + rm -f "${S}/${filename}"
175 + [[ -e "${manifile}" ]] && echo "${filename}" >> "${skipfile}"
176 + done
177 + if [[ -e "${manifile}" && -e "${skipfile}" ]]; then
178 + einfo "Fixing Manifest"
179 + grep -v -F -f "${skipfile}" "${manifile}" > "${manitemp}"
180 + mv -f -- "${manitemp}" "${manifile}"
181 + rm -- "${skipfile}";
182 + fi
183 + IFS="$oldifs"
184 +}
185 +
186 +# @FUNCTION: perl_link_duallife_scripts
187 +# @USAGE: perl_link_duallife_scripts
188 +# @DESCRIPTION:
189 +# Moves files and generates symlinks so dual-life packages installing scripts do not
190 +# lead to file collisions. Mainly for use in pkg_postinst and pkg_postrm, and makes
191 +# only sense for perl-core packages.
192 +perl_link_duallife_scripts() {
193 + debug-print-function $FUNCNAME "$@"
194 + if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
195 + return 0
196 + fi
197 +
198 + local i ff
199 + if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
200 + for i in "${DUALLIFESCRIPTS[@]}" ; do
201 + alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
202 + done
203 + for i in "${DUALLIFEMAN[@]}" ; do
204 + ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
205 + ff=${ff##*.1}
206 + alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
207 + done
208 + else
209 + pushd "${ED}" > /dev/null
210 + for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
211 + mv ${i}{,-${PV}-${P}} || die
212 + #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
213 + DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
214 + done
215 + for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
216 + mv ${i} ${i%.1}-${PV}-${P}.1 || die
217 + DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
218 + done
219 + popd > /dev/null
220 + fi
221 +}
222 +
223 +# @FUNCTION: perl_check_env
224 +# @USAGE: perl_check_env
225 +# @DESCRIPTION:
226 +# Checks a blacklist of known-suspect ENV values that can be accidentally set by users
227 +# doing personal perl work, which may accidentally leak into portage and break the
228 +# system perl installaton.
229 +# Dies if any of the suspect fields are found, and tell the user what needs to be unset.
230 +# There's a workaround, but you'll have to read the code for it.
231 +perl_check_env() {
232 + local errored value;
233 +
234 + for i in PERL_MM_OPT PERL5LIB PERL5OPT PERL_MB_OPT PERL_CORE PERLPREFIX; do
235 + # Next unless match
236 + [ -v $i ] || continue;
237 +
238 + # Warn only once, and warn only when one of the bad values are set.
239 + # record failure here.
240 + if [ ${errored:-0} == 0 ]; then
241 + if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
242 + elog "perl-module.eclass: Suspicious environment values found.";
243 + else
244 + eerror "perl-module.eclass: Suspicious environment values found.";
245 + fi
246 + fi
247 + errored=1
248 +
249 + # Read ENV Value
250 + eval "value=\$$i";
251 +
252 + # Print ENV name/value pair
253 + if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
254 + elog " $i=\"$value\"";
255 + else
256 + eerror " $i=\"$value\"";
257 + fi
258 + done
259 +
260 + # Return if there were no failures
261 + [ ${errored:-0} == 0 ] && return;
262 +
263 + # Return if user knows what they're doing
264 + if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
265 + elog "Continuing anyway, seems you know what you're doing."
266 + return
267 + fi
268 +
269 + eerror "Your environment settings may lead to undefined behavior and/or build failures."
270 + die "Please fix your environment ( ~/.bashrc, package.env, ... ), see above for details."
271 +}
272
273 diff --git a/eclass/perl-module.eclass b/eclass/perl-module.eclass
274 index 341fa89..5a476d2 100644
275 --- a/eclass/perl-module.eclass
276 +++ b/eclass/perl-module.eclass
277 @@ -7,13 +7,15 @@
278 # perl@g.o
279 # @AUTHOR:
280 # Seemant Kulleen <seemant@g.o>
281 +# Andreas K. Huettel <dilfridge@g.o>
282 # @BLURB: eclass for perl modules
283 # @DESCRIPTION:
284 # The perl-module eclass is designed to allow easier installation of perl
285 # modules, and their incorporation into the Gentoo Linux system.
286 +# All exported functions from perl-functions.eclass (inherited here)
287 +# explicitly also belong to the interface of perl-module.eclass.
288
289 -inherit eutils multiprocessing unpacker
290 -[[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
291 +inherit eutils multiprocessing unpacker perl-functions
292
293 PERL_EXPF="src_unpack src_prepare src_configure src_compile src_test src_install"
294
295 @@ -321,227 +323,3 @@ perl-module_pkg_postrm() {
296 fi
297 perl_link_duallife_scripts
298 }
299 -
300 -# @FUNCTION: perl_set_version
301 -# @USAGE: perl_set_version
302 -# @DESCRIPTION:
303 -# Extract version information and installation paths from the current Perl
304 -# interpreter.
305 -#
306 -# This sets the following variables: PERL_VERSION, SITE_ARCH, SITE_LIB,
307 -# ARCH_LIB, VENDOR_LIB, VENDOR_ARCH
308 -#
309 -# This function used to be called perlinfo as well.
310 -perl_set_version() {
311 - debug-print-function $FUNCNAME "$@"
312 - debug-print "$FUNCNAME: perlinfo_done=${perlinfo_done}"
313 - ${perlinfo_done} && return 0
314 - perlinfo_done=true
315 -
316 - local f version install{{site,vendor}{arch,lib},archlib}
317 - eval "$(perl -V:{version,install{{site,vendor}{arch,lib},archlib}} )"
318 - PERL_VERSION=${version}
319 - SITE_ARCH=${installsitearch}
320 - SITE_LIB=${installsitelib}
321 - ARCH_LIB=${installarchlib}
322 - VENDOR_LIB=${installvendorlib}
323 - VENDOR_ARCH=${installvendorarch}
324 -}
325 -
326 -# @FUNCTION: perl_delete_localpod
327 -# @USAGE: perl_delete_localpod
328 -# @DESCRIPTION:
329 -# Remove stray perllocal.pod files in the temporary install directory D.
330 -#
331 -# This function used to be called fixlocalpod as well.
332 -perl_delete_localpod() {
333 - debug-print-function $FUNCNAME "$@"
334 -
335 - find "${D}" -type f -name perllocal.pod -delete
336 - find "${D}" -depth -mindepth 1 -type d -empty -delete
337 -}
338 -
339 -# @FUNCTION: perl_fix_osx_extra
340 -# @USAGE: perl_fix_osx_extra
341 -# @DESCRIPTION:
342 -# Look through ${S} for AppleDouble encoded files and get rid of them.
343 -perl_fix_osx_extra() {
344 - debug-print-function $FUNCNAME "$@"
345 -
346 - local f
347 - find "${S}" -type f -name "._*" -print0 | while read -rd '' f ; do
348 - einfo "Removing AppleDouble encoded Macintosh file: ${f#${S}/}"
349 - rm -f "${f}"
350 - f=${f#${S}/}
351 - grep -q "${f}" "${S}"/MANIFEST && \
352 - elog "AppleDouble encoded Macintosh file in MANIFEST: ${f#${S}/}"
353 - done
354 -}
355 -
356 -# @FUNCTION: perl_delete_module_manpages
357 -# @USAGE: perl_delete_module_manpages
358 -# @DESCRIPTION:
359 -# Bump off manpages installed by the current module such as *.3pm files as well
360 -# as empty directories.
361 -perl_delete_module_manpages() {
362 - debug-print-function $FUNCNAME "$@"
363 -
364 - if [[ -d "${ED}"/usr/share/man ]] ; then
365 - find "${ED}"/usr/share/man -type f -name "*.3pm" -delete
366 - find "${ED}"/usr/share/man -depth -type d -empty -delete
367 - fi
368 -}
369 -
370 -# @FUNCTION: perl_delete_packlist
371 -# @USAGE: perl_delete_packlist
372 -# @DESCRIPTION:
373 -# Look through ${D} for .packlist files, empty .bs files and empty directories,
374 -# and get rid of items found.
375 -perl_delete_packlist() {
376 - debug-print-function $FUNCNAME "$@"
377 - perl_set_version
378 - if [[ -d ${D}/${VENDOR_ARCH} ]] ; then
379 - find "${D}/${VENDOR_ARCH}" -type f -a \( -name .packlist \
380 - -o \( -name '*.bs' -a -empty \) \) -delete
381 - find "${D}" -depth -mindepth 1 -type d -empty -delete
382 - fi
383 -}
384 -
385 -# @FUNCTION: perl_remove_temppath
386 -# @USAGE: perl_remove_temppath
387 -# @DESCRIPTION:
388 -# Look through ${D} for text files containing the temporary installation
389 -# folder (i.e. ${D}). If the pattern is found (i.e. " text"), replace it with `/'.
390 -perl_remove_temppath() {
391 - debug-print-function $FUNCNAME "$@"
392 -
393 - find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
394 - if file "${f}" | grep -q -i " text" ; then
395 - grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
396 - sed -i -e "s:${D}:/:g" "${f}"
397 - fi
398 - done
399 -}
400 -
401 -# @FUNCTION: perl_rm_files
402 -# @USAGE: perl_rm_files "file_1" "file_2"
403 -# @DESCRIPTION:
404 -# Remove certain files from a Perl release and remove them from the MANIFEST
405 -# while we're there.
406 -#
407 -# Most useful in src_prepare for nuking bad tests, and is highly recommended
408 -# for any tests like 'pod.t', 'pod-coverage.t' or 'kwalitee.t', as what they
409 -# test is completely irrelevant to end users, and frequently fail simply
410 -# because the authors of Test::Pod... changed their recommendations, and thus
411 -# failures are only useful feedback to Authors, not users.
412 -#
413 -# Removing from MANIFEST also avoids needless log messages warning
414 -# users about files "missing from their kit".
415 -perl_rm_files() {
416 - debug-print-function $FUNCNAME "$@"
417 - local skipfile="${T}/.gentoo_makefile_skip"
418 - local manifile="${S}/MANIFEST"
419 - local manitemp="${T}/.gentoo_manifest_temp"
420 - oldifs="$IFS"
421 - IFS="\n"
422 - for filename in "$@"; do
423 - einfo "Removing un-needed ${filename}";
424 - # Remove the file
425 - rm -f "${S}/${filename}"
426 - [[ -e "${manifile}" ]] && echo "${filename}" >> "${skipfile}"
427 - done
428 - if [[ -e "${manifile}" && -e "${skipfile}" ]]; then
429 - einfo "Fixing Manifest"
430 - grep -v -F -f "${skipfile}" "${manifile}" > "${manitemp}"
431 - mv -f -- "${manitemp}" "${manifile}"
432 - rm -- "${skipfile}";
433 - fi
434 - IFS="$oldifs"
435 -}
436 -
437 -# @FUNCTION: perl_link_duallife_scripts
438 -# @USAGE: perl_link_duallife_scripts
439 -# @DESCRIPTION:
440 -# Moves files and generates symlinks so dual-life packages installing scripts do not
441 -# lead to file collisions. Mainly for use in pkg_postinst and pkg_postrm, and makes
442 -# only sense for perl-core packages.
443 -perl_link_duallife_scripts() {
444 - debug-print-function $FUNCNAME "$@"
445 - if [[ ${CATEGORY} != perl-core ]] || ! has_version ">=dev-lang/perl-5.8.8-r8" ; then
446 - return 0
447 - fi
448 -
449 - local i ff
450 - if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
451 - for i in "${DUALLIFESCRIPTS[@]}" ; do
452 - alternatives_auto_makesym "/${i}" "/${i}-[0-9]*"
453 - done
454 - for i in "${DUALLIFEMAN[@]}" ; do
455 - ff=`echo "${EROOT}"/${i%.1}-${PV}-${P}.1*`
456 - ff=${ff##*.1}
457 - alternatives_auto_makesym "/${i}${ff}" "/${i%.1}-[0-9]*"
458 - done
459 - else
460 - pushd "${ED}" > /dev/null
461 - for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
462 - mv ${i}{,-${PV}-${P}} || die
463 - #DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
464 - DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i}
465 - done
466 - for i in $(find usr/share/man/man1 -maxdepth 1 -type f 2>/dev/null) ; do
467 - mv ${i} ${i%.1}-${PV}-${P}.1 || die
468 - DUALLIFEMAN[${#DUALLIFEMAN[*]}]=${i}
469 - done
470 - popd > /dev/null
471 - fi
472 -}
473 -
474 -# @FUNCTION: perl_check_env
475 -# @USAGE: perl_check_env
476 -# @DESCRIPTION:
477 -# Checks a blacklist of known-suspect ENV values that can be accidentally set by users
478 -# doing personal perl work, which may accidentally leak into portage and break the
479 -# system perl installaton.
480 -# Dies if any of the suspect fields are found, and tell the user what needs to be unset.
481 -# There's a workaround, but you'll have to read the code for it.
482 -perl_check_env() {
483 - local errored value;
484 -
485 - for i in PERL_MM_OPT PERL5LIB PERL5OPT PERL_MB_OPT PERL_CORE PERLPREFIX; do
486 - # Next unless match
487 - [ -v $i ] || continue;
488 -
489 - # Warn only once, and warn only when one of the bad values are set.
490 - # record failure here.
491 - if [ ${errored:-0} == 0 ]; then
492 - if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
493 - elog "perl-module.eclass: Suspicious environment values found.";
494 - else
495 - eerror "perl-module.eclass: Suspicious environment values found.";
496 - fi
497 - fi
498 - errored=1
499 -
500 - # Read ENV Value
501 - eval "value=\$$i";
502 -
503 - # Print ENV name/value pair
504 - if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
505 - elog " $i=\"$value\"";
506 - else
507 - eerror " $i=\"$value\"";
508 - fi
509 - done
510 -
511 - # Return if there were no failures
512 - [ ${errored:-0} == 0 ] && return;
513 -
514 - # Return if user knows what they're doing
515 - if [ -n "${I_KNOW_WHAT_I_AM_DOING}" ]; then
516 - elog "Continuing anyway, seems you know what you're doing."
517 - return
518 - fi
519 -
520 - eerror "Your environment settings may lead to undefined behavior and/or build failures."
521 - die "Please fix your environment ( ~/.bashrc, package.env, ... ), see above for details."
522 -}