Gentoo Archives: gentoo-dev

From: Duncan <1i5t5.duncan@×××.net>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Re: [PATCH 09/15] perl-module.eclass: Use DIST_ prefix instead of MODULE_ prefix in EAPI=6 for control variables.
Date: Sat, 12 Dec 2015 09:15:32
Message-Id: pan$c2607$140dfec8$c28b7cca$6586ccc@cox.net
In Reply to: [gentoo-dev] [PATCH 09/15] perl-module.eclass: Use DIST_ prefix instead of MODULE_ prefix in EAPI=6 for control variables. by dilfridge@gentoo.org
1 dilfridge posted on Fri, 11 Dec 2015 22:03:05 +0100 as excerpted:
2
3 > -# @ECLASS-VARIABLE: MODULE_VERSION
4 > +# @ECLASS-VARIABLE: DIST_VERSION
5 > # @DESCRIPTION:
6 > -# This variable provides a way to override PV for the calculation of S and SRC_URI.
7 > +# (EAPI=6) This variable provides a way to override PV for the calculation of S and SRC_URI.
8 > # Use it to provide the non-normalized, upstream version number. Defaults to PV.
9 > +# Named MODULE_VERSION in EAPI=5.
10
11 Dev-author's discretion, here and below, as it's purely style, but...
12
13 What I would have expected to see here (and in other docs-related patches) would be cleanly
14 separate EAPI-5 vs. EAPI-6 descriptions, on separate lines, so when EAPI-5 support cleanup
15 time comes, it's easy to simply delete EAPI-5 lines. Something like:
16
17 +# ECLASS-VARIABLE: DIST_VERSION
18 +# (EAPI=6)
19 +# This variable provides a way to override PV for the calculation of S and SRC_URI.
20 +
21 # @ECLASS-VARIABLE: MODULE_VERSION
22 # @DESCRIPTION:
23 -# This variable provides a way to override PV for the calculation of S and SRC_URI.
24 +# (EAPI-5 version of DIST_VERSION)
25
26 With this, EAPI-5 cleanup should be purely lines deleted (including the EAPI-6 on its own line).
27 Additionally, people (like me) trying to debug failing existing EAPI-5 ebuilds won't be having
28 to look for EAPI-5 var-names at unexpected locations in the documentation. =:^)
29
30 Of course for the other vars that change names but not functionality between the two
31 EAPIs, both in this patch and in others, as well.
32
33 (Don't miss the further comment below.)
34
35 > @@ -146,19 +147,26 @@ if [[ ${EAPI:-0} = 5 ]] ; then
36 > fi
37 > MODULE_NAME=${MY_PN:-${PN}}
38 > MODULE_P=${MY_P:-${P}}
39 > +
40 > + [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
41 > + MODULE_A="${MODULE_P}.${MODULE_A_EXT:-tar.gz}"
42 > + [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
43 > + SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
44 > + [[ -z "${HOMEPAGE}" ]] && \
45 > + HOMEPAGE="http://search.cpan.org/dist/${MODULE_NAME}/"
46 > else
47 > - MODULE_NAME=${MODULE_NAME:-${PN}}
48 > - MODULE_P=${MODULE_NAME}-${MODULE_VERSION:-${PV}}
49 > - S=${WORKDIR}/${MODULE_P}
50 > + DIST_NAME=${DIST_NAME:-${PN}}
51 > + DIST_P=${DIST_NAME}-${DIST_VERSION:-${PV}}
52 > + S=${WORKDIR}/${DIST_P}
53 > +
54 > + [[ -z "${SRC_URI}" && -z "${DIST_A}" ]] && \
55 > + DIST_A="${DIST_P}.${DIST_A_EXT:-tar.gz}"
56 > + [[ -z "${SRC_URI}" && -n "${DIST_AUTHOR}" ]] && \
57 > + SRC_URI="mirror://cpan/authors/id/${DIST_AUTHOR:0:1}/${DIST_AUTHOR:0:2}/${DIST_AUTHOR}/${DIST_SECTION:+${DIST_SECTION}/}${DIST_A}"
58 > + [[ -z "${HOMEPAGE}" ]] && \
59 > + HOMEPAGE="http://search.cpan.org/dist/${DIST_NAME}/"
60 > fi
61 >
62 > -[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
63 > - MODULE_A="${MODULE_P}.${MODULE_A_EXT:-tar.gz}"
64 > -[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
65 > - SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
66 > -[[ -z "${HOMEPAGE}" ]] && \
67 > - HOMEPAGE="http://search.cpan.org/dist/${MODULE_NAME}/"
68 > -
69
70 Particularly for 100% straight var-renames with no change in functionality,
71 I'd expect something more like (pseudocode):
72
73 if $EAPI = 5 then
74 # eapi-6+ only, clear them
75 unset newvarname newvarname2
76
77 # assign eapi-6 vars from eapi-5 vars so we
78 # can reference only the new eapi-6 ones below
79 newvarname=oldvarname
80 newvarname2=oldvarname2
81 ...
82 fi
83
84 # make sure we don't use old eapi-5 varnames
85 unset oldvarname1 oldvarname2
86
87 # the rest of the patch simply changes old varnames to new ones,
88 # thus avoiding duplicate code
89
90
91 That makes it very clear in both the patch and the post-patch code
92 what's going on, while preventing all three of:
93 1) use of the old varnames in EAPI-6 (due to the unset)
94 2) use of the new varnames in EAPI-5 (due to the unset and reassignment)
95 3) uncaught and unchanged reference to the old vars (due to the unset)
96
97 Again, when eapi-5 code cleanup time comes, it's just deletion of the
98 eapi-5 lines. No else clause to unwind. And in the mean time, the code
99 isn't duplicated to eapi-5 and eapi-6 locations with only differing vars.
100 =:^)
101
102 Seems cleaner to me, but as I said above, purely a matter of author style,
103 so if you don't like it, feel free to ignore.
104
105 --
106 Duncan - List replies preferred. No HTML msgs.
107 "Every nonfree program has a lord, a master --
108 and if you use the program, he is your master." Richard Stallman

Replies