/[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.26 Revision 1.27
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.26 2008/01/06 19:30:24 swegener Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.27 2009/03/23 20:06:19 kolmodin 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
29# bypass the script under certain circumstances); 29# bypass the script under certain circumstances);
30# for Cabal, we add an empty global package config file, 30# for Cabal, we add an empty global package config file,
31# because for some reason the global package file 31# because for some reason the global package file
32# must be specified 32# must be specified
33ghc-getghcpkgbin() { 33ghc-getghcpkgbin() {
34 if version_is_at_least "6.10" "$(ghc-version)"; then
35 # the ghc-pkg executable changed name in ghc 6.10, as it no longer needs
36 # the wrapper script with the static flags
37 echo '[]' > "${T}/empty.conf"
38 echo "$(ghc-libdir)/ghc-pkg" "--global-conf=${T}/empty.conf"
34 if ghc-cabal; then 39 elif ghc-cabal; then
35 echo '[]' > "${T}/empty.conf" 40 echo '[]' > "${T}/empty.conf"
36 echo "$(ghc-libdir)/ghc-pkg.bin" "--global-conf=${T}/empty.conf" 41 echo "$(ghc-libdir)/ghc-pkg.bin" "--global-conf=${T}/empty.conf"
37 else 42 else
38 echo "$(ghc-libdir)/ghc-pkg.bin" 43 echo "$(ghc-libdir)/ghc-pkg.bin"
39 fi 44 fi
140 ld --relocatable --discard-all --output="${outfile}" --whole-archive "$1" 145 ld --relocatable --discard-all --output="${outfile}" --whole-archive "$1"
141} 146}
142 147
143# tests if a ghc package exists 148# tests if a ghc package exists
144ghc-package-exists() { 149ghc-package-exists() {
150 local describe_flag
151 if version_is_at_least "6.4" "$(ghc-version)"; then
152 describe_flag="describe"
153 else
154 describe_flag="--show-package"
155 fi
156
145 $(ghc-getghcpkg) -s "$1" > /dev/null 2>&1 157 $(ghc-getghcpkg) "${describe_flag}" "$1" > /dev/null 2>&1
146} 158}
147 159
148# creates a local (package-specific) package 160# creates a local (package-specific) package
149# configuration file; the arguments should be 161# configuration file; the arguments should be
150# uninstalled package description files, each 162# uninstalled package description files, each
153# empty 165# empty
154ghc-setup-pkg() { 166ghc-setup-pkg() {
155 local localpkgconf 167 local localpkgconf
156 localpkgconf="${S}/$(ghc-localpkgconf)" 168 localpkgconf="${S}/$(ghc-localpkgconf)"
157 echo '[]' > "${localpkgconf}" 169 echo '[]' > "${localpkgconf}"
170 local update_flag
171 if version_is_at_least "6.4" "$(ghc-version)"; then
172 update_flag="update -"
173 else
174 update_flag="--update-package"
175 fi
158 for pkg in $*; do 176 for pkg in $*; do
159 $(ghc-getghcpkgbin) -f "${localpkgconf}" -u --force \ 177 $(ghc-getghcpkgbin) -f "${localpkgconf}" ${update_flag} --force \
160 < "${pkg}" || die "failed to register ${pkg}" 178 < "${pkg}" || die "failed to register ${pkg}"
161 done 179 done
162} 180}
163 181
164# fixes the library and import directories path 182# fixes the library and import directories path
181# registers all packages in the local (package-specific) 199# registers all packages in the local (package-specific)
182# package configuration file 200# package configuration file
183ghc-register-pkg() { 201ghc-register-pkg() {
184 local localpkgconf 202 local localpkgconf
185 localpkgconf="$(ghc-confdir)/$1" 203 localpkgconf="$(ghc-confdir)/$1"
204 local update_flag
205 local describe_flag
206 if version_is_at_least "6.4" "$(ghc-version)"; then
207 update_flag="update -"
208 describe_flag="describe"
209 else
210 update_flag="--update-package"
211 describe_flag="--show-package"
212 fi
186 if [[ -f "${localpkgconf}" ]]; then 213 if [[ -f "${localpkgconf}" ]]; then
187 for pkg in $(ghc-listpkg "${localpkgconf}"); do 214 for pkg in $(ghc-listpkg "${localpkgconf}"); do
188 ebegin "Registering ${pkg} " 215 ebegin "Registering ${pkg} "
189 $(ghc-getghcpkgbin) -f "${localpkgconf}" -s "${pkg}" \ 216 $(ghc-getghcpkgbin) -f "${localpkgconf}" "${describe_flag}" "${pkg}" \
190 | $(ghc-getghcpkg) -u --force > /dev/null 217 | $(ghc-getghcpkg) ${update_flag} --force > /dev/null
191 eend $? 218 eend $?
192 done 219 done
193 fi 220 fi
194} 221}
195 222
196# re-adds all available .conf files to the global 223# re-adds all available .conf files to the global
197# package conf file, to be used on a ghc reinstallation 224# package conf file, to be used on a ghc reinstallation
198ghc-reregister() { 225ghc-reregister() {
199 einfo "Re-adding packages (may cause several harmless warnings) ..." 226 einfo "Re-adding packages (may cause several harmless warnings) ..."
200 if [ -d "$(ghc-confdir)" ]; then 227 PATH="/usr/bin:${PATH}" CONFDIR="$(ghc-confdir)"
201 pushd "$(ghc-confdir)" > /dev/null 228 if [ -d "${CONFDIR}" ]; then
229 pushd "${CONFDIR}" > /dev/null
202 for conf in *.conf; do 230 for conf in *.conf; do
203# einfo "Processing ${conf} ..." 231 PATH="/usr/bin:${PATH}" ghc-register-pkg "${conf}"
204 ghc-register-pkg "${conf}"
205 done 232 done
206 popd > /dev/null 233 popd > /dev/null
207 fi 234 fi
208} 235}
209 236
213ghc-unregister-pkg() { 240ghc-unregister-pkg() {
214 local localpkgconf 241 local localpkgconf
215 local i 242 local i
216 local pkg 243 local pkg
217 local protected 244 local protected
245 local unregister_flag
218 localpkgconf="$(ghc-confdir)/$1" 246 localpkgconf="$(ghc-confdir)/$1"
247
248 if version_is_at_least "6.4" "$(ghc-version)"; then
249 unregister_flag="unregister"
250 else
251 unregister_flag="--remove-package"
252 fi
219 253
220 for i in $(ghc-confdir)/*.conf; do 254 for i in $(ghc-confdir)/*.conf; do
221 [[ "${i}" != "${localpkgconf}" ]] && protected="${protected} $(ghc-listpkg ${i})" 255 [[ "${i}" != "${localpkgconf}" ]] && protected="${protected} $(ghc-listpkg ${i})"
222 done 256 done
223 # protected now contains the packages that cannot be unregistered yet 257 # protected now contains the packages that cannot be unregistered yet
229 elif ! ghc-package-exists "${pkg}"; then 263 elif ! ghc-package-exists "${pkg}"; then
230 : 264 :
231 # einfo "Package ${pkg} is not installed for ghc-$(ghc-version)." 265 # einfo "Package ${pkg} is not installed for ghc-$(ghc-version)."
232 else 266 else
233 ebegin "Unregistering ${pkg} " 267 ebegin "Unregistering ${pkg} "
234 $(ghc-getghcpkg) -r "${pkg}" --force > /dev/null 268 $(ghc-getghcpkg) "${unregister_flag}" "${pkg}" --force > /dev/null
235 eend $? 269 eend $?
236 fi 270 fi
237 done 271 done
238 fi 272 fi
239} 273}

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

  ViewVC Help
Powered by ViewVC 1.1.20