/[gentoo-x86]/eclass/ghc-package.eclass
Gentoo

Diff of /eclass/ghc-package.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.16 Revision 1.26
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.16 2006/03/01 12:58:01 dcoutts Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.26 2008/01/06 19:30:24 swegener Exp $
4# 4#
5# Author: Andres Loeh <kosmikus@gentoo.org> 5# Author: Andres Loeh <kosmikus@gentoo.org>
6# Maintained by: Haskell herd <haskell@gentoo.org>
6# 7#
7# This eclass helps with the Glasgow Haskell Compiler's package 8# This eclass helps with the Glasgow Haskell Compiler's package
8# configuration utility. 9# configuration utility.
9 10
10inherit versionator 11inherit versionator
13PATH="/usr/bin:/opt/ghc/bin:${PATH}" 14PATH="/usr/bin:/opt/ghc/bin:${PATH}"
14 15
15# for later configuration using environment variables/ 16# for later configuration using environment variables/
16# returns the name of the ghc executable 17# returns the name of the ghc executable
17ghc-getghc() { 18ghc-getghc() {
18 echo "ghc" 19 type -P ghc
19} 20}
20 21
21# returns the name of the ghc-pkg executable 22# returns the name of the ghc-pkg executable
22ghc-getghcpkg() { 23ghc-getghcpkg() {
23 echo "ghc-pkg" 24 type -P ghc-pkg
24} 25}
25 26
26# returns the name of the ghc-pkg binary (ghc-pkg 27# returns the name of the ghc-pkg binary (ghc-pkg
27# itself usually is a shell script, and we have to 28# itself usually is a shell script, and we have to
28# bypass the script under certain circumstances); 29# bypass the script under certain circumstances);
55 version_is_at_least "6.4" "$(ghc-version)" 56 version_is_at_least "6.4" "$(ghc-version)"
56} 57}
57 58
58# return the best version of the Cabal library that is available 59# return the best version of the Cabal library that is available
59ghc-bestcabalversion() { 60ghc-bestcabalversion() {
60 local cabalpackage
61 local cabalversion 61 local cabalversion
62 if ghc-cabal; then 62 if ghc-cabal; then
63 # Try if ghc-pkg can determine the latest version. 63 # We ask portage, not ghc, so that we only pick up
64 # If not, use portage. 64 # portage-installed cabal versions.
65 cabalpackage="$($(ghc-getghcpkg) latest Cabal 2> /dev/null)" 65 cabalversion="$(ghc-extractportageversion dev-haskell/cabal)"
66 if [[ $? -eq 0 ]]; then
67 cabalversion="${cabalpackage#Cabal-}"
68 else
69 cabalpackage="$(best_version cabal)"
70 cabalversion="${cabalpackage#dev-haskell/cabal-}"
71 cabalversion="${cabalversion%-r*}"
72 cabalversion="${cabalversion%_pre*}"
73 fi
74 echo "Cabal-${cabalversion}" 66 echo "Cabal-${cabalversion}"
75 else 67 else
76 # older ghc's don't support package versioning 68 # older ghc's don't support package versioning
77 echo Cabal 69 echo Cabal
78 fi 70 fi
87 if [[ -z "$1" ]]; then version="1.0.1"; else version="$1"; fi 79 if [[ -z "$1" ]]; then version="1.0.1"; else version="$1"; fi
88 for f in $(ghc-confdir)/cabal-*; do 80 for f in $(ghc-confdir)/cabal-*; do
89 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return 81 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return
90 done 82 done
91 return 1 83 return 1
84}
85
86# checks if ghc and ghc-bin are installed in the same version
87# (if they're both installed); if this is not the case, we
88# unfortunately cannot trust portage's dependency resolution
89ghc-saneghc() {
90 local ghcversion
91 local ghcbinversion
92 if [[ "${PN}" == "ghc" || "${PN}" == "ghc-bin" ]]; then
93 return
94 fi
95 if has_version dev-lang/ghc && has_version dev-lang/ghc-bin; then
96 ghcversion="$(ghc-extractportageversion dev-lang/ghc)"
97 ghcbinversion="$(ghc-extractportageversion dev-lang/ghc-bin)"
98 if [[ "${ghcversion}" != "${ghcbinversion}" ]]; then
99 return 1
100 fi
101 fi
102 return
103}
104
105# extract the version of a portage-installed package
106ghc-extractportageversion() {
107 local pkg
108 local version
109 pkg="$(best_version $1)"
110 version="${pkg#$1-}"
111 version="${version%-r*}"
112 version="${version%_pre*}"
113 echo "${version}"
92} 114}
93 115
94# returns the library directory 116# returns the library directory
95_GHC_LIBDIR_CACHE="" 117_GHC_LIBDIR_CACHE=""
96ghc-libdir() { 118ghc-libdir() {
243 if ghc-cabal; then 265 if ghc-cabal; then
244 echo $($(ghc-getghcpkg) list -f "${i}") \ 266 echo $($(ghc-getghcpkg) list -f "${i}") \
245 | sed \ 267 | sed \
246 -e "s|^.*${i}:\([^:]*\).*$|\1|" \ 268 -e "s|^.*${i}:\([^:]*\).*$|\1|" \
247 -e "s|/.*$||" \ 269 -e "s|/.*$||" \
248 -e "s|,| |g" -e "s|[()]||g" 270 -e "s|,| |g" -e "s|[(){}]||g"
249 else 271 else
250 echo $($(ghc-getghcpkgbin) -l -f "${i}") \ 272 echo $($(ghc-getghcpkgbin) -l -f "${i}") \
251 | cut -f2 -d':' \ 273 | cut -f2 -d':' \
252 | sed 's:,: :g' 274 | sed 's:,: :g'
253 fi 275 fi
254 done 276 done
277}
278
279# exported function: check if we have a consistent ghc installation
280ghc-package_pkg_setup() {
281 if ! ghc-saneghc; then
282 eerror "You have inconsistent versions of dev-lang/ghc and dev-lang/ghc-bin"
283 eerror "installed. Portage currently cannot work correctly with this setup."
284 eerror "There are several possibilities to work around this problem:"
285 eerror "(1) Up/downgrade ghc-bin to the same version as ghc."
286 eerror "(2) Unmerge ghc-bin."
287 eerror "(3) Unmerge ghc."
288 eerror "You probably want option 1 or 2."
289 die "Inconsistent versions of ghc and ghc-bin."
290 fi
255} 291}
256 292
257# exported function: registers the package-specific package 293# exported function: registers the package-specific package
258# configuration file 294# configuration file
259ghc-package_pkg_postinst() { 295ghc-package_pkg_postinst() {
266# package configuration file ... 302# package configuration file ...
267ghc-package_pkg_prerm() { 303ghc-package_pkg_prerm() {
268 ghc-unregister-pkg "$(ghc-localpkgconf)" 304 ghc-unregister-pkg "$(ghc-localpkgconf)"
269} 305}
270 306
271EXPORT_FUNCTIONS pkg_postinst pkg_prerm 307EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_prerm

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.26

  ViewVC Help
Powered by ViewVC 1.1.20