summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 826769b4804eb4ff32363ef962193309a08bebd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Maintainer: Phil Ruffwind <rf@rufflewind.com>
pkgname=ghc-pristine
pkgver=8.2.1
pkgrel=1
pkgdesc="Symlinks to GHC with only boot libs, useful for building static binaries"
arch=(any)
url=https://www.haskell.org/ghc/
license=(custom)
depends=(ghc)

# This package provides symbolic links to the Glasgow Haskell Compiler, but
# with the global package database restricted to only boot libraries.  This is
# useful for building statically linked executables without interference from
# the official haskell-* packages, which only offer dynamic libraries and
# makes cabal hopelessly confused.
#
# To use this package, you just need to configure cabal
# --with-compiler=/usr/share/ghc-pristine/bin/ghc

pkgver() {
    ghc --version | sed -n 's/^.*version \([0-9.]*\)/\1/p'
}

package() {
    prefix=/usr/share/ghc-pristine
    mkdir -p "$pkgdir$prefix/bin/" "$pkgdir$prefix/lib/package.conf.d/"
    ver=`pacman -Q ghc`
    ver=${ver#* }
    ver=${ver%-*}
    pacman -Ql ghc | while read -r line; do
        f=${line#* }
        f=${f%/}
        case $f in
            /usr/bin/*)
                if [ -L "$f" ]; then
                    cp -P "$f" "$pkgdir$prefix/bin/"
                else
                    head=`head -c 2 "$f"`
                    if [ "$head" = "#!" ]; then
                        n=`basename "$f"`
                        cp -p "$f" "$pkgdir$prefix/bin/"
                        sed -i 's?topdir=.*?topdir="'"$prefix"'"/lib?;s?exec "/usr/bin/ghc?exec "'"$prefix"'"/bin/ghc?' "$pkgdir$prefix/bin/$n"
                    fi
                fi
                ;;
            /usr/lib/ghc-$ver/package.conf.d/*.conf)
                ln -fs "$f" "$pkgdir$prefix/lib/package.conf.d/"
                ;;
            /usr/lib/ghc-$ver/*-*.*.*)
                ;;
            /usr/lib/ghc-$ver/package.conf.d)
                ;;
            /usr/lib/ghc-$ver/*/*)
                ;;
            /usr/lib/ghc-$ver/*)
                ln -fs "$f" "$pkgdir$prefix/lib/"
                ;;
        esac
    done
    ghc-pkg -f "$pkgdir$prefix/lib/package.conf.d" recache
    mkdir -p "$pkgdir/usr/share/licenses/ghc-pristine"
    ln -s ../ghc/LICENSE "$pkgdir/usr/share/licenses/ghc-pristine"
}