1 |
commit: 456fe14669aabfe1a94367fd4c331d2644e18001 |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Jun 9 19:04:07 2018 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jun 9 19:09:16 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=456fe146 |
7 |
|
8 |
dev-lang/ghc: bump up to 8.4.3, no binaries yet |
9 |
|
10 |
Package-Manager: Portage-2.3.40, Repoman-2.3.9 |
11 |
|
12 |
dev-lang/ghc/Manifest | 1 + |
13 |
.../ghc/files/ghc-8.0.2-no-relax-everywhere.patch | 17 + |
14 |
.../files/ghc-8.4.2-allow-cross-bootstrap.patch | 23 + |
15 |
dev-lang/ghc/ghc-8.4.3.ebuild | 760 +++++++++++++++++++++ |
16 |
4 files changed, 801 insertions(+) |
17 |
|
18 |
diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest |
19 |
index 0e30d62f1a7..54d2adc8a19 100644 |
20 |
--- a/dev-lang/ghc/Manifest |
21 |
+++ b/dev-lang/ghc/Manifest |
22 |
@@ -7,6 +7,7 @@ DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e013 |
23 |
DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799 |
24 |
DIST ghc-8.4.1-src.tar.xz 11301528 BLAKE2B 6dcf467d04cace856b68315c85b80f19b517dcbc8ae6e2a08c60afa141c9e0261e012738452c9ca208f9fc40c48bd1a0817e5e0fe9f4737383cd7b44ca65c8d9 SHA512 f8ae11f498bf2911fb92635534c6906c96f1fbe5072c7b7447bd3f69e408026b674564515af02a8aaddc57ee6905ce78d10005b12478a39c220580aaec13a9f7 |
25 |
DIST ghc-8.4.2-src.tar.xz 11313140 BLAKE2B d6fe90f3c68b137c6029bf08918a51ff43c210ba0485aca8d77541cd455f6f9c94287cd011ecd710a8e5a14a27e8a27c04c517417c5748966afd63a5ba6ed19e SHA512 aeb17c986c597762381d9887679eb0eec194c2938a92b5a33e66b4c80002ead02d672b4aa968e1061ab5652b74e46a3c9f9e3d58d5be4a0ae47aa8aed288cf1f |
26 |
+DIST ghc-8.4.3-src.tar.xz 11315068 BLAKE2B cfb858051aff0c4fb3cdbbe96627cacc82665a6bfc4f863b0353eb3d93d358f7ed4efd7b131280763786f397aabc5c4825f60c3890649303fc97187f2b996d21 SHA512 c6cea84264f32ae888f9931f834a1d721889242f656d14262e787ec54a1793d1862ce76daacaf1006c12b8af12919501afce1dc02571373e24830e4d51803414 |
27 |
DIST ghc-bin-7.10.3-alpha.tbz2 183558856 BLAKE2B 2bb02aafa49c6a91bec016e8bec2d07257d602e53c9df55792ec6fbbf8e2e46de1d5f3f72c0ccf74d6bd7f7987f53412063ccb02ae85455fce11fa928cbf5291 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230 |
28 |
DIST ghc-bin-7.10.3-amd64.tbz2 112040431 BLAKE2B 3e59b70ca309a1cd704266c54a7983f9a58362bf700ced89c5649c780c664c650ec091e14026a7b84e339d2ebff39eba1772eebcd9fb4b99b9c99d179453d5cc SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558 |
29 |
DIST ghc-bin-7.10.3-ia64.tbz2 238680956 BLAKE2B 08593718d376051edfb0c86131e54dafc5c15056757fbeef90c653a7d217e49ff34ffaf7cd4083144c9277e73a290b822a0f889aaf806341375708e4b92654b2 SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5 |
30 |
|
31 |
diff --git a/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch |
32 |
new file mode 100644 |
33 |
index 00000000000..d6cff337380 |
34 |
--- /dev/null |
35 |
+++ b/dev-lang/ghc/files/ghc-8.0.2-no-relax-everywhere.patch |
36 |
@@ -0,0 +1,17 @@ |
37 |
+https://github.com/gentoo-haskell/gentoo-haskell/issues/704 |
38 |
+ |
39 |
+Allow users to specify -W,--relax externally and pass |
40 |
+-Wl,-no-relax unconditonally on all arches. |
41 |
+ |
42 |
+Reported-by: wmyrda |
43 |
+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs |
44 |
+index acd0d61..5830517 100644 |
45 |
+--- a/compiler/main/DriverPipeline.hs |
46 |
++++ b/compiler/main/DriverPipeline.hs |
47 |
+@@ -2172,5 +2172,3 @@ joinObjectFiles dflags o_files output_fn = do |
48 |
+ -- disable --relax explicitly. |
49 |
+- ++ (if platformArch (targetPlatform dflags) |
50 |
+- `elem` [ArchSPARC, ArchSPARC64] |
51 |
+- && ldIsGnuLd |
52 |
++ ++ (if ldIsGnuLd |
53 |
+ then [SysTools.Option "-Wl,-no-relax"] |
54 |
|
55 |
diff --git a/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch |
56 |
new file mode 100644 |
57 |
index 00000000000..071d4970a25 |
58 |
--- /dev/null |
59 |
+++ b/dev-lang/ghc/files/ghc-8.4.2-allow-cross-bootstrap.patch |
60 |
@@ -0,0 +1,23 @@ |
61 |
+Allow using cross-compilers to bootstrap GHC. |
62 |
+ |
63 |
+In my case I'm using "cross"-compiler from |
64 |
+x86_64-unknown-linux to x86_64-HEAD-linux. |
65 |
+ |
66 |
+Those targets have the same ABI and can boot one another. |
67 |
+diff --git a/configure.ac b/configure.ac |
68 |
+index a8b8681a36..791367e8bf 100644 |
69 |
+--- a/configure.ac |
70 |
++++ b/configure.ac |
71 |
+@@ -228,11 +228,11 @@ FPTOOLS_SET_PLATFORM_VARS |
72 |
+ if test "$BuildPlatform" != "$bootstrap_target" |
73 |
+ then |
74 |
+ echo "This GHC (${WithGhc}) does not generate code for the build platform" |
75 |
+ echo " GHC target platform : $bootstrap_target" |
76 |
+ echo " Desired build platform : $BuildPlatform" |
77 |
+- exit 1 |
78 |
++ #exit 1 |
79 |
+ fi |
80 |
+ |
81 |
+ # Testing if we shall enable shared libs support on Solaris. |
82 |
+ # Anything older than SunOS 5.11 aka Solaris 11 (Express) is broken. |
83 |
+ |
84 |
|
85 |
diff --git a/dev-lang/ghc/ghc-8.4.3.ebuild b/dev-lang/ghc/ghc-8.4.3.ebuild |
86 |
new file mode 100644 |
87 |
index 00000000000..59e9e523932 |
88 |
--- /dev/null |
89 |
+++ b/dev-lang/ghc/ghc-8.4.3.ebuild |
90 |
@@ -0,0 +1,760 @@ |
91 |
+# Copyright 1999-2018 Gentoo Foundation |
92 |
+# Distributed under the terms of the GNU General Public License v2 |
93 |
+ |
94 |
+EAPI=6 |
95 |
+ |
96 |
+# to make make a crosscompiler use crossdev and symlink ghc tree into |
97 |
+# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc' |
98 |
+export CBUILD=${CBUILD:-${CHOST}} |
99 |
+export CTARGET=${CTARGET:-${CHOST}} |
100 |
+if [[ ${CTARGET} = ${CHOST} ]] ; then |
101 |
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then |
102 |
+ export CTARGET=${CATEGORY/cross-} |
103 |
+ fi |
104 |
+fi |
105 |
+ |
106 |
+inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package |
107 |
+inherit multilib pax-utils toolchain-funcs versionator prefix |
108 |
+inherit check-reqs |
109 |
+DESCRIPTION="The Glasgow Haskell Compiler" |
110 |
+HOMEPAGE="http://www.haskell.org/ghc/" |
111 |
+ |
112 |
+# we don't have any binaries yet |
113 |
+arch_binaries="" |
114 |
+ |
115 |
+# sorted! |
116 |
+#arch_binaries="$arch_binaries alpha? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-alpha.tbz2 )" |
117 |
+#arch_binaries="$arch_binaries arm? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )" |
118 |
+#arch_binaries="$arch_binaries arm64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )" |
119 |
+#arch_binaries="$arch_binaries amd64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )" |
120 |
+#arch_binaries="$arch_binaries ia64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )" |
121 |
+#arch_binaries="$arch_binaries ppc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc.tbz2 )" |
122 |
+#arch_binaries="$arch_binaries ppc64? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-ppc64.tbz2 )" |
123 |
+#arch_binaries="$arch_binaries sparc? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-sparc.tbz2 )" |
124 |
+#arch_binaries="$arch_binaries x86? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )" |
125 |
+ |
126 |
+# various ports: |
127 |
+#arch_binaries="$arch_binaries x86-fbsd? ( https://slyfox.uni.cx/~slyfox/distfiles/ghc-bin-${PV}-x86-fbsd.tbz2 )" |
128 |
+ |
129 |
+# 0 - yet |
130 |
+yet_binary() { |
131 |
+ case "${ARCH}" in |
132 |
+ #alpha) return 0 ;; |
133 |
+ #arm64) return 0 ;; |
134 |
+ #arm) return 0 ;; |
135 |
+ #amd64) return 0 ;; |
136 |
+ #ia64) return 0 ;; |
137 |
+ #ppc) return 0 ;; |
138 |
+ #ppc64) return 0 ;; |
139 |
+ #sparc) return 0 ;; |
140 |
+ #x86) return 0 ;; |
141 |
+ *) return 1 ;; |
142 |
+ esac |
143 |
+} |
144 |
+ |
145 |
+GHC_PV=${PV} |
146 |
+#GHC_PV=8.4.1.20180329 # uncomment only for -alpha, -beta, -rc ebuilds |
147 |
+GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct |
148 |
+ |
149 |
+SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_/-}/${GHC_P}-src.tar.xz )" |
150 |
+S="${WORKDIR}"/${GHC_P} |
151 |
+ |
152 |
+[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )" |
153 |
+ |
154 |
+BUMP_LIBRARIES=( |
155 |
+ # "hackage-name hackage-version" |
156 |
+) |
157 |
+ |
158 |
+LICENSE="BSD" |
159 |
+SLOT="0/${PV}" |
160 |
+#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux" |
161 |
+IUSE="doc ghcbootstrap ghcmakebinary +gmp profile" |
162 |
+IUSE+=" binary" |
163 |
+ |
164 |
+RDEPEND=" |
165 |
+ >=dev-lang/perl-5.6.1 |
166 |
+ dev-libs/gmp:0= |
167 |
+ sys-libs/ncurses:0=[unicode] |
168 |
+ !ghcmakebinary? ( virtual/libffi:= ) |
169 |
+" |
170 |
+ |
171 |
+# This set of dependencies is needed to run |
172 |
+# prebuilt ghc. We specifically avoid ncurses |
173 |
+# dependency with: |
174 |
+# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING |
175 |
+PREBUILT_BINARY_DEPENDS=" |
176 |
+ !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) ) |
177 |
+" |
178 |
+# This set of dependencies is needed to install |
179 |
+# ghc[binary] in system. terminfo package is linked |
180 |
+# against ncurses. |
181 |
+PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS} |
182 |
+ sys-libs/ncurses:0/6 |
183 |
+" |
184 |
+ |
185 |
+RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )" |
186 |
+ |
187 |
+DEPEND="${RDEPEND} |
188 |
+ doc? ( app-text/docbook-xml-dtd:4.2 |
189 |
+ app-text/docbook-xml-dtd:4.5 |
190 |
+ app-text/docbook-xsl-stylesheets |
191 |
+ dev-python/sphinx |
192 |
+ >=dev-libs/libxslt-1.1.2 ) |
193 |
+ !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )" |
194 |
+ |
195 |
+PDEPEND="!ghcbootstrap? ( >=app-admin/haskell-updater-1.2 )" |
196 |
+ |
197 |
+REQUIRED_USE="?? ( ghcbootstrap binary )" |
198 |
+ |
199 |
+# haskell libraries built with cabal in configure mode, #515354 |
200 |
+QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc" |
201 |
+ |
202 |
+is_crosscompile() { |
203 |
+ [[ ${CHOST} != ${CTARGET} ]] |
204 |
+} |
205 |
+ |
206 |
+is_native() { |
207 |
+ [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]] |
208 |
+} |
209 |
+ |
210 |
+# returns tool prefix for crosscompiler. |
211 |
+# Example: |
212 |
+# CTARGET=armv7a-unknown-linux-gnueabi |
213 |
+# CHOST=x86_64-pc-linux-gnu |
214 |
+# "armv7a-unknown-linux-gnueabi-" |
215 |
+# CTARGET=${CHOST} |
216 |
+# "" |
217 |
+# Used in tools and library prefix: |
218 |
+# "${ED}"/usr/bin/$(cross)haddock |
219 |
+# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
220 |
+ |
221 |
+cross() { |
222 |
+ if is_crosscompile; then |
223 |
+ echo "${CTARGET}-" |
224 |
+ else |
225 |
+ echo "" |
226 |
+ fi |
227 |
+} |
228 |
+ |
229 |
+append-ghc-cflags() { |
230 |
+ local persistent compile assemble link |
231 |
+ local flag ghcflag |
232 |
+ |
233 |
+ for flag in $*; do |
234 |
+ case ${flag} in |
235 |
+ persistent) persistent="yes";; |
236 |
+ compile) compile="yes";; |
237 |
+ assemble) assemble="yes";; |
238 |
+ link) link="yes";; |
239 |
+ *) |
240 |
+ [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
241 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
242 |
+ [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
243 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
244 |
+ [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" && |
245 |
+ [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}" |
246 |
+ ;; |
247 |
+ esac |
248 |
+ done |
249 |
+} |
250 |
+ |
251 |
+# $1 - lib name (under libraries/) |
252 |
+# $2 - lib version |
253 |
+# example: bump_lib "transformers" "0.4.2.0" |
254 |
+bump_lib() { |
255 |
+ local pn=$1 pv=$2 |
256 |
+ local p=${pn}-${pv} |
257 |
+ local f |
258 |
+ |
259 |
+ einfo "Bumping ${pn} up to ${pv}" |
260 |
+ |
261 |
+ for f in ghc.mk GNUmakefile; do |
262 |
+ mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die |
263 |
+ done |
264 |
+ mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die |
265 |
+ mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die |
266 |
+} |
267 |
+ |
268 |
+update_SRC_URI() { |
269 |
+ local p pn pv |
270 |
+ for p in "${BUMP_LIBRARIES[@]}"; do |
271 |
+ set -- $p |
272 |
+ pn=$1 pv=$2 |
273 |
+ |
274 |
+ SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz" |
275 |
+ done |
276 |
+} |
277 |
+ |
278 |
+update_SRC_URI |
279 |
+ |
280 |
+bump_libs() { |
281 |
+ local p pn pv |
282 |
+ for p in "${BUMP_LIBRARIES[@]}"; do |
283 |
+ set -- $p |
284 |
+ pn=$1 pv=$2 |
285 |
+ |
286 |
+ bump_lib "${pn}" "${pv}" |
287 |
+ done |
288 |
+} |
289 |
+ |
290 |
+ghc_setup_cflags() { |
291 |
+ # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N> |
292 |
+ if ! is_native; then |
293 |
+ export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"} |
294 |
+ export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"} |
295 |
+ einfo "Crosscompiling mode:" |
296 |
+ einfo " CHOST: ${CHOST}" |
297 |
+ einfo " CTARGET: ${CTARGET}" |
298 |
+ einfo " CFLAGS: ${CFLAGS}" |
299 |
+ einfo " LDFLAGS: ${LDFLAGS}" |
300 |
+ einfo " prefix: $(cross)" |
301 |
+ return |
302 |
+ fi |
303 |
+ # We need to be very careful with the CFLAGS we ask ghc to pass through to |
304 |
+ # gcc. There are plenty of flags which will make gcc produce output that |
305 |
+ # breaks ghc in various ways. The main ones we want to pass through are |
306 |
+ # -mcpu / -march flags. These are important for arches like alpha & sparc. |
307 |
+ # We also use these CFLAGS for building the C parts of ghc, ie the rts. |
308 |
+ strip-flags |
309 |
+ strip-unsupported-flags |
310 |
+ |
311 |
+ # Cmm can't parse line numbers #482086 |
312 |
+ replace-flags -ggdb[3-9] -ggdb2 |
313 |
+ |
314 |
+ GHC_FLAGS="" |
315 |
+ GHC_PERSISTENT_FLAGS="" |
316 |
+ for flag in ${CFLAGS}; do |
317 |
+ case ${flag} in |
318 |
+ |
319 |
+ # Ignore extra optimisation (ghc passes -O to gcc anyway) |
320 |
+ # -O2 and above break on too many systems |
321 |
+ -O*) ;; |
322 |
+ |
323 |
+ # Arch and ABI flags are what we're really after |
324 |
+ -m*) append-ghc-cflags compile assemble ${flag};; |
325 |
+ |
326 |
+ # Sometimes it's handy to see backtrace of RTS |
327 |
+ # to get an idea what happens there |
328 |
+ -g*) append-ghc-cflags compile ${flag};; |
329 |
+ |
330 |
+ # Ignore all other flags, including all -f* flags |
331 |
+ esac |
332 |
+ done |
333 |
+ |
334 |
+ for flag in ${LDFLAGS}; do |
335 |
+ append-ghc-cflags link ${flag} |
336 |
+ done |
337 |
+ |
338 |
+ # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build. |
339 |
+ # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported |
340 |
+ # options to gcc. |
341 |
+ if is_native; then |
342 |
+ # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries |
343 |
+ # are not built with fPIC, bug #606666 |
344 |
+ gcc-specs-pie && append-ghc-cflags persistent compile link -nopie |
345 |
+ tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then |
346 |
+ # gcc-6.3 has support for -no-pie upstream, but spelling differs from |
347 |
+ # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow |
348 |
+ # hardened users try '-pie' in USE=ghcbootstrap mode. |
349 |
+ append-ghc-cflags compile link -no-pie |
350 |
+ fi |
351 |
+ |
352 |
+ # prevent from failing to build unregisterised ghc: |
353 |
+ # http://www.mail-archive.com/debian-bugs-dist@××××××××××××.org/msg171602.html |
354 |
+ use ppc64 && append-ghc-cflags persistent compile -mminimal-toc |
355 |
+ fi |
356 |
+} |
357 |
+ |
358 |
+# substitutes string $1 to $2 in files $3 $4 ... |
359 |
+relocate_path() { |
360 |
+ local from=$1 |
361 |
+ local to=$2 |
362 |
+ shift 2 |
363 |
+ local file= |
364 |
+ for file in "$@" |
365 |
+ do |
366 |
+ sed -i -e "s|$from|$to|g" \ |
367 |
+ "$file" || die "path relocation failed for '$file'" |
368 |
+ done |
369 |
+} |
370 |
+ |
371 |
+# changes hardcoded ghc paths and updates package index |
372 |
+# $1 - new absolute root path |
373 |
+relocate_ghc() { |
374 |
+ local to=$1 |
375 |
+ |
376 |
+ # libdir for prebuilt binary and for current system may mismatch |
377 |
+ # It does for prefix installation for example: bug #476998 |
378 |
+ local bin_ghc_prefix=${WORKDIR}/usr |
379 |
+ local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*) |
380 |
+ local bin_libdir=${bin_libpath#${bin_ghc_prefix}/} |
381 |
+ |
382 |
+ # backup original script to use it later after relocation |
383 |
+ local gp_back="${T}/ghc-pkg-${GHC_PV}-orig" |
384 |
+ cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper" |
385 |
+ |
386 |
+ if [[ ${bin_libdir} != $(get_libdir) ]]; then |
387 |
+ einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)" |
388 |
+ # moving the dir itself is not strictly needed |
389 |
+ # but then USE=binary would result in installing |
390 |
+ # in '${bin_libdir}' |
391 |
+ mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die |
392 |
+ |
393 |
+ relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \ |
394 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ |
395 |
+ "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ |
396 |
+ "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ |
397 |
+ "${WORKDIR}/usr/bin/hsc2hs" \ |
398 |
+ "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ |
399 |
+ "$gp_back" \ |
400 |
+ "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* |
401 |
+ fi |
402 |
+ |
403 |
+ # Relocate from /usr to ${EPREFIX}/usr |
404 |
+ relocate_path "/usr" "${to}/usr" \ |
405 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \ |
406 |
+ "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \ |
407 |
+ "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \ |
408 |
+ "${WORKDIR}/usr/bin/haddock-ghc-${GHC_PV}" \ |
409 |
+ "${WORKDIR}/usr/bin/hp2ps" \ |
410 |
+ "${WORKDIR}/usr/bin/hpc" \ |
411 |
+ "${WORKDIR}/usr/bin/hsc2hs" \ |
412 |
+ "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \ |
413 |
+ "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"* |
414 |
+ |
415 |
+ # this one we will use to regenerate cache |
416 |
+ # so it should point to current tree location |
417 |
+ relocate_path "/usr" "${WORKDIR}/usr" "$gp_back" |
418 |
+ |
419 |
+ if use prefix; then |
420 |
+ hprefixify "${bin_libpath}"/${PN}*/settings |
421 |
+ fi |
422 |
+ |
423 |
+ # regenerate the binary package cache |
424 |
+ "$gp_back" recache || die "failed to update cache after relocation" |
425 |
+ rm "$gp_back" |
426 |
+} |
427 |
+ |
428 |
+ghc-check-reqs() { |
429 |
+ # These are pessimistic values (slightly bigger than worst-case) |
430 |
+ # Worst case is UNREG USE=profile ia64. See bug #611866 for some |
431 |
+ # numbers on various arches. |
432 |
+ CHECKREQS_DISK_BUILD=8G |
433 |
+ CHECKREQS_DISK_USR=2G |
434 |
+ # USE=binary roughly takes |
435 |
+ use binary && CHECKREQS_DISK_BUILD=4G |
436 |
+ |
437 |
+ "$@" |
438 |
+} |
439 |
+ |
440 |
+pkg_pretend() { |
441 |
+ ghc-check-reqs check-reqs_pkg_pretend |
442 |
+} |
443 |
+ |
444 |
+pkg_setup() { |
445 |
+ ghc-check-reqs check-reqs_pkg_setup |
446 |
+ |
447 |
+ # quiet portage about prebuilt binaries |
448 |
+ use binary && QA_PREBUILT="*" |
449 |
+ |
450 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
451 |
+ |
452 |
+ if use ghcbootstrap; then |
453 |
+ ewarn "You requested ghc bootstrapping, this is usually only used" |
454 |
+ ewarn "by Gentoo developers to make binary .tbz2 packages." |
455 |
+ |
456 |
+ [[ -z $(type -P ghc) ]] && \ |
457 |
+ die "Could not find a ghc to bootstrap with." |
458 |
+ else |
459 |
+ if ! yet_binary; then |
460 |
+ eerror "Please try emerging with USE=ghcbootstrap and report build" |
461 |
+ eerror "sucess or failure to the haskell team (haskell@g.o)" |
462 |
+ die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap" |
463 |
+ fi |
464 |
+ fi |
465 |
+} |
466 |
+ |
467 |
+src_unpack() { |
468 |
+ # Create the ${S} dir if we're using the binary version |
469 |
+ use binary && mkdir "${S}" |
470 |
+ |
471 |
+ # the Solaris and Darwin binaries from ghc (maeder) need to be |
472 |
+ # unpacked separately, so prevent them from being unpacked |
473 |
+ local ONLYA=${A} |
474 |
+ case ${CHOST} in |
475 |
+ *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;; |
476 |
+ esac |
477 |
+ unpack ${ONLYA} |
478 |
+} |
479 |
+ |
480 |
+src_prepare() { |
481 |
+ ghc_setup_cflags |
482 |
+ |
483 |
+ if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then |
484 |
+ # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS. |
485 |
+ # See bug #313635. |
486 |
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ |
487 |
+ "${WORKDIR}/usr/bin/ghc-${GHC_PV}" |
488 |
+ |
489 |
+ # allow hardened users use vanilla binary to bootstrap ghc |
490 |
+ # ghci uses mmap with rwx protection at it implements dynamic |
491 |
+ # linking on it's own (bug #299709) |
492 |
+ pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc" |
493 |
+ fi |
494 |
+ |
495 |
+ if use binary; then |
496 |
+ if use prefix; then |
497 |
+ relocate_ghc "${EPREFIX}" |
498 |
+ fi |
499 |
+ |
500 |
+ # Move unpacked files to the expected place |
501 |
+ mv "${WORKDIR}/usr" "${S}" |
502 |
+ eapply_user |
503 |
+ else |
504 |
+ if ! use ghcbootstrap; then |
505 |
+ case ${CHOST} in |
506 |
+ *-darwin* | *-solaris*) |
507 |
+ # UPDATE ME for ghc-7 |
508 |
+ mkdir "${WORKDIR}"/ghc-bin-installer || die |
509 |
+ pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die |
510 |
+ use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2 |
511 |
+ use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2 |
512 |
+ use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2 |
513 |
+ use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2 |
514 |
+ popd > /dev/null |
515 |
+ |
516 |
+ pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die |
517 |
+ # fix the binaries so they run, on Solaris we need an |
518 |
+ # LD_LIBRARY_PATH which has our prefix libdirs, on |
519 |
+ # Darwin we need to replace the frameworks with our libs |
520 |
+ # from the prefix fix before installation, because some |
521 |
+ # of the tools are actually used during configure/make |
522 |
+ if [[ ${CHOST} == *-solaris* ]] ; then |
523 |
+ export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}" |
524 |
+ elif [[ ${CHOST} == *-darwin* ]] ; then |
525 |
+ local readline_framework=GNUreadline.framework/GNUreadline |
526 |
+ local gmp_framework=/opt/local/lib/libgmp.10.dylib |
527 |
+ local ncurses_file=/opt/local/lib/libncurses.5.dylib |
528 |
+ for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do |
529 |
+ install_name_tool -change \ |
530 |
+ ${readline_framework} \ |
531 |
+ "${EPREFIX}"/lib/libreadline.dylib \ |
532 |
+ ${binary} || die |
533 |
+ install_name_tool -change \ |
534 |
+ ${gmp_framework} \ |
535 |
+ "${EPREFIX}"/usr/lib/libgmp.dylib \ |
536 |
+ ${binary} || die |
537 |
+ install_name_tool -change \ |
538 |
+ ${ncurses_file} \ |
539 |
+ "${EPREFIX}"/usr/lib/libncurses.dylib \ |
540 |
+ ${binary} || die |
541 |
+ done |
542 |
+ # we don't do frameworks! |
543 |
+ sed -i \ |
544 |
+ -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \ |
545 |
+ -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \ |
546 |
+ rts/package.conf.in || die |
547 |
+ fi |
548 |
+ |
549 |
+ # it is autoconf, but we really don't want to give it too |
550 |
+ # much arguments, in fact we do the make in-place anyway |
551 |
+ ./configure --prefix="${WORKDIR}"/usr || die |
552 |
+ make install || die |
553 |
+ popd > /dev/null |
554 |
+ ;; |
555 |
+ *) |
556 |
+ relocate_ghc "${WORKDIR}" |
557 |
+ ;; |
558 |
+ esac |
559 |
+ fi |
560 |
+ |
561 |
+ sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \ |
562 |
+ "${S}/ghc/ghc.wrapper" |
563 |
+ |
564 |
+ cd "${S}" # otherwise eapply will break |
565 |
+ |
566 |
+ eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch |
567 |
+ eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch |
568 |
+ eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch |
569 |
+ eapply "${FILESDIR}"/${PN}-8.0.2-no-relax-everywhere.patch |
570 |
+ eapply "${FILESDIR}"/${PN}-8.4.2-allow-cross-bootstrap.patch |
571 |
+ |
572 |
+ # a bunch of crosscompiler patches |
573 |
+ # needs newer version: |
574 |
+ #eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch |
575 |
+ |
576 |
+ # mingw32 target |
577 |
+ pushd "${S}/libraries/Win32" |
578 |
+ eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround |
579 |
+ popd |
580 |
+ |
581 |
+ bump_libs |
582 |
+ |
583 |
+ eapply_user |
584 |
+ # as we have changed the build system |
585 |
+ eautoreconf |
586 |
+ fi |
587 |
+} |
588 |
+ |
589 |
+src_configure() { |
590 |
+ if ! use binary; then |
591 |
+ # initialize build.mk |
592 |
+ echo '# Gentoo changes' > mk/build.mk |
593 |
+ |
594 |
+ # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV} |
595 |
+ echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk |
596 |
+ echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk |
597 |
+ |
598 |
+ # We also need to use the GHC_FLAGS flags when building ghc itself |
599 |
+ echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk |
600 |
+ echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk |
601 |
+ echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk |
602 |
+ # Speed up initial Cabal bootstrap |
603 |
+ echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk |
604 |
+ |
605 |
+ # We can't depend on haddock except when bootstrapping when we |
606 |
+ # must build docs and include them into the binary .tbz2 package |
607 |
+ # app-text/dblatex is not in portage, can not build PDF or PS |
608 |
+ echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk |
609 |
+ echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk |
610 |
+ echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk |
611 |
+ |
612 |
+ # this controls presence on 'xhtml' and 'haddock' in final install |
613 |
+ echo "HADDOCK_DOCS = YES" >> mk/build.mk |
614 |
+ |
615 |
+ # not used outside of ghc's test |
616 |
+ if [[ -n ${GHC_BUILD_DPH} ]]; then |
617 |
+ echo "BUILD_DPH = YES" >> mk/build.mk |
618 |
+ else |
619 |
+ echo "BUILD_DPH = NO" >> mk/build.mk |
620 |
+ fi |
621 |
+ |
622 |
+ # Any non-native build has to skip as it needs |
623 |
+ # target haddock binary to be runnabine. |
624 |
+ if ! is_native; then |
625 |
+ # disable docs generation as it requires running stage2 |
626 |
+ echo "HADDOCK_DOCS=NO" >> mk/build.mk |
627 |
+ echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk |
628 |
+ echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk |
629 |
+ fi |
630 |
+ |
631 |
+ if is_crosscompile; then |
632 |
+ # Install ghc-stage1 crosscompiler instead of |
633 |
+ # ghc-stage2 cross-built compiler. |
634 |
+ echo "Stage1Only=YES" >> mk/build.mk |
635 |
+ fi |
636 |
+ |
637 |
+ # allows overriding build flavours for libraries: |
638 |
+ # v - vanilla (static libs) |
639 |
+ # p - profiled |
640 |
+ # dyn - shared libraries |
641 |
+ # example: GHC_LIBRARY_WAYS="v dyn" |
642 |
+ if [[ -n ${GHC_LIBRARY_WAYS} ]]; then |
643 |
+ echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk |
644 |
+ fi |
645 |
+ echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk |
646 |
+ |
647 |
+ # Get ghc from the unpacked binary .tbz2 |
648 |
+ # except when bootstrapping we just pick ghc up off the path |
649 |
+ if ! use ghcbootstrap; then |
650 |
+ export PATH="${WORKDIR}/usr/bin:${PATH}" |
651 |
+ fi |
652 |
+ |
653 |
+ echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk |
654 |
+ |
655 |
+ # don't strip anything. Very useful when stage2 SIGSEGVs on you |
656 |
+ echo "STRIP_CMD = :" >> mk/build.mk |
657 |
+ |
658 |
+ local econf_args=() |
659 |
+ |
660 |
+ # GHC embeds toolchain it was built by and uses it later. |
661 |
+ # Don't allow things like ccache or versioned binary slip. |
662 |
+ # We use stable thing across gcc upgrades. |
663 |
+ # User can use EXTRA_ECONF=CC=... to override this default. |
664 |
+ econf_args+=( |
665 |
+ AR=${CTARGET}-ar |
666 |
+ CC=${CTARGET}-gcc |
667 |
+ # these should be inferred by GHC but ghc defaults |
668 |
+ # to using bundled tools on windows. |
669 |
+ Windres=${CTARGET}-windres |
670 |
+ DllWrap=${CTARGET}-dllwrap |
671 |
+ # we set the linker explicitly below |
672 |
+ --disable-ld-override |
673 |
+ ) |
674 |
+ case ${CTARGET} in |
675 |
+ arm*) |
676 |
+ # ld.bfd-2.28 does not work for ghc. Force ld.gold |
677 |
+ # instead. This should be removed once gentoo gets |
678 |
+ # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177 |
679 |
+ econf_args+=(LD=${CTARGET}-ld.gold) |
680 |
+ ;; |
681 |
+ sparc*) |
682 |
+ # ld.gold-2.28 does not work for ghc. Force ld.bfd |
683 |
+ # instead. This should be removed once gentoo gets |
684 |
+ # a fix for missing --no-relax support bug: |
685 |
+ # https://sourceware.org/ml/binutils/2017-07/msg00183.html |
686 |
+ econf_args+=(LD=${CTARGET}-ld.bfd) |
687 |
+ ;; |
688 |
+ *) |
689 |
+ econf_args+=(LD=${CTARGET}-ld) |
690 |
+ esac |
691 |
+ |
692 |
+ if [[ ${CBUILD} != ${CHOST} ]]; then |
693 |
+ # GHC bug: ghc claims not to support cross-building. |
694 |
+ # It does, but does not distinct --host= value |
695 |
+ # for stage1 and stage2 compiler. |
696 |
+ econf_args+=(--host=${CBUILD}) |
697 |
+ fi |
698 |
+ |
699 |
+ if use ghcmakebinary; then |
700 |
+ # When building booting libary we are trying to |
701 |
+ # bundle or restrict most of external depends |
702 |
+ # with unstable ABI: |
703 |
+ # - embed libffi (default GHC behaviour) |
704 |
+ # - disable ncurses support for ghci (via haskeline) |
705 |
+ # https://bugs.gentoo.org/557478 |
706 |
+ # - disable ncurses support for ghc-pkg |
707 |
+ echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk |
708 |
+ echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk |
709 |
+ elif is_native; then |
710 |
+ # using ${GTARGET}'s libffi is not supported yet: |
711 |
+ # GHC embeds full path for ffi includes without /usr/${CTARGET} account. |
712 |
+ econf_args+=(--with-system-libffi) |
713 |
+ econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@')) |
714 |
+ fi |
715 |
+ |
716 |
+ einfo "Final mk/build.mk:" |
717 |
+ cat mk/build.mk || die |
718 |
+ |
719 |
+ econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot |
720 |
+ |
721 |
+ if [[ ${PV} == *9999* ]]; then |
722 |
+ GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')" |
723 |
+ GHC_P=${PN}-${GHC_PV} |
724 |
+ fi |
725 |
+ fi # ! use binary |
726 |
+} |
727 |
+ |
728 |
+src_compile() { |
729 |
+ if ! use binary; then |
730 |
+ # Stage1Only crosscompiler does not build stage2 |
731 |
+ if ! is_crosscompile; then |
732 |
+ # 1. build/pax-mark compiler binary first |
733 |
+ emake ghc/stage2/build/tmp/ghc-stage2 |
734 |
+ # 2. pax-mark (bug #516430) |
735 |
+ pax-mark -m ghc/stage2/build/tmp/ghc-stage2 |
736 |
+ # 2. build/pax-mark haddock using ghc-stage2 |
737 |
+ if is_native; then |
738 |
+ # non-native build does not build haddock |
739 |
+ # due to HADDOCK_DOCS=NO, but it could. |
740 |
+ emake utils/haddock/dist/build/tmp/haddock |
741 |
+ pax-mark -m utils/haddock/dist/build/tmp/haddock |
742 |
+ fi |
743 |
+ fi |
744 |
+ # 3. and then all the rest |
745 |
+ emake all |
746 |
+ fi # ! use binary |
747 |
+} |
748 |
+ |
749 |
+src_install() { |
750 |
+ if use binary; then |
751 |
+ use prefix && mkdir -p "${ED}" |
752 |
+ mv "${S}/usr" "${ED}" |
753 |
+ else |
754 |
+ [[ -f VERSION ]] || emake VERSION |
755 |
+ |
756 |
+ # -j1 due to a rare race in install script: |
757 |
+ # make --no-print-directory -f ghc.mk phase=final install |
758 |
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \ |
759 |
+ # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include" |
760 |
+ # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \ |
761 |
+ # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404" |
762 |
+ # /usr/bin/install: cannot create regular file \ |
763 |
+ # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory |
764 |
+ emake -j1 install DESTDIR="${D}" |
765 |
+ |
766 |
+ # Skip for cross-targets as they all share target location: |
767 |
+ # /usr/share/doc/ghc-9999/ |
768 |
+ if ! is_crosscompile; then |
769 |
+ dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION" |
770 |
+ fi |
771 |
+ |
772 |
+ # rename ghc-shipped files to avoid collision |
773 |
+ # of external packages. Motivating example: |
774 |
+ # user had installed: |
775 |
+ # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0) |
776 |
+ # dev-haskell/transformers-0.4.2.0 |
777 |
+ # then user tried to update to |
778 |
+ # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0) |
779 |
+ # this will lead to single .conf file collision. |
780 |
+ local shipped_conf renamed_conf |
781 |
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
782 |
+ for shipped_conf in "${package_confdir}"/*.conf; do |
783 |
+ # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf' |
784 |
+ renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf |
785 |
+ mv "${shipped_conf}" "${renamed_conf}" || die |
786 |
+ done |
787 |
+ |
788 |
+ # remove link, but leave 'haddock-${GHC_P}' |
789 |
+ rm -f "${ED}"/usr/bin/$(cross)haddock |
790 |
+ |
791 |
+ if ! is_crosscompile; then |
792 |
+ newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg |
793 |
+ newbashcomp utils/completion/ghc.bash ghc |
794 |
+ fi |
795 |
+ fi |
796 |
+ |
797 |
+ # path to the package.cache |
798 |
+ local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d" |
799 |
+ PKGCACHE="${package_confdir}"/package.cache |
800 |
+ # copy the package.conf.d, including timestamp, save it so we can help |
801 |
+ # users that have a broken package.conf.d |
802 |
+ cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d" |
803 |
+ |
804 |
+ # copy the package.conf, including timestamp, save it so we later can put it |
805 |
+ # back before uninstalling, or when upgrading. |
806 |
+ cp -p "${PKGCACHE}"{,.shipped} \ |
807 |
+ || die "failed to copy package.conf.d/package.cache" |
808 |
+} |
809 |
+ |
810 |
+pkg_preinst() { |
811 |
+ # have we got an earlier version of ghc installed? |
812 |
+ if has_version "<${CATEGORY}/${PF}"; then |
813 |
+ haskell_updater_warn="1" |
814 |
+ fi |
815 |
+} |
816 |
+ |
817 |
+pkg_postinst() { |
818 |
+ ghc-reregister |
819 |
+ |
820 |
+ # path to the package.cache |
821 |
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" |
822 |
+ |
823 |
+ # give the cache a new timestamp, it must be as recent as |
824 |
+ # the package.conf.d directory. |
825 |
+ touch "${PKGCACHE}" |
826 |
+ |
827 |
+ if [[ "${haskell_updater_warn}" == "1" ]]; then |
828 |
+ ewarn |
829 |
+ ewarn "\e[1;31m************************************************************************\e[0m" |
830 |
+ ewarn |
831 |
+ ewarn "You have just upgraded from an older version of GHC." |
832 |
+ ewarn "You may have to run" |
833 |
+ ewarn " 'haskell-updater'" |
834 |
+ ewarn "to rebuild all ghc-based Haskell libraries." |
835 |
+ ewarn |
836 |
+ ewarn "\e[1;31m************************************************************************\e[0m" |
837 |
+ ewarn |
838 |
+ fi |
839 |
+} |
840 |
+ |
841 |
+pkg_prerm() { |
842 |
+ PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache" |
843 |
+ rm -rf "${PKGCACHE}" |
844 |
+ |
845 |
+ cp -p "${PKGCACHE}"{.shipped,} |
846 |
+} |
847 |
+ |
848 |
+pkg_postrm() { |
849 |
+ ghc-package_pkg_postrm |
850 |
+} |