/[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.20 Revision 1.23
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.20 2006/10/04 17:45:35 kosmikus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.23 2007/07/25 18:07:02 dcoutts 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# Maintained by: Haskell herd <haskell@gentoo.org>
7# 7#
8# This eclass helps with the Glasgow Haskell Compiler's package 8# This eclass helps with the Glasgow Haskell Compiler's package
14PATH="/usr/bin:/opt/ghc/bin:${PATH}" 14PATH="/usr/bin:/opt/ghc/bin:${PATH}"
15 15
16# for later configuration using environment variables/ 16# for later configuration using environment variables/
17# returns the name of the ghc executable 17# returns the name of the ghc executable
18ghc-getghc() { 18ghc-getghc() {
19 echo "$(which ghc)" 19 type -P ghc
20} 20}
21 21
22# returns the name of the ghc-pkg executable 22# returns the name of the ghc-pkg executable
23ghc-getghcpkg() { 23ghc-getghcpkg() {
24 echo "$(which ghc-pkg)" 24 type -P ghc-pkg
25} 25}
26 26
27# returns the name of the ghc-pkg binary (ghc-pkg 27# returns the name of the ghc-pkg binary (ghc-pkg
28# itself usually is a shell script, and we have to 28# itself usually is a shell script, and we have to
29# bypass the script under certain circumstances); 29# bypass the script under certain circumstances);
56 version_is_at_least "6.4" "$(ghc-version)" 56 version_is_at_least "6.4" "$(ghc-version)"
57} 57}
58 58
59# return the best version of the Cabal library that is available 59# return the best version of the Cabal library that is available
60ghc-bestcabalversion() { 60ghc-bestcabalversion() {
61 local cabalpackage
62 local cabalversion 61 local cabalversion
63 if ghc-cabal; then 62 if ghc-cabal; then
64 # We ask portage, not ghc, so that we only pick up 63 # We ask portage, not ghc, so that we only pick up
65 # portage-installed cabal versions. 64 # portage-installed cabal versions.
66 cabalpackage="$(best_version dev-haskell/cabal)" 65 cabalversion="$(ghc-extractportageversion dev-haskell/cabal)"
67 cabalversion="${cabalpackage#dev-haskell/cabal-}"
68 cabalversion="${cabalversion%-r*}"
69 cabalversion="${cabalversion%_pre*}"
70 echo "Cabal-${cabalversion}" 66 echo "Cabal-${cabalversion}"
71 else 67 else
72 # older ghc's don't support package versioning 68 # older ghc's don't support package versioning
73 echo Cabal 69 echo Cabal
74 fi 70 fi
83 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
84 for f in $(ghc-confdir)/cabal-*; do 80 for f in $(ghc-confdir)/cabal-*; do
85 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return 81 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return
86 done 82 done
87 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}"
88} 114}
89 115
90# returns the library directory 116# returns the library directory
91_GHC_LIBDIR_CACHE="" 117_GHC_LIBDIR_CACHE=""
92ghc-libdir() { 118ghc-libdir() {
248 | sed 's:,: :g' 274 | sed 's:,: :g'
249 fi 275 fi
250 done 276 done
251} 277}
252 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
291}
292
253# exported function: registers the package-specific package 293# exported function: registers the package-specific package
254# configuration file 294# configuration file
255ghc-package_pkg_postinst() { 295ghc-package_pkg_postinst() {
256 ghc-register-pkg "$(ghc-localpkgconf)" 296 ghc-register-pkg "$(ghc-localpkgconf)"
257} 297}
262# package configuration file ... 302# package configuration file ...
263ghc-package_pkg_prerm() { 303ghc-package_pkg_prerm() {
264 ghc-unregister-pkg "$(ghc-localpkgconf)" 304 ghc-unregister-pkg "$(ghc-localpkgconf)"
265} 305}
266 306
267EXPORT_FUNCTIONS pkg_postinst pkg_prerm 307EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_prerm

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.23

  ViewVC Help
Powered by ViewVC 1.1.20