Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 312595

Summary: Please review Prefix modifications to haskell-cabal.eclass
Product: Gentoo Linux Reporter: Fabian Groffen <grobian>
Component: EclassesAssignee: Gentoo's Haskell Language team <haskell>
Status: RESOLVED FIXED    
Severity: normal CC: prefix
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 315803, 312597    

Description Fabian Groffen gentoo-dev 2010-04-01 11:32:39 UTC
The following changes to haskell-cabal.eclass are necessary to make it Prefix aware.  Please review the changes and incorporate them into the eclass.  Thanks in advance.

--- eclass/haskell-cabal.eclass        2010-03-31 00:36:18.000000000 +0200
+++ haskell-cabal.eclass        2010-04-01 13:07:46.900695000 +0200
@@ -70,6 +70,9 @@
        esac
 done
 
+# no fun, but necessary for the cabalconf settings below
+has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
+
 if [[ -n "${CABAL_USE_HADDOCK}" ]]; then
        IUSE="${IUSE} doc"
        DEPEND="${DEPEND} doc? ( dev-haskell/haddock )"
@@ -77,22 +80,22 @@
 
 if [[ -n "${CABAL_USE_ALEX}" ]]; then
        DEPEND="${DEPEND} dev-haskell/alex"
-       cabalconf="${cabalconf} --with-alex=/usr/bin/alex"
+       cabalconf="${cabalconf} --with-alex=${EPREFIX}/usr/bin/alex"
 fi
 
 if [[ -n "${CABAL_USE_HAPPY}" ]]; then
        DEPEND="${DEPEND} dev-haskell/happy"
-       cabalconf="${cabalconf} --with-happy=/usr/bin/happy"
+       cabalconf="${cabalconf} --with-happy=${EPREFIX}/usr/bin/happy"
 fi
 
 if [[ -n "${CABAL_USE_C2HS}" ]]; then
        DEPEND="${DEPEND} dev-haskell/c2hs"
-       cabalconf="${cabalconf} --with-c2hs=/usr/bin/c2hs"
+       cabalconf="${cabalconf} --with-c2hs=${EPREFIX}/usr/bin/c2hs"
 fi
 
 if [[ -n "${CABAL_USE_CPPHS}" ]]; then
        DEPEND="${DEPEND} dev-haskell/cpphs"
-       cabalconf="${cabalconf} --with-cpphs=/usr/bin/cpphs"
+       cabalconf="${cabalconf} --with-cpphs=${EPREFIX}/usr/bin/cpphs"
 fi
 
 if [[ -n "${CABAL_USE_PROFILE}" ]]; then
@@ -192,8 +195,9 @@
 }
 
 cabal-configure() {
+       has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
        if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
-               cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock"
+               cabalconf="${cabalconf} --with-haddock=${EPREFIX}/usr/bin/haddock"
        fi
        if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then
                cabalconf="${cabalconf} --enable-library-profiling"
@@ -214,7 +218,7 @@
        fi
 
        if version_is_at_least "1.2.0" "$(cabal-version)"; then
-               cabalconf="${cabalconf} --docdir=/usr/share/doc/${PF}"
+               cabalconf="${cabalconf} --docdir=${EPREFIX}/usr/share/doc/${PF}"
                # As of Cabal 1.2, configure is quite quiet. For diagnostic purposes
                # it's better if the configure chatter is in the build logs:
                cabalconf="${cabalconf} --verbose"
@@ -226,13 +230,13 @@
        # Because we can only set the datadir, not the docdir.
 
        ./setup configure \
-               --ghc --prefix=/usr \
+               --ghc --prefix="${EPREFIX}"/usr \
                --with-compiler="$(ghc-getghc)" \
                --with-hc-pkg="$(ghc-getghcpkg)" \
-               --prefix=/usr \
-               --libdir=/usr/$(get_libdir) \
+               --prefix="${EPREFIX}"/usr \
+               --libdir="${EPREFIX}"/usr/$(get_libdir) \
                --libsubdir=${P}/ghc-$(ghc-version) \
-               --datadir=/usr/share/ \
+               --datadir="${EPREFIX}"/usr/share/ \
                --datasubdir=${P}/ghc-$(ghc-version) \
                ${cabalconf} \
                ${CABAL_CONFIGURE_FLAGS} \
@@ -246,19 +250,20 @@
 }
 
 cabal-copy() {
+       has "${EAPI:-0}" 0 1 2 && ! use prefix && ED=${D}
        ./setup copy \
-               --destdir="${D}" \
+               --copy-prefix="${ED}/usr" \
                || die "setup copy failed"
 
        # cabal is a bit eager about creating dirs,
        # so remove them if they are empty
-       rmdir "${D}/usr/bin" 2> /dev/null
+       rmdir "${ED}/usr/bin" 2> /dev/null
 
        # GHC 6.4 has a bug in get/setPermission and Cabal 1.1.1 has
        # no workaround.
        # set the +x permission on executables
-       if [[ -d "${D}/usr/bin" ]] ; then
-               chmod +x "${D}/usr/bin/"*
+       if [[ -d "${ED}/usr/bin" ]] ; then
+               chmod +x "${ED}/usr/bin/"*
        fi
        # TODO: do we still need this?
 }
