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

Contents of /eclass/ghc-package.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Nov 3 20:38:35 2004 UTC (9 years, 8 months ago) by kosmikus
Branch: MAIN
Changes since 1.1: +2 -2 lines
* removed --auto-ghci-libs flag because it produces orphaned files in
  the portage tree

1 kosmikus 1.1 # Copyright 1999-2004 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 kosmikus 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.1 2004/11/03 15:06:41 kosmikus Exp $
4 kosmikus 1.1 #
5     # Author: Andres Loeh <kosmikus@gentoo.org>
6     #
7     # This eclass helps with the Glasgow Haskell Compiler's package
8     # configuration utility.
9    
10     ECLASS="ghc-package"
11     INHERITED="$INHERITED $ECLASS"
12    
13     PATH="${PATH}:/opt/ghc/bin"
14    
15     # for later configuration using environment variables/
16     # returns the name of the ghc executable
17     ghc-getghc() {
18     echo "ghc"
19     }
20    
21     # returns the name of the ghc-pkg executable
22     ghc-getghcpkg() {
23     echo "ghc-pkg"
24     }
25    
26     # returns the name of the ghc-pkg binary (ghc-pkg
27     # itself usually is a shell script, and we have to
28     # bypass the script under certain circumstances)
29     ghc-getghcpkgbin() {
30     echo $(ghc-libdir)/"ghc-pkg.bin"
31     }
32    
33     # returns the version of ghc
34     ghc-version() {
35     $(ghc-getghc) --version | sed 's:^.*version ::'
36     }
37    
38     # returns the library directory
39     ghc-libdir() {
40     $(ghc-getghc) --print-libdir
41     }
42    
43     # returns the (Gentoo) library configuration directory
44     ghc-confdir() {
45     echo $(ghc-libdir)/gentoo
46     }
47    
48     # returns the name of the local (package-specific)
49     # package configuration file
50     ghc-localpkgconf() {
51     echo "${PF}.conf"
52     }
53    
54     # creates an empty local (package-specific) package
55     # configuration file
56     ghc-setup-pkg() {
57     echo '[]' > ${S}/$(ghc-localpkgconf)
58     }
59    
60     # moves the local (package-specific) package configuration
61     # file to its final destination
62     ghc-install-pkg() {
63     mkdir -p ${D}/$(ghc-confdir)
64     cat ${S}/$(ghc-localpkgconf) | sed "s:${D}::" \
65     > ${D}/$(ghc-confdir)/$(ghc-localpkgconf)
66     }
67    
68     # registers all packages in the local (package-specific)
69     # package configuration file
70     ghc-register-pkg() {
71     local localpkgconf
72     localpkgconf=$(ghc-confdir)/$1
73     for pkg in $(ghc-listpkg ${localpkgconf}); do
74     einfo "Registering ${pkg} ..."
75     $(ghc-getghcpkgbin) -f ${localpkgconf} -s ${pkg} \
76 kosmikus 1.2 | $(ghc-getghcpkg) -u --force
77 kosmikus 1.1 done
78     }
79    
80     # re-adds all available .conf files to the global
81     # package conf file, to be used on a ghc reinstallation
82     ghc-reregister() {
83     einfo "Re-adding packages ..."
84     ewarn "This may cause several warnings, but they should be harmless."
85     pushd $(ghc-confdir)
86     for conf in *.conf; do
87     einfo "Processing ${conf} ..."
88     ghc-register-pkg ${conf}
89     done
90     popd
91     }
92    
93     # unregisters ...
94     ghc-unregister-pkg() {
95     local localpkgconf
96     localpkgconf=$(ghc-confdir)/$1
97     for pkg in $(ghc-reverse "$(ghc-listpkg ${localpkgconf})"); do
98     einfo "Unregistering ${pkg} ..."
99     $(ghc-getghcpkg) -r ${pkg} --force
100     done
101     }
102    
103     # help-function: reverse a list
104     ghc-reverse() {
105     local result
106     for i in $1; do
107     result="${i} ${result}"
108     done
109     echo ${result}
110     }
111    
112     # show the packages in a package configuration file
113     ghc-listpkg() {
114     [ -f $1 ] && echo $($(ghc-getghcpkgbin) -l -f $1) \
115     | cut -f2 -d':' \
116     | sed 's:,: :g'
117     }
118    
119     # exported function: registers the package-specific package
120     # configuration file
121     ghc-package_pkg_postinst() {
122     ghc-register-pkg $(ghc-localpkgconf)
123     }
124    
125     # exported function: unregisters the package-specific
126     # package configuration file, under the condition that
127     # after removal, no other instances of the package will
128     # be left (necessary check because ghc packages are not
129     # versioned)
130     ghc-package_pkg_prerm() {
131     has_version "<${CATEGORY}/${PF}" || has_version ">${CATEGORY}/${PF}" \
132     || ghc-unregister-pkg $(ghc-localpkgconf)
133     }
134    
135     EXPORT_FUNCTIONS pkg_postinst pkg_prerm

  ViewVC Help
Powered by ViewVC 1.1.20