/[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.32 Revision 1.33
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2012 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.32 2011/11/24 00:04:13 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.33 2012/04/09 18:08:45 slyfox Exp $
4 4
5# @ECLASS: ghc-package.eclass 5# @ECLASS: ghc-package.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# "Gentoo's Haskell Language team" <haskell@gentoo.org> 7# "Gentoo's Haskell Language team" <haskell@gentoo.org>
8# @AUTHOR: 8# @AUTHOR:
34# bypass the script under certain circumstances); 34# bypass the script under certain circumstances);
35# for Cabal, we add an empty global package config file, 35# for Cabal, we add an empty global package config file,
36# because for some reason the global package file 36# because for some reason the global package file
37# must be specified 37# must be specified
38ghc-getghcpkgbin() { 38ghc-getghcpkgbin() {
39 if version_is_at_least "6.10" "$(ghc-version)"; then
40 # the ghc-pkg executable changed name in ghc 6.10, as it no longer needs 39 # the ghc-pkg executable changed name in ghc 6.10, as it no longer needs
41 # the wrapper script with the static flags 40 # the wrapper script with the static flags
42 echo '[]' > "${T}/empty.conf" 41 echo '[]' > "${T}/empty.conf"
43 echo "$(ghc-libdir)/ghc-pkg" "--global-conf=${T}/empty.conf" 42 echo "$(ghc-libdir)/ghc-pkg" "--global-conf=${T}/empty.conf"
44 elif ghc-cabal; then
45 echo '[]' > "${T}/empty.conf"
46 echo "$(ghc-libdir)/ghc-pkg.bin" "--global-conf=${T}/empty.conf"
47 else
48 echo "$(ghc-libdir)/ghc-pkg.bin"
49 fi
50} 43}
51 44
52# @FUNCTION: ghc-version 45# @FUNCTION: ghc-version
53# @DESCRIPTION: 46# @DESCRIPTION:
54# returns the version of ghc 47# returns the version of ghc
58 _GHC_VERSION_CACHE="$($(ghc-getghc) --numeric-version)" 51 _GHC_VERSION_CACHE="$($(ghc-getghc) --numeric-version)"
59 fi 52 fi
60 echo "${_GHC_VERSION_CACHE}" 53 echo "${_GHC_VERSION_CACHE}"
61} 54}
62 55
63# @FUNCTION: ghc-cabal
64# @DESCRIPTION:
65# this function can be used to determine if ghc itself
66# uses the Cabal package format; it has nothing to do
67# with the Cabal libraries ... ghc uses the Cabal package
68# format since version 6.4
69ghc-cabal() {
70 version_is_at_least "6.4" "$(ghc-version)"
71}
72
73# @FUNCTION: ghc-bestcabalversion 56# @FUNCTION: ghc-bestcabalversion
74# @DESCRIPTION: 57# @DESCRIPTION:
75# return the best version of the Cabal library that is available 58# return the best version of the Cabal library that is available
76ghc-bestcabalversion() { 59ghc-bestcabalversion() {
77 local cabalversion
78 if ghc-cabal; then
79 # We ask portage, not ghc, so that we only pick up 60 # We ask portage, not ghc, so that we only pick up
80 # portage-installed cabal versions. 61 # portage-installed cabal versions.
81 cabalversion="$(ghc-extractportageversion dev-haskell/cabal)" 62 local cabalversion="$(ghc-extractportageversion dev-haskell/cabal)"
82 echo "Cabal-${cabalversion}" 63 echo "Cabal-${cabalversion}"
83 else
84 # older ghc's don't support package versioning
85 echo Cabal
86 fi
87} 64}
88 65
89# @FUNCTION: ghc-sanecabal 66# @FUNCTION: ghc-sanecabal
90# @DESCRIPTION: 67# @DESCRIPTION:
91# check if a standalone Cabal version is available for the 68# check if a standalone Cabal version is available for the
99 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return 76 [[ -f "${f}" ]] && version_is_at_least "${version}" "${f#*cabal-}" && return
100 done 77 done
101 return 1 78 return 1
102} 79}
103 80
104# @FUNCTION: ghc-saneghc
105# @DESCRIPTION:
106# checks if ghc and ghc-bin are installed in the same version
107# (if they're both installed); if this is not the case, we
108# unfortunately cannot trust portage's dependency resolution
109ghc-saneghc() {
110 local ghcversion
111 local ghcbinversion
112 if [[ "${PN}" == "ghc" || "${PN}" == "ghc-bin" ]]; then
113 return
114 fi
115 if has_version dev-lang/ghc && has_version dev-lang/ghc-bin; then
116 ghcversion="$(ghc-extractportageversion dev-lang/ghc)"
117 ghcbinversion="$(ghc-extractportageversion dev-lang/ghc-bin)"
118 if [[ "${ghcversion}" != "${ghcbinversion}" ]]; then
119 return 1
120 fi
121 fi
122 return
123}
124
125# @FUNCTION: ghc-supports-shared-libraries 81# @FUNCTION: ghc-supports-shared-libraries
126# @DESCRIPTION: 82# @DESCRIPTION:
127# checks if ghc is built with support for building 83# checks if ghc is built with support for building
128# shared libraries (aka '-dynamic' option) 84# shared libraries (aka '-dynamic' option)
129ghc-supports-shared-libraries() { 85ghc-supports-shared-libraries() {
180 136
181# @FUNCTION: ghc-package-exists 137# @FUNCTION: ghc-package-exists
182# @DESCRIPTION: 138# @DESCRIPTION:
183# tests if a ghc package exists 139# tests if a ghc package exists
184ghc-package-exists() { 140ghc-package-exists() {
185 local describe_flag
186 if version_is_at_least "6.4" "$(ghc-version)"; then
187 describe_flag="describe"
188 else
189 describe_flag="--show-package"
190 fi
191
192 $(ghc-getghcpkg) "${describe_flag}" "$1" > /dev/null 2>&1 141 $(ghc-getghcpkg) describe "$1" > /dev/null 2>&1
193} 142}
194 143
195# @FUNCTION: ghc-setup-pkg 144# @FUNCTION: ghc-setup-pkg
196# @DESCRIPTION: 145# @DESCRIPTION:
197# creates a local (package-specific) package 146# creates a local (package-specific) package
199# uninstalled package description files, each 148# uninstalled package description files, each
200# containing a single package description; if 149# containing a single package description; if
201# no arguments are given, the resulting file is 150# no arguments are given, the resulting file is
202# empty 151# empty
203ghc-setup-pkg() { 152ghc-setup-pkg() {
204 local localpkgconf
205 localpkgconf="${S}/$(ghc-localpkgconf)" 153 local localpkgconf="${S}/$(ghc-localpkgconf)"
206 echo '[]' > "${localpkgconf}" 154 echo '[]' > "${localpkgconf}"
207 local update_flag 155
208 if version_is_at_least "6.4" "$(ghc-version)"; then
209 update_flag="update -"
210 else
211 update_flag="--update-package"
212 fi
213 for pkg in $*; do 156 for pkg in $*; do
214 $(ghc-getghcpkgbin) -f "${localpkgconf}" ${update_flag} --force \ 157 $(ghc-getghcpkgbin) -f "${localpkgconf}" update - --force \
215 < "${pkg}" || die "failed to register ${pkg}" 158 < "${pkg}" || die "failed to register ${pkg}"
216 done 159 done
217} 160}
218 161
219# @FUNCTION: ghc-fixlibpath 162# @FUNCTION: ghc-fixlibpath
240# @FUNCTION: ghc-register-pkg 183# @FUNCTION: ghc-register-pkg
241# @DESCRIPTION: 184# @DESCRIPTION:
242# registers all packages in the local (package-specific) 185# registers all packages in the local (package-specific)
243# package configuration file 186# package configuration file
244ghc-register-pkg() { 187ghc-register-pkg() {
245 local localpkgconf
246 localpkgconf="$(ghc-confdir)/$1" 188 local localpkgconf="$(ghc-confdir)/$1"
247 local update_flag 189
248 local describe_flag
249 if version_is_at_least "6.4" "$(ghc-version)"; then
250 update_flag="update -"
251 describe_flag="describe"
252 else
253 update_flag="--update-package"
254 describe_flag="--show-package"
255 fi
256 if [[ -f "${localpkgconf}" ]]; then 190 if [[ -f "${localpkgconf}" ]]; then
257 for pkg in $(ghc-listpkg "${localpkgconf}"); do 191 for pkg in $(ghc-listpkg "${localpkgconf}"); do
258 ebegin "Registering ${pkg} " 192 ebegin "Registering ${pkg} "
259 $(ghc-getghcpkgbin) -f "${localpkgconf}" "${describe_flag}" "${pkg}" \ 193 $(ghc-getghcpkgbin) -f "${localpkgconf}" describe "${pkg}" \
260 | $(ghc-getghcpkg) ${update_flag} --force > /dev/null 194 | $(ghc-getghcpkg) update - --force > /dev/null
261 eend $? 195 eend $?
262 done 196 done
263 fi 197 fi
264} 198}
265 199
284# @DESCRIPTION: 218# @DESCRIPTION:
285# unregisters a package configuration file 219# unregisters a package configuration file
286# protected are all packages that are still contained in 220# protected are all packages that are still contained in
287# another package configuration file 221# another package configuration file
288ghc-unregister-pkg() { 222ghc-unregister-pkg() {
289 local localpkgconf 223 local localpkgconf="$(ghc-confdir)/$1"
290 local i 224 local i
291 local pkg 225 local pkg
292 local unregister_flag
293 localpkgconf="$(ghc-confdir)/$1"
294
295 if version_is_at_least "6.4" "$(ghc-version)"; then
296 unregister_flag="unregister"
297 else
298 unregister_flag="--remove-package"
299 fi
300 226
301 if [[ -f "${localpkgconf}" ]]; then 227 if [[ -f "${localpkgconf}" ]]; then
302 for pkg in $(ghc-reverse "$(ghc-listpkg ${localpkgconf})"); do 228 for pkg in $(ghc-reverse "$(ghc-listpkg ${localpkgconf})"); do
303 if ! ghc-package-exists "${pkg}"; then 229 if ! ghc-package-exists "${pkg}"; then
304 einfo "Package ${pkg} is not installed for ghc-$(ghc-version)." 230 einfo "Package ${pkg} is not installed for ghc-$(ghc-version)."
305 else 231 else
306 ebegin "Unregistering ${pkg} " 232 ebegin "Unregistering ${pkg} "
307 $(ghc-getghcpkg) "${unregister_flag}" "${pkg}" --force > /dev/null 233 $(ghc-getghcpkg) unregister "${pkg}" --force > /dev/null
308 eend $? 234 eend $?
309 fi 235 fi
310 done 236 done
311 fi 237 fi
312} 238}
343 local extra_flags 269 local extra_flags
344 if version_is_at_least '6.12.3' "$(ghc-version)"; then 270 if version_is_at_least '6.12.3' "$(ghc-version)"; then
345 extra_flags="${extra_flags} -v0" 271 extra_flags="${extra_flags} -v0"
346 fi 272 fi
347 for i in $*; do 273 for i in $*; do
348 if ghc-cabal; then
349 echo $($(ghc-getghcpkg) list ${extra_flags} -f "${i}") \ 274 echo $($(ghc-getghcpkg) list ${extra_flags} -f "${i}") \
350 | sed \ 275 | sed \
351 -e "s|^.*${i}:\([^:]*\).*$|\1|" \ 276 -e "s|^.*${i}:\([^:]*\).*$|\1|" \
352 -e "s|/.*$||" \ 277 -e "s|/.*$||" \
353 -e "s|,| |g" -e "s|[(){}]||g" 278 -e "s|,| |g" -e "s|[(){}]||g"
354 else
355 echo $($(ghc-getghcpkgbin) -l -f "${i}") \
356 | cut -f2 -d':' \
357 | sed 's:,: :g'
358 fi
359 done 279 done
360}
361
362# @FUNCTION: ghc-package_pkg_setup
363# @DESCRIPTION:
364# exported function: check if we have a consistent ghc installation
365ghc-package_pkg_setup() {
366 if ! ghc-saneghc; then
367 eerror "You have inconsistent versions of dev-lang/ghc and dev-lang/ghc-bin"
368 eerror "installed. Portage currently cannot work correctly with this setup."
369 eerror "There are several possibilities to work around this problem:"
370 eerror "(1) Up/downgrade ghc-bin to the same version as ghc."
371 eerror "(2) Unmerge ghc-bin."
372 eerror "(3) Unmerge ghc."
373 eerror "You probably want option 1 or 2."
374 die "Inconsistent versions of ghc and ghc-bin."
375 fi
376} 280}
377 281
378# @FUNCTION: ghc-package_pkg_postinst 282# @FUNCTION: ghc-package_pkg_postinst
379# @DESCRIPTION: 283# @DESCRIPTION:
380# exported function: registers the package-specific package 284# exported function: registers the package-specific package
391# package configuration file ... 295# package configuration file ...
392ghc-package_pkg_prerm() { 296ghc-package_pkg_prerm() {
393 ghc-unregister-pkg "$(ghc-localpkgconf)" 297 ghc-unregister-pkg "$(ghc-localpkgconf)"
394} 298}
395 299
396EXPORT_FUNCTIONS pkg_setup pkg_postinst pkg_prerm 300EXPORT_FUNCTIONS pkg_postinst pkg_prerm

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20