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