Gentoo Archives: gentoo-dev

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] [PATCH v2 1/3] elisp-common.eclass: New function elisp-check-emacs-version.
Date: Fri, 20 Dec 2019 13:43:53
Message-Id: w6go8w3nmcu.fsf@kph.uni-mainz.de
In Reply to: [gentoo-dev] [PATCH 0/3] elisp{,-common}.eclass update for emacs-vcs consolidation by "Ulrich Müller"
1 Tests if the Emacs version is at least the (full) version specified
2 by NEED_EMACS, otherwise dies. Intended as a replacement for function
3 elisp-need-emacs, which did only a simple numeric comparison of the
4 major version.
5
6 Call the new function before doing any actual work in elisp-compile()
7 and elisp-make-autoload-file(), so ebuilds inheriting only
8 elisp-common.eclass (but not elisp.eclass) won't have to add a
9 pkg_setup phase function.
10
11 Drop support for EAPIs 0 to 3.
12
13 Signed-off-by: Ulrich Müller <ulm@g.o>
14 ---
15 v2: Don't change elisp-need-emacs() in place, but add a new function
16 for the new functionality, and and deprecate the old function.
17
18 eclass/elisp-common.eclass | 52 +++++++++++++++++++++++++++++++++++++-
19 1 file changed, 51 insertions(+), 1 deletion(-)
20
21 diff --git a/eclass/elisp-common.eclass b/eclass/elisp-common.eclass
22 index 05b03f49395..8e5d70046bc 100644
23 --- a/eclass/elisp-common.eclass
24 +++ b/eclass/elisp-common.eclass
25 @@ -1,4 +1,4 @@
26 -# Copyright 1999-2015 Gentoo Foundation
27 +# Copyright 1999-2019 Gentoo Authors
28 # Distributed under the terms of the GNU General Public License v2
29
30 # @ECLASS: elisp-common.eclass
31 @@ -156,6 +156,12 @@
32 # environment, so it is no problem when you unset USE=emacs between
33 # merge and unmerge of a package.
34
35 +case ${EAPI:-0} in
36 + 4|5|6) inherit eapi7-ver ;;
37 + 7) ;;
38 + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
39 +esac
40 +
41 # @ECLASS-VARIABLE: SITELISP
42 # @DESCRIPTION:
43 # Directory where packages install Emacs Lisp files.
44 @@ -182,6 +188,17 @@ EMACSFLAGS="-batch -q --no-site-file"
45 # Emacs flags used for byte-compilation in elisp-compile().
46 BYTECOMPFLAGS="-L ."
47
48 +# @ECLASS-VARIABLE: NEED_EMACS
49 +# @DESCRIPTION:
50 +# The minimum Emacs version required for the package.
51 +: ${NEED_EMACS:=23.1}
52 +
53 +# @ECLASS-VARIABLE: _ELISP_EMACS_VERSION
54 +# @INTERNAL
55 +# @DESCRIPTION:
56 +# Cached value of Emacs version detected in elisp-check-emacs-version().
57 +_ELISP_EMACS_VERSION=""
58 +
59 # @FUNCTION: elisp-emacs-version
60 # @RETURN: exit status of Emacs
61 # @DESCRIPTION:
62 @@ -212,6 +229,35 @@ elisp-emacs-version() {
63 echo "${version}"
64 }
65
66 +# @FUNCTION: elisp-check-emacs-version
67 +# @USAGE: [version]
68 +# @DESCRIPTION:
69 +# Test if the eselected Emacs version is at least the version of
70 +# GNU Emacs specified in the NEED_EMACS variable, or die otherwise.
71 +
72 +elisp-check-emacs-version() {
73 + if [[ -z ${_ELISP_EMACS_VERSION} ]]; then
74 + local have_emacs
75 + have_emacs=$(elisp-emacs-version) \
76 + || die "Could not determine Emacs version"
77 + elog "Emacs version: ${have_emacs}"
78 + if [[ ${have_emacs} =~ XEmacs|Lucid ]]; then
79 + die "XEmacs detected. This package needs GNU Emacs."
80 + fi
81 + # GNU Emacs versions have only numeric components.
82 + if ! [[ ${have_emacs} =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
83 + die "Malformed version string: ${have_emacs}"
84 + fi
85 + _ELISP_EMACS_VERSION=${have_emacs}
86 + fi
87 +
88 + if ! ver_test "${_ELISP_EMACS_VERSION}" -ge "${NEED_EMACS}"; then
89 + eerror "This package needs at least Emacs ${NEED_EMACS}."
90 + eerror "Use \"eselect emacs\" to select the active version."
91 + die "Emacs version too low"
92 + fi
93 +}
94 +
95 # @FUNCTION: elisp-need-emacs
96 # @USAGE: <version>
97 # @RETURN: 0 if true, 1 if false, 2 if trouble
98 @@ -249,6 +295,8 @@ elisp-need-emacs() {
99 # in case they require or load one another.
100
101 elisp-compile() {
102 + elisp-check-emacs-version
103 +
104 ebegin "Compiling GNU Emacs Elisp files"
105 ${EMACS} ${EMACSFLAGS} ${BYTECOMPFLAGS} -f batch-byte-compile "$@"
106 eend $? "elisp-compile: batch-byte-compile failed" || die
107 @@ -262,6 +310,8 @@ elisp-compile() {
108 elisp-make-autoload-file() {
109 local f="${1:-${PN}-autoloads.el}" null="" page=$'\f'
110 shift
111 + elisp-check-emacs-version
112 +
113 ebegin "Generating autoload file for GNU Emacs"
114
115 cat >"${f}" <<-EOF
116 --
117 2.24.1

Attachments

File name MIME type
signature.asc application/pgp-signature