source: trunk/dports/_resources/port1.0/group/haskell-1.0.tcl @ 131981

Last change on this file since 131981 was 131981, checked in by cal@…, 4 years ago

haskell world: revbump everything (including ghc)

  • Clean up remnants left in GHC's package directory that may be left over from previous installations. See for example #46611, which has a log of all the superfluous files left on the buildbots, which should be cleaned up by this.
  • Modify portgroups to register configuration files in $prefix/lib/ghc-7.8.3/package.conf.d/ directly before calling ghc-pkg recache rather than using activation and deactivation scripts that indirectly create these files to avoid the same mess in the future. This way, the state in the package cache directory will always represent the same state MacPorts expects.
  • Simplify and clean up some of the portgroups, especially related to variable substitution in pre-/post-activation hooks.
  • Avoid duplicating most of the code in the haskellplatform 2.0 portgroup and just refer back to the haskell 1.0 portgroup instead.
  • Apply the hook variable substitution cleanup to the local helper functions in the haskell-platform Portfile.

This change

  • should finally fix #46611 and #42082 and all the weird little misconfigurations that would occasionally occur on users' machines
  • adds helpful debugging information (ghc-pkg list, ghc-pkg check) to the main.log in the configure phase.
  • breaks manual installation of haskell packages (e.g. using cabal) in the system directory, because the ghc Portfile will clean out everything that isn't owned by a port in the package cache directory. If this affects you, be advised that you should not be putting stuff MacPorts doesn't know about in MacPorts' prefix. Instead, please use user installations of these packages.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1# $Id: haskell-1.0.tcl 131981 2015-01-22 19:34:32Z cal@macports.org $
2#
3# Copyright (c) 2009 The MacPorts Project
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are
8# met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15# 3. Neither the name of The MacPorts Project nor the names of its
16#    contributors may be used to endorse or promote products derived from
17#    this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31#
32# Usage:
33# PortGroup       haskell 1.0
34# haskell.setup   haskell_package version [haskell_compiler]
35# where haskell_package is the name of the package (eg, digest), version
36# is the version for it, and haskell_compiler is which compiler to use
37# (ghc is the default if not specified, and currently the only option).
38# This automatically defines name, version, categories, homepage,
39# master_sites, distname, and depends_build as appropriate, and sets up
40# the configure, build, destroot, and post-activate stages.
41
42
43# List of supported compilers
44set haskell.compiler_list {ghc}
45
46# Configuration for each compiler
47
48# I'm explicitly *not* determining the GHC version programatically here,
49# because doing so would allow GHC packages to continue working when
50# installed from source after a GHC update without a revbump. That's however
51# not what I want, because it has previously lead to problems when mixing
52# buildbot packages with locally compiled ones around the time of GHC
53# updates.
54array set haskell.compiler_configuration {
55    ghc {port       ghc
56         version    7.8.3
57         compiler   ${prefix}/bin/ghc
58         ghc-pkg    ${prefix}/bin/ghc-pkg}
59}
60
61proc haskell.setup {package version {compiler ghc} {register_scripts "yes"} {target "standalone"}} {
62    global haskell.compiler_list
63    global haskell.compiler_configuration
64    global homepage prefix configure.cmd destroot worksrcpath name master_sites configure.cc extract.suffix
65
66    if {![info exists haskell.compiler_configuration($compiler)]} {
67        return -code error "Compiler ${compiler} not currently supported"
68    }
69    array set compiler_config [lindex [array get haskell.compiler_configuration $compiler] 1]
70
71    if {${target} eq "standalone"} {
72        # Do not set name when used for haskell platform port, because those
73        # are subports and cannot touch $name
74        name            hs-[string tolower ${package}]
75    }
76    version             ${version}
77    categories          devel haskell
78    homepage            http://hackage.haskell.org/package/${package}
79    master_sites        http://hackage.haskell.org/package/${package}-${version}
80    distname            ${package}-${version}
81    depends_lib         port:${compiler_config(port)}
82    configure.cmd       runhaskell
83    configure.pre_args
84    configure.args      Setup configure \
85                        --prefix=${prefix} \
86                        --with-compiler=[subst ${compiler_config(compiler)}] \
87                        -v \
88                        --enable-library-profiling \
89                        --with-gcc=${configure.cc}
90    build.cmd           ${configure.cmd}
91    build.args          Setup build -v
92    build.target
93    destroot.cmd        ${configure.cmd}
94    destroot.destdir
95    destroot.target     Setup copy --destdir=${destroot}
96    if {${register_scripts} == "yes"} {
97        # Create the package config, drop it in package.conf.d for the current
98        # GHC version and run ghc-pkg recache.
99        # Do not use the Setup register --gen-script and Setup unregister
100        # --gen-script method to generate scripts and call them during
101        # activation. It previously caused a mess that was hard to clean up,
102        # especially since ghc-pkg is pretty stubborn in removing packages when
103        # there are still dependencies left.
104
105        set package_conf_d ${prefix}/lib/ghc-${compiler_config(version)}/package.conf.d/
106        set generate_pkg_config_cmdline [list \
107            ${configure.cmd} Setup register \
108            --gen-pkg-config=${package}-${version}.conf]
109        set generate_pkg_config_hook [subst {
110            xinstall -d -m 755 [list ${destroot}${package_conf_d}]
111            system -W [list ${worksrcpath}] [list $generate_pkg_config_cmdline]
112            xinstall -m 644 [list ${worksrcpath}/${package}-${version}.conf] \
113                [list ${destroot}${package_conf_d}]
114        }]
115        post-destroot $generate_pkg_config_hook
116
117        set ghc_pkg_recache [list [subst ${compiler_config(ghc-pkg)}] recache -v]
118        set ghc_pkg_recache_hook [subst {
119            system [list $ghc_pkg_recache]
120        }]
121        post-activate $ghc_pkg_recache_hook
122        post-deactivate $ghc_pkg_recache_hook
123    }
124
125    set ghc_pkg_list  [list [subst ${compiler_config(ghc-pkg)}] list]
126    set ghc_pkg_check [list [subst ${compiler_config(ghc-pkg)}] check]
127
128    pre-configure [subst {
129        global ports_trace
130
131        ui_debug "Listing installed haskell packages"
132        catch {system [list $ghc_pkg_list]}
133
134        if [list {![tbool ports_trace]}] {
135            ui_debug "Running ghc-pkg check"
136            catch {system [list $ghc_pkg_check]}
137        } else {
138            ui_debug "Skipping ghc-pkg check because it generates wrong results in trace mode"
139        }
140    }]
141
142    if {${target} eq "standalone"} {
143        livecheck.type      regex
144        livecheck.url       http://hackage.haskell.org/package/${package}
145        livecheck.regex     "/package/[quotemeta ${package}]-\[^/\]+/[quotemeta ${package}]-(\[^\"\]+)[quotemeta ${extract.suffix}]"
146    } else {
147        # Disable livecheck for haskell platform ports
148        livecheck.type      none
149    }
150
151    universal_variant   no
152}
Note: See TracBrowser for help on using the repository browser.