@@ -377,9 +382,12 @@
 
 # exported function: cabal-style copy and register
 cabal_src_install() {
+       has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
        if cabal-is-dummy-lib; then
                # create a dummy local package conf file for the sake of ghc-updater
-               dodir "$(ghc-confdir)"
+               local ghc_confdir_with_prefix="$(ghc-confdir)"
+               # remove EPREFIX
+               dodir ${ghc_confdir_with_prefix#${EPREFIX}}
                echo '[]' > "${D}/$(ghc-confdir)/$(ghc-localpkgconf)"
        else
                cabal-copy


The has in global scope isn't really cool, but I guess it can only be solved if the cabalconf settings are done separate from the DEPEND settings in some function.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2011-01-30 12:42:43 UTC
Sorry for so late response.

        ./setup copy \
-               --destdir="${D}" \
+               --copy-prefix="${ED}/usr" \

This one will break for sure.

ghc (the haskell compiler) is expected to be installed in $EPREFIX directory
(as the rest of stuff), right? I'm not sure it will work.

May I ask for a "quick gentoo prefix install howto" link?
I'd try to install it and attempt to make things work.
Comment 2 Fabian Groffen gentoo-dev 2011-01-30 12:54:31 UTC
Interestingly that copy-prefix thing seems to come from a sync, 2007-07-26.  Perhaps this was reverted again.  The destdir thing seems to be from just a day before from 1.11, which mention "updates to ghc-6.6.x upgrade".  It is safe to assume we somehow missed this update (syncing isn't perfect).  I think 
  --destdir="${D}" \
is the correct thing to take here.  But I need to test this (which takes some considerate amount of time)

Your howto:
http://blog.jolexa.net/2010/03/23/installing-gentoo-prefix-on-a-gentoo-linux-host/
Comment 3 Sergei Trofimovich (RETIRED) gentoo-dev 2011-04-10 13:12:36 UTC
Eclass pushed to the tree in almost unmodified form.
> revision 1.23
> date: 2011-03-13 22:15:14 +0200;  author: slyfox;  state: Exp;  lines: +47 -26;  commitid: 2c814d7d25954567;
> Added EPREFIX support. Fixed default src_configure for dummy packages (EAPI=3 and upper).

ghc with basic eprefix support is in the tree.
> *ghc-6.12.3-r1 (27 Mar 2011)
> 
>   27 Mar 2011; Sergei Trofimovich <slyfox@gentoo.org> +ghc-6.12.3-r1.ebuild,
>   +files/ghc-6.12.3-ticket-2615-linker-script.patch:
>   Migrated to EAPI=3: initial PREFIX support (based on work of grobian);
>   USE=unicode for ncurses is a required depend (bug #326237 by Josh
>   Cartwright and others). Added linker script support to workaround bug
>   #311361 by Maciej Piechotka.


Thank you, Fabian!