Re: [gentoo-dev] [PATCH] eutils.eclass: split unique functions into eutils-r1

2018-04-08 Thread Ulrich Mueller
> On Sun, 8 Apr 2018, Marty E Plummer wrote:

> Split all functions unique to eutils into eutils-r1, and inherit it
> from eutils. Issue a QA warning on EAPI=6 ebuilds using eutils directly
> and suggest migrating to direct use of the needed eclass, with a list of
> functions unique to eutils-r1.

> With this we can start moving ebuilds which inherit eutils because they
> need a function unique to the old eutils to eutils-r1, while being able
> to single out ebuilds which used eutils to inherit other ebuilds lazily
> or just cargo cult coding of always inheriting eutils.

I fear that at this point, shortly before approval of EAPI 7, this
doesn't make much sense. More than half of the tree is at EAPI 6, so
that QA warning would be shown for many ebuilds.

Also in EAPI 7 some functions won't be in eutils any more. For example,
eqawarn will be provided by the package manager. So that -r1 eclass
would start out with ugly EAPI conditionals.

So, IMHO the cleaner procedure is to wait with this for EAPI 7, where
we may be able to do the migration without a revision bump of the
eclass.

Ulrich


pgp2BhsSGmHXr.pgp
Description: PGP signature


[gentoo-dev] [PATCH] eutils.eclass: split unique functions into eutils-r1

2018-04-08 Thread Marty E. Plummer
Split all functions unique to eutils into eutils-r1, and inherit it
from eutils. Issue a QA warning on EAPI=6 ebuilds using eutils directly
and suggest migrating to direct use of the needed eclass, with a list of
functions unique to eutils-r1.

With this we can start moving ebuilds which inherit eutils because they
need a function unique to the old eutils to eutils-r1, while being able
to single out ebuilds which used eutils to inherit other ebuilds lazily
or just cargo cult coding of always inheriting eutils.

Package-Manager: Portage-2.3.28, Repoman-2.3.9
---
 eclass/eutils-r1.eclass | 265 
 eclass/eutils.eclass| 253 ++
 2 files changed, 278 insertions(+), 240 deletions(-)
 create mode 100644 eclass/eutils-r1.eclass

diff --git a/eclass/eutils-r1.eclass b/eclass/eutils-r1.eclass
new file mode 100644
index 000..93fd0be7928
--- /dev/null
+++ b/eclass/eutils-r1.eclass
@@ -0,0 +1,265 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: eutils-r1.eclass
+# @MAINTAINER:
+# base-sys...@gentoo.org
+# @BLURB: many extra (but common) functions that are used in ebuilds
+# @DESCRIPTION:
+# The eutils eclass contains a suite of functions that complement
+# the ones that ebuild.sh already contain.  The idea is that the functions
+# are not required in all ebuilds but enough utilize them to have a common
+# home rather than having multiple ebuilds implementing the same thing.
+#
+# Due to the nature of this eclass, some functions may have maintainers
+# different from the overall eclass!
+
+if [[ -z ${_EUTILS_R1_ECLASS} ]]; then
+_EUTILS_R1_ECLASS=1
+
+case ${EAPI:-0} in
+   6) ;;
+   *) [[ ${_EUTILS_ECLASS} == 1 ]] || die "${ECLASS}.eclass is banned n 
EAPI=${EAPI}" ;;
+esac
+
+# @FUNCTION: eqawarn
+# @USAGE: [message]
+# @DESCRIPTION:
+# Proxy to ewarn for package managers that don't provide eqawarn and use the PM
+# implementation if available. Reuses PORTAGE_ELOG_CLASSES as set by the dev
+# profile.
+if ! declare -F eqawarn >/dev/null ; then
+   eqawarn() {
+   has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@"
+   :
+   }
+fi
+
+# @FUNCTION: emktemp
+# @USAGE: [temp dir]
+# @DESCRIPTION:
+# Cheap replacement for when debianutils (and thus mktemp)
+# does not exist on the users system.
+emktemp() {
+   local exe="touch"
+   [[ $1 == -d ]] && exe="mkdir" && shift
+   local topdir=$1
+
+   if [[ -z ${topdir} ]] ; then
+   [[ -z ${T} ]] \
+   && topdir="/tmp" \
+   || topdir=${T}
+   fi
+
+   if ! type -P mktemp > /dev/null ; then
+   # system lacks `mktemp` so we have to fake it
+   local tmp=/
+   while [[ -e ${tmp} ]] ; do
+   tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}
+   done
+   ${exe} "${tmp}" || ${exe} -p "${tmp}"
+   echo "${tmp}"
+   else
+   # the args here will give slightly wierd names on BSD,
+   # but should produce a usable file on all userlands
+   if [[ ${exe} == "touch" ]] ; then
+   TMPDIR="${topdir}" mktemp -t tmp.XX
+   else
+   TMPDIR="${topdir}" mktemp -dt tmp.XX
+   fi
+   fi
+}
+
+# @FUNCTION: edos2unix
+# @USAGE:  [more files ...]
+# @DESCRIPTION:
+# A handy replacement for dos2unix, recode, fixdos, etc...  This allows you
+# to remove all of these text utilities from DEPEND variables because this
+# is a script based solution.  Just give it a list of files to convert and
+# they will all be changed from the DOS CRLF format to the UNIX LF format.
+edos2unix() {
+   [[ $# -eq 0 ]] && return 0
+   sed -i 's/\r$//' -- "$@" || die
+}
+
+# @FUNCTION: strip-linguas
+# @USAGE: [|<-i|-u> ]
+# @DESCRIPTION:
+# Make sure that LINGUAS only contains languages that
+# a package can support.  The first form allows you to
+# specify a list of LINGUAS.  The -i builds a list of po
+# files found in all the directories and uses the
+# intersection of the lists.  The -u builds a list of po
+# files found in all the directories and uses the union
+# of the lists.
+strip-linguas() {
+   local ls newls nols
+   if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
+   local op=$1; shift
+   ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
+   local d f
+   for d in "$@" ; do
+   if [[ ${op} == "-u" ]] ; then
+   newls=${ls}
+   else
+   newls=""
+   fi
+   for f in $(find "$d" -name '*.po' -exec basename {} .po 
';') ; do
+   if [[ ${op} == "-i" ]] ; then
+   has $