From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5960F138334 for ; Fri, 20 Dec 2019 13:43:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE035E09DB; Fri, 20 Dec 2019 13:43:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 74358E09C2 for ; Fri, 20 Dec 2019 13:43:50 +0000 (UTC) Received: from a1i15 (a1i15.kph.uni-mainz.de [134.93.134.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ulm) by smtp.gentoo.org (Postfix) with ESMTPSA id 3D56A34D7FD for ; Fri, 20 Dec 2019 13:43:49 +0000 (UTC) From: Ulrich =?utf-8?Q?M=C3=BCller?= To: Subject: [gentoo-dev] [PATCH v2 1/3] elisp-common.eclass: New function elisp-check-emacs-version. References: Date: Fri, 20 Dec 2019 14:43:45 +0100 In-Reply-To: ("Ulrich \=\?utf-8\?Q\?M\?\= \=\?utf-8\?Q\?\=C3\=BCller\=22's\?\= message of "Wed, 18 Dec 2019 12:08:16 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: d8d22125-4e0b-4fbb-83d5-f4bb929692b8 X-Archives-Hash: 13e6f154fb44aec5e628551711bdac46 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Tests if the Emacs version is at least the (full) version specified by NEED_EMACS, otherwise dies. Intended as a replacement for function elisp-need-emacs, which did only a simple numeric comparison of the major version. Call the new function before doing any actual work in elisp-compile() and elisp-make-autoload-file(), so ebuilds inheriting only elisp-common.eclass (but not elisp.eclass) won't have to add a pkg_setup phase function. Drop support for EAPIs 0 to 3. Signed-off-by: Ulrich M=C3=BCller =2D-- v2: Don't change elisp-need-emacs() in place, but add a new function for the new functionality, and and deprecate the old function. eclass/elisp-common.eclass | 52 +++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass index 05b03f49395..8e5d70046bc 100644 =2D-- a/eclass/elisp-common.eclass +++ b/eclass/elisp-common.eclass @@ -1,4 +1,4 @@ =2D# Copyright 1999-2015 Gentoo Foundation +# Copyright 1999-2019 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 =20 # @ECLASS: elisp-common.eclass @@ -156,6 +156,12 @@ # environment, so it is no problem when you unset USE=3Demacs between # merge and unmerge of a package. =20 +case ${EAPI:-0} in + 4|5|6) inherit eapi7-ver ;; + 7) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + # @ECLASS-VARIABLE: SITELISP # @DESCRIPTION: # Directory where packages install Emacs Lisp files. @@ -182,6 +188,17 @@ EMACSFLAGS=3D"-batch -q --no-site-file" # Emacs flags used for byte-compilation in elisp-compile(). BYTECOMPFLAGS=3D"-L ." =20 +# @ECLASS-VARIABLE: NEED_EMACS +# @DESCRIPTION: +# The minimum Emacs version required for the package. +: ${NEED_EMACS:=3D23.1} + +# @ECLASS-VARIABLE: _ELISP_EMACS_VERSION +# @INTERNAL +# @DESCRIPTION: +# Cached value of Emacs version detected in elisp-check-emacs-version(). +_ELISP_EMACS_VERSION=3D"" + # @FUNCTION: elisp-emacs-version # @RETURN: exit status of Emacs # @DESCRIPTION: @@ -212,6 +229,35 @@ elisp-emacs-version() { echo "${version}" } =20 +# @FUNCTION: elisp-check-emacs-version +# @USAGE: [version] +# @DESCRIPTION: +# Test if the eselected Emacs version is at least the version of +# GNU Emacs specified in the NEED_EMACS variable, or die otherwise. + +elisp-check-emacs-version() { + if [[ -z ${_ELISP_EMACS_VERSION} ]]; then + local have_emacs + have_emacs=3D$(elisp-emacs-version) \ + || die "Could not determine Emacs version" + elog "Emacs version: ${have_emacs}" + if [[ ${have_emacs} =3D~ XEmacs|Lucid ]]; then + die "XEmacs detected. This package needs GNU Emacs." + fi + # GNU Emacs versions have only numeric components. + if ! [[ ${have_emacs} =3D~ ^[0-9]+(\.[0-9]+)*$ ]]; then + die "Malformed version string: ${have_emacs}" + fi + _ELISP_EMACS_VERSION=3D${have_emacs} + fi + + if ! ver_test "${_ELISP_EMACS_VERSION}" -ge "${NEED_EMACS}"; then + eerror "This package needs at least Emacs ${NEED_EMACS}." + eerror "Use \"eselect emacs\" to select the active version." + die "Emacs version too low" + fi +} + # @FUNCTION: elisp-need-emacs # @USAGE: # @RETURN: 0 if true, 1 if false, 2 if trouble @@ -249,6 +295,8 @@ elisp-need-emacs() { # in case they require or load one another. =20 elisp-compile() { + elisp-check-emacs-version + ebegin "Compiling GNU Emacs Elisp files" ${EMACS} ${EMACSFLAGS} ${BYTECOMPFLAGS} -f batch-byte-compile "$@" eend $? "elisp-compile: batch-byte-compile failed" || die @@ -262,6 +310,8 @@ elisp-compile() { elisp-make-autoload-file() { local f=3D"${1:-${PN}-autoloads.el}" null=3D"" page=3D$'\f' shift + elisp-check-emacs-version + ebegin "Generating autoload file for GNU Emacs" =20 cat >"${f}" <<-EOF =2D-=20 2.24.1 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEZlHkP3TnuTbxrN0HwwkGhRxhwnMFAl380BEACgkQwwkGhRxh wnOmXgf+MRSxtfdO9Y6YPTZRzLOfK218m+vAXKp7ck8rM0PaXRkW1oQQ3zyLM0MJ 5wzj76ypPKXCVCPaGe1mgmuVyVULH8luB31dFwI+u2ZzF5kS4GNGLAGpeLqvrBAU MdLvFZuMNtIsLdvyttgAj0TiWgnvYhse7BE6i2hyL7QCFz3BN8BV/Bn/7UCMBg7k PfIZEk2pgRggqgM2Q5XBg3gOb3P4D8zESthtlaHSmrgpc/Id59hQyI2ALpWFXeSk GR8q2cviLeU7i3VzzEqa2EeCUWvGoSFDnSdWddjsdiZ1/quu+UTlXXbNG1YXbRwP DAZI3Q5HksHrVFGDY9l++s62Vh4KzA== =G+as -----END PGP SIGNATURE----- --=-=-=--