Skip to content

Commit

Permalink
cabal: Update to version 3.4.0.0
Browse files Browse the repository at this point in the history
* Update to version 3.4.0.0
* Implement new cabal bootstrap process
  • Loading branch information
essandess authored and herbygillot committed Mar 27, 2021
1 parent 364c800 commit 7915851
Showing 1 changed file with 65 additions and 41 deletions.
106 changes: 65 additions & 41 deletions lang/cabal/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,46 @@
PortSystem 1.0

name cabal
version 3.0.0.0
categories lang haskell
version 3.4.0.0
revision 0
categories lang haskell devel
platforms darwin
license BSD
maintainers nomaintainer

description Haskell Cabal: Common Architecture for Building Applications and Libraries
long_description \
Cabal is a system for building and packaging Haskell libraries and \
programs. It defines a common interface for package authors and \
distributors to easily build their applications in a portable \
way. Cabal is part of a larger infrastructure for distributing, \
organizing, and cataloging Haskell libraries and programs.
description Haskell Cabal: Common Architecture for \
Building Applications and Libraries

long_description Cabal is a system for building and packaging \
Haskell libraries and programs. It defines a \
common interface for package authors and \
distributors to easily build their applications in \
a portable way. Cabal is part of a larger \
infrastructure for distributing, organizing, and \
cataloging Haskell libraries and programs.

homepage https://www.haskell.org/cabal

# Bootstrapped cabal is the default build
variant prebuilt \
description {Do not bootstrap cabal; install the pre-built binary.} {}

master_sites https://downloads.haskell.org/~${name}/${name}-install-${version}/
distname ${name}-install-${version}-x86_64-apple-darwin17.7.0
extract.suffix .tar.xz
master_sites https://downloads.haskell.org/~${name}/${name}-install-${version}/:haskell
set distfile_haskell \
${name}-install-${version}-x86_64-darwin-sierra.tar.xz
distfiles ${distfile_haskell}:haskell

checksums [lindex ${distfiles} end] \
rmd160 9b5fbf25fe1f9473766a3466aaa9d66d66cfb884 \
sha256 d4857e068560515e4cbb0e8ca124c370e07892f2a28804d87152834e5fe2b845 \
size 5022564
checksums ${distfile_haskell} \
rmd160 b21c826fec8389ff429fcac37541430d34ac8c71 \
sha256 cb10be9a53e856aa2d852fd88fb6944f138783ffe0ea84d93c9a69244e34ea91 \
size 5583116

extract.only [lindex ${distfiles} end]
extract.only ${distfile_haskell}

supported_archs x86_64

depends_build-append \
port:ghc

use_configure no

# the PATH environment must provide /usr/bin/clang, not ${prefix}/bin/gcc,
# along with bootstrap path
build.env \
PATH=/usr/bin:${workpath}:$env(PATH) \
PREFIX=${prefix} \
CC=${configure.cc}

# cabal must bootstrap itself
pre-build {
# binary extract to ${workpath}/${name}
Expand All @@ -58,29 +53,58 @@ pre-build {
if { [variant_isset "prebuilt"] } {
build {}
} else {
distfiles-append \
set distfile_github \
${name}-install-${version}.tar.gz
master_sites-append \
https://github.com/haskell/${name}/archive/:github
distfiles-append \
${distfile_github}:github
checksums-append \
${name}-install-${version}.tar.gz \
rmd160 7217d6334bdf98f18341fb0aff8208b20717f695 \
sha256 a432a7853afe96c0fd80f434bd80274601331d8c46b628cd19a0d8e96212aaf1 \
size 654045
${distfile_github} \
rmd160 7d9f7a4c5551104a5787781e9938003944902a8a \
sha256 e4fbd5eb1d77400746a993679181f159aa415a37b931b26d67f5602f63ce971c \
size 2072483

# See ${prefix}/var/macports/sources/rsync.macports.org/macports/release/tarballs/ports/_resources/port1.0/group/python-1.0.tcl
set python_version 39
set python_branch [string index ${python_version} 0].[string range ${python_version} 1 end]
set python_prefix ${frameworks_dir}/Python.framework/Versions/${python_branch}
set python_bin ${python_prefix}/bin/python${python_branch}

depends_build-append \
port:ghc \
port:python${python_version}

extract.only-append \
${name}-install-${version}.tar.gz
${distfile_github}
worksrcdir ${name}-install-${version}

post-patch {
reinplace -E "1s|^(#!)/usr/bin/env\[\[:space:]]+python3\[\[:space:]]*$|\\1${python_bin}|" \
${worksrcpath}/bootstrap/bootstrap.py
}

# bootstrap instructions:
# https://github.com/haskell/cabal/blob/master/bootstrap/README.md
build {
# build cabal and overwrite ${workpath}/bin/${name}
# the PATH environment must provide /usr/bin/clang, not ${prefix}/bin/gcc
set ghc_version [exec sh -c "ghc --version | sed -E 's|^.+version (\[\[:digit:]])|\\1|'"]
system -W ${worksrcpath} \
"${workpath}/bin/cabal update"
system -W ${worksrcpath} \
"${workpath}/bin/cabal v2-build --with-compiler=${prefix}/bin/ghc --dry-run cabal-install:exe:cabal"
xinstall -m 0644 -W ${worksrcpath} \
./dist-newstyle/cache/plan.json \
./bootstrap/${platforms}-${ghc_version}.plan.json
system -W ${worksrcpath} \
"${worksrcpath}/bootstrap.sh"
"${workpath}/bin/cabal v2-build --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen"
system -W ${worksrcpath} \
"${workpath}/bin/cabal v2-run -vnormal+stderr --builddir=dist-newstyle-bootstrap --project=cabal.project.bootstrap cabal-bootstrap-gen -- bootstrap/${platforms}-${ghc_version}.plan.json | tee bootstrap/${platforms}-${ghc_version}.json"
system -W ${worksrcpath} \
"bootstrap/bootstrap.py -d bootstrap/${platforms}-${ghc_version}.json -w ${prefix}/bin/ghc"

delete ${workpath}/bin/${name}
xinstall -m 0755 -W ${worksrcpath}/dist/build/${name} ${name} ${workpath}/bin/${name}
}

post-destroot {
xinstall -m 0755 -d ${destroot}${prefix}/share/man/man1
xinstall -m 0644 -W ${worksrcpath}/dist/build/${name} ${name}.1 ${destroot}${prefix}/share/man/man1
xinstall -m 0755 -W ${worksrcpath}/_build/bin ${name} ${workpath}/bin/${name}
}
}

Expand Down

0 comments on commit 7915851

Please sign in to comment.