Gentoo Archives: gentoo-dev

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-dev@l.g.o
Cc: Sergei Trofimovich <slyfox@g.o>
Subject: [gentoo-dev] [PATCH 2/5] ghc-package.eclass: drop EAPI={0..5} support
Date: Mon, 05 Jul 2021 22:26:50
Message-Id: 20210705222555.3847172-3-slyfox@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/6] haskell eclass update to EAPI=8, old EAPI={0..5} removal by Sergei Trofimovich
1 Signed-off-by: Sergei Trofimovich <slyfox@g.o>
2 ---
3 eclass/ghc-package.eclass | 6 +++---
4 1 file changed, 3 insertions(+), 3 deletions(-)
5
6 diff --git a/eclass/ghc-package.eclass b/eclass/ghc-package.eclass
7 index 5decbaa228e..71e84af3444 100644
8 --- a/eclass/ghc-package.eclass
9 +++ b/eclass/ghc-package.eclass
10 @@ -1,346 +1,346 @@
11 # Copyright 1999-2021 Gentoo Authors
12 # Distributed under the terms of the GNU General Public License v2
13
14 # @ECLASS: ghc-package.eclass
15 # @MAINTAINER:
16 # "Gentoo's Haskell Language team" <haskell@g.o>
17 -# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
18 +# @SUPPORTED_EAPIS: 6 7
19 # @AUTHOR:
20 # Original Author: Andres Loeh <kosmikus@g.o>
21 # @BLURB: This eclass helps with the Glasgow Haskell Compiler's package configuration utility.
22 # @DESCRIPTION:
23 # Helper eclass to handle ghc installation/upgrade/deinstallation process.
24
25 inherit multiprocessing
26
27 # Maintain version-testing compatibility with ebuilds not using EAPI 7.
28 case "${EAPI:-0}" in
29 - 0|1|2|3|7) ;;
30 - 4|5|6) inherit eapi7-ver ;;
31 + 7) ;;
32 + 6) inherit eapi7-ver ;;
33 *) die "EAPI ${EAPI} unsupported." ;;
34 esac
35
36 # GHC uses it's own native code generator. Portage's
37 # QA check generates false positive because it assumes
38 # presence of GCC-specific sections.
39 #
40 # Workaround false positiove by disabling the check completely.
41 # bug #722078, bug #677600
42 QA_FLAGS_IGNORED='.*'
43
44 # @FUNCTION: ghc-getghc
45 # @DESCRIPTION:
46 # returns the name of the ghc executable
47 ghc-getghc() {
48 if ! type -P ${HC:-ghc}; then
49 ewarn "ghc not found"
50 type -P false
51 fi
52 }
53
54 # @FUNCTION: ghc-getghcpkg
55 # @INTERNAL
56 # @DESCRIPTION:
57 # Internal function determines returns the name of the ghc-pkg executable
58 ghc-getghcpkg() {
59 if ! type -P ${HC_PKG:-ghc-pkg}; then
60 ewarn "ghc-pkg not found"
61 type -P false
62 fi
63 }
64
65 # @FUNCTION: ghc-getghcpkgbin
66 # @DESCRIPTION:
67 # returns the name of the ghc-pkg binary (ghc-pkg
68 # itself usually is a shell script, and we have to
69 # bypass the script under certain circumstances);
70 # for Cabal, we add an empty global package config file,
71 # because for some reason the global package file
72 # must be specified
73 ghc-getghcpkgbin() {
74 local empty_db="${T}/empty.conf.d" ghc_pkg="$(ghc-libdir)/bin/ghc-pkg"
75 if [[ ! -d ${empty_db} ]]; then
76 "${ghc_pkg}" init "${empty_db}" || die "Failed to initialize empty global db"
77 fi
78 echo "$(ghc-libdir)/bin/ghc-pkg" "--global-package-db=${empty_db}"
79 }
80
81 # @FUNCTION: ghc-version
82 # @DESCRIPTION:
83 # returns upstream version of ghc
84 # as reported by '--numeric-version'
85 # Examples: "7.10.2", "7.9.20141222"
86 _GHC_VERSION_CACHE=""
87 ghc-version() {
88 if [[ -z "${_GHC_VERSION_CACHE}" ]]; then
89 _GHC_VERSION_CACHE="$($(ghc-getghc) --numeric-version)"
90 fi
91 echo "${_GHC_VERSION_CACHE}"
92 }
93
94 # @FUNCTION: ghc-pm-version
95 # @DESCRIPTION:
96 # returns package manager(PM) version of ghc
97 # as reported by '$(best_version)'
98 # Examples: "PM:7.10.2", "PM:7.10.2_rc1", "PM:7.8.4-r4"
99 _GHC_PM_VERSION_CACHE=""
100 ghc-pm-version() {
101 local pm_ghc_p
102
103 if [[ -z "${_GHC_PM_VERSION_CACHE}" ]]; then
104 pm_ghc_p=$(best_version dev-lang/ghc)
105 _GHC_PM_VERSION_CACHE="PM:${pm_ghc_p#dev-lang/ghc-}"
106 fi
107 echo "${_GHC_PM_VERSION_CACHE}"
108 }
109
110 # @FUNCTION: ghc-cabal-version
111 # @DESCRIPTION:
112 # return version of the Cabal library bundled with ghc
113 ghc-cabal-version() {
114 # outputs in format: 'version: 1.18.1.5'
115 set -- `$(ghc-getghcpkg) --package-db=$(ghc-libdir)/package.conf.d.initial field Cabal version`
116 echo "$2"
117 }
118
119 # @FUNCTION: ghc-is-dynamic
120 # @DESCRIPTION:
121 # checks if ghc is built against dynamic libraries
122 # binaries linked against GHC library (and using plugin loading)
123 # have to be linked the same way:
124 # https://ghc.haskell.org/trac/ghc/ticket/10301
125 ghc-is-dynamic() {
126 $(ghc-getghc) --info | grep "GHC Dynamic" | grep -q "YES"
127 }
128
129 # @FUNCTION: ghc-supports-shared-libraries
130 # @DESCRIPTION:
131 # checks if ghc is built with support for building
132 # shared libraries (aka '-dynamic' option)
133 ghc-supports-shared-libraries() {
134 $(ghc-getghc) --info | grep "RTS ways" | grep -q "dyn"
135 }
136
137 # @FUNCTION: ghc-supports-threaded-runtime
138 # @DESCRIPTION:
139 # checks if ghc is built with support for threaded
140 # runtime (aka '-threaded' option)
141 ghc-supports-threaded-runtime() {
142 $(ghc-getghc) --info | grep "RTS ways" | grep -q "thr"
143 }
144
145 # @FUNCTION: ghc-supports-smp
146 # @DESCRIPTION:
147 # checks if ghc is built with support for multiple cores runtime
148 ghc-supports-smp() {
149 $(ghc-getghc) --info | grep "Support SMP" | grep -q "YES"
150 }
151
152 # @FUNCTION: ghc-supports-interpreter
153 # @DESCRIPTION:
154 # checks if ghc has interpreter mode (aka GHCi)
155 # It usually means that ghc supports for template haskell.
156 ghc-supports-interpreter() {
157 $(ghc-getghc) --info | grep "Have interpreter" | grep -q "YES"
158 }
159
160 # @FUNCTION: ghc-supports-parallel-make
161 # @DESCRIPTION:
162 # checks if ghc has support for '--make -j' mode
163 # The option was introduced in ghc-7.8-rc1.
164 ghc-supports-parallel-make() {
165 $(ghc-getghc) --info | grep "Support parallel --make" | grep -q "YES"
166 }
167
168 # @FUNCTION: ghc-extractportageversion
169 # @DESCRIPTION:
170 # extract the version of a portage-installed package
171 ghc-extractportageversion() {
172 local pkg
173 local version
174 pkg="$(best_version $1)"
175 version="${pkg#$1-}"
176 version="${version%-r*}"
177 version="${version%_pre*}"
178 echo "${version}"
179 }
180
181 # @FUNCTION: ghc-libdir
182 # @DESCRIPTION:
183 # returns the library directory
184 _GHC_LIBDIR_CACHE=""
185 ghc-libdir() {
186 if [[ -z "${_GHC_LIBDIR_CACHE}" ]]; then
187 _GHC_LIBDIR_CACHE="$($(ghc-getghc) --print-libdir)"
188 fi
189 echo "${_GHC_LIBDIR_CACHE}"
190 }
191
192 # @FUNCTION: ghc-make-args
193 # @DESCRIPTION:
194 # Returns default arguments passed along 'ghc --make'
195 # build mode. Used mainly to enable parallel build mode.
196 ghc-make-args() {
197 local ghc_make_args=()
198 # parallel on all available cores
199 if ghc-supports-smp && ghc-supports-parallel-make; then
200 # It should have been just -j$(makeopts_jobs)
201 # but GHC does not yet have nice defaults:
202 # https://ghc.haskell.org/trac/ghc/ticket/9221#comment:57
203 # SMP is a requirement for parallel GC's gen0
204 # 'qb' balancing.
205 echo "-j$(makeopts_jobs) +RTS -A256M -qb0 -RTS"
206 ghc_make_args=()
207 fi
208 echo "${ghc_make_args[@]}"
209 }
210
211 # @FUNCTION: ghc-confdir
212 # @DESCRIPTION:
213 # returns the (Gentoo) library configuration directory, we
214 # store here a hint for 'haskell-updater' about packages
215 # installed for old ghc versions and current ones.
216 ghc-confdir() {
217 echo "$(ghc-libdir)/gentoo"
218 }
219
220 # @FUNCTION: ghc-package-db
221 # @DESCRIPTION:
222 # returns the global package database directory
223 ghc-package-db() {
224 echo "$(ghc-libdir)/package.conf.d"
225 }
226
227 # @FUNCTION: ghc-localpkgconfd
228 # @DESCRIPTION:
229 # returns the name of the local (package-specific)
230 # package configuration file
231 ghc-localpkgconfd() {
232 echo "${PF}.conf.d"
233 }
234
235 # @FUNCTION: ghc-package-exists
236 # @DESCRIPTION:
237 # tests if a ghc package exists
238 ghc-package-exists() {
239 $(ghc-getghcpkg) describe "$1" > /dev/null 2>&1
240 }
241
242 # @FUNCTION: check-for-collisions
243 # @DESCRIPTION:
244 # makes sure no packages
245 # have the same version as initial package setup
246 check-for-collisions() {
247 local localpkgconf=$1
248 local checked_pkg
249 local initial_pkg_db="$(ghc-libdir)/package.conf.d.initial"
250
251 for checked_pkg in `$(ghc-getghcpkgbin) -f "${localpkgconf}" list --simple-output`
252 do
253 # should return empty output
254 local collided=`$(ghc-getghcpkgbin) -f ${initial_pkg_db} list --simple-output "${checked_pkg}"`
255
256 if [[ -n ${collided} ]]; then
257 eerror "Cabal package '${checked_pkg}' is shipped with '$(ghc-pm-version)' ('$(ghc-version)')."
258 eerror "Ebuild author forgot an entry in CABAL_CORE_LIB_GHC_PV='${CABAL_CORE_LIB_GHC_PV}'."
259 eerror "Found in ${initial_pkg_db}."
260 die
261 fi
262 done
263 }
264
265 # @FUNCTION: ghc-install-pkg
266 # @DESCRIPTION:
267 # moves the local (package-specific) package configuration
268 # file to its final destination
269 ghc-install-pkg() {
270 local localpkgconf="${T}/$(ghc-localpkgconfd)"
271 local pkg_path pkg pkg_db="${D}/$(ghc-package-db)" hint_db="${D}/$(ghc-confdir)"
272
273 $(ghc-getghcpkgbin) init "${localpkgconf}" || die "Failed to initialize empty local db"
274 for pkg_config_file in "$@"; do
275 $(ghc-getghcpkgbin) -f "${localpkgconf}" update - --force \
276 < "${pkg_config_file}" || die "failed to register ${pkg}"
277 done
278
279 check-for-collisions "${localpkgconf}"
280
281 mkdir -p "${pkg_db}" || die
282 for pkg_path in "${localpkgconf}"/*.conf; do
283 pkg=$(basename "${pkg_path}")
284 cp "${pkg_path}" "${pkg_db}/${pkg}" || die
285 done
286
287 mkdir -p "${hint_db}" || die
288 for pkg_config_file in "$@"; do
289 local pkg_name="gentoo-${CATEGORY}-${PF}-"$(basename "${pkg_config_file}")
290 cp "${pkg_config_file}" "${hint_db}/${pkg_name}" || die
291 chmod 0644 "${hint_db}/${pkg_name}" || die
292 done
293 }
294
295 # @FUNCTION: ghc-recache-db
296 # @DESCRIPTION:
297 # updates 'package.cache' binary cacne for registered '*.conf'
298 # packages
299 ghc-recache-db() {
300 einfo "Recaching GHC package DB"
301 $(ghc-getghcpkg) recache
302 }
303
304 # @FUNCTION: ghc-register-pkg
305 # @DESCRIPTION:
306 # registers all packages in the local (package-specific)
307 # package configuration file
308 ghc-register-pkg() {
309 ghc-recache-db
310 }
311
312 # @FUNCTION: ghc-reregister
313 # @DESCRIPTION:
314 # re-adds all available .conf files to the global
315 # package conf file, to be used on a ghc reinstallation
316 ghc-reregister() {
317 ghc-recache-db
318 }
319
320 # @FUNCTION: ghc-unregister-pkg
321 # @DESCRIPTION:
322 # unregisters a package configuration file
323 ghc-unregister-pkg() {
324 ghc-recache-db
325 }
326
327 # @FUNCTION: ghc-pkgdeps
328 # @DESCRIPTION:
329 # exported function: loads a package dependency in a form
330 # cabal_package version
331 ghc-pkgdeps() {
332 echo $($(ghc-getghcpkg) describe "${1}") \
333 | sed \
334 -e '/depends/,/^.*:/ !d' \
335 -e 's/\(.*\)-\(.*\)-\(.*\)/\1 \2/' \
336 -e 's/^.*://g'
337 }
338
339 # @FUNCTION: ghc-package_pkg_postinst
340 # @DESCRIPTION:
341 # updates package.cache after package install
342 ghc-package_pkg_postinst() {
343 ghc-recache-db
344 }
345
346 # @FUNCTION: ghc-package_pkg_prerm
347 # @DESCRIPTION:
348 # updates package.cache after package deinstall
349 ghc-package_pkg_prerm() {
350 ewarn "ghc-package.eclass: 'ghc-package_pkg_prerm()' is a noop"
351 ewarn "ghc-package.eclass: consider 'haskell-cabal_pkg_postrm()' instead"
352 }
353
354 # @FUNCTION: ghc-package_pkg_postrm
355 # @DESCRIPTION:
356 # updates package.cache after package deinstall
357 ghc-package_pkg_postrm() {
358 ghc-recache-db
359 }
360 --
361 2.32.0