dilfridge posted on Fri, 11 Dec 2015 22:03:05 +0100 as excerpted:

> -# @ECLASS-VARIABLE: MODULE_VERSION
> +# @ECLASS-VARIABLE: DIST_VERSION
>  # @DESCRIPTION:
> -# This variable provides a way to override PV for the calculation of S and 
> SRC_URI.
> +# (EAPI=6) This variable provides a way to override PV for the calculation 
> of S and SRC_URI.
>  # Use it to provide the non-normalized, upstream version number. Defaults to 
> PV.
> +# Named MODULE_VERSION in EAPI=5.

Dev-author's discretion, here and below, as it's purely style, but...

What I would have expected to see here (and in other docs-related patches) 
would be cleanly
separate EAPI-5 vs. EAPI-6 descriptions, on separate lines, so when EAPI-5 
support cleanup
time comes, it's easy to simply delete EAPI-5 lines.  Something like:

+# ECLASS-VARIABLE: DIST_VERSION
+# (EAPI=6)
+# This variable provides a way to override PV for the calculation of S and 
SRC_URI.
+
 # @ECLASS-VARIABLE: MODULE_VERSION
 # @DESCRIPTION:
-# This variable provides a way to override PV for the calculation of S and 
SRC_URI.
+# (EAPI-5 version of DIST_VERSION)

With this, EAPI-5 cleanup should be purely lines deleted (including the EAPI-6 
on its own line).
Additionally, people (like me) trying to debug failing existing EAPI-5 ebuilds 
won't be having
to look for EAPI-5 var-names at unexpected locations in the documentation. =:^)

Of course for the other vars that change names but not functionality between 
the two
EAPIs, both in this patch and in others, as well.

(Don't miss the further comment below.)

> @@ -146,19 +147,26 @@ if [[ ${EAPI:-0} = 5 ]] ; then
>       fi
>       MODULE_NAME=${MY_PN:-${PN}}
>       MODULE_P=${MY_P:-${P}}
> +
> +     [[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
> +             MODULE_A="${MODULE_P}.${MODULE_A_EXT:-tar.gz}"
> +     [[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
> +             
> SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
> +     [[ -z "${HOMEPAGE}" ]] && \
> +             HOMEPAGE="http://search.cpan.org/dist/${MODULE_NAME}/";
>  else
> -     MODULE_NAME=${MODULE_NAME:-${PN}}
> -     MODULE_P=${MODULE_NAME}-${MODULE_VERSION:-${PV}}
> -     S=${WORKDIR}/${MODULE_P}
> +     DIST_NAME=${DIST_NAME:-${PN}}
> +     DIST_P=${DIST_NAME}-${DIST_VERSION:-${PV}}
> +     S=${WORKDIR}/${DIST_P}
> +
> +     [[ -z "${SRC_URI}" && -z "${DIST_A}" ]] && \
> +             DIST_A="${DIST_P}.${DIST_A_EXT:-tar.gz}"
> +     [[ -z "${SRC_URI}" && -n "${DIST_AUTHOR}" ]] && \
> +             
> SRC_URI="mirror://cpan/authors/id/${DIST_AUTHOR:0:1}/${DIST_AUTHOR:0:2}/${DIST_AUTHOR}/${DIST_SECTION:+${DIST_SECTION}/}${DIST_A}"
> +     [[ -z "${HOMEPAGE}" ]] && \
> +             HOMEPAGE="http://search.cpan.org/dist/${DIST_NAME}/";
>  fi
>  
> -[[ -z "${SRC_URI}" && -z "${MODULE_A}" ]] && \
> -     MODULE_A="${MODULE_P}.${MODULE_A_EXT:-tar.gz}"
> -[[ -z "${SRC_URI}" && -n "${MODULE_AUTHOR}" ]] && \
> -     
> SRC_URI="mirror://cpan/authors/id/${MODULE_AUTHOR:0:1}/${MODULE_AUTHOR:0:2}/${MODULE_AUTHOR}/${MODULE_SECTION:+${MODULE_SECTION}/}${MODULE_A}"
> -[[ -z "${HOMEPAGE}" ]] && \
> -     HOMEPAGE="http://search.cpan.org/dist/${MODULE_NAME}/";
> -

Particularly for 100% straight var-renames with no change in functionality,
I'd expect something more like (pseudocode):

if $EAPI = 5 then
        # eapi-6+ only, clear them
        unset newvarname newvarname2

        # assign eapi-6 vars from eapi-5 vars so we
        # can reference only the new eapi-6 ones below
        newvarname=oldvarname
        newvarname2=oldvarname2
        ...
fi

# make sure we don't use old eapi-5 varnames
unset oldvarname1 oldvarname2

# the rest of the patch simply changes old varnames to new ones,
# thus avoiding duplicate code


That makes it very clear in both the patch and the post-patch code
what's going on, while preventing all three of:
1) use of the old varnames in EAPI-6 (due to the unset)
2) use of the new varnames in EAPI-5 (due to the unset and reassignment)
3) uncaught and unchanged reference to the old vars (due to the unset)

Again, when eapi-5 code cleanup time comes, it's just deletion of the
eapi-5 lines.  No else clause to unwind.  And in the mean time, the code
isn't duplicated to eapi-5 and eapi-6 locations with only differing vars.
=:^)

Seems cleaner to me, but as I said above, purely a matter of author style,
so if you don't like it, feel free to ignore.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


Reply via email to