APKBUILD examples:Haskell

From Alpine Linux
Revision as of 23:06, 6 February 2018 by Orson Teodoro (talk | contribs) (fix package())

Packaging Haskell software may require specific versions of dependencies which the Alpine package system is not suited for. Alpine does not have an elaborate slot system, allowing for multiple minor and major versions to be installed, like Gentoo does but assumed that packages are are latest version for that release of Alpine or Edge. Alpine can achieve a slot system but requires separate package like how llvm (llvm5- llvm4-) and python (python3- and python4-) are handled. Each package dependencies along with the main program will be placed in a sandbox. We will describe boilerplate template you can use to create a package that depends on Haskell. Haskell uses a package manager called cabal which dumps the contents into a .cabal folder in the current directory. Alpine uses ghc (Glasgow Haskell Compiler) for Haskell support.

At this time, there is no site directory where all Haskell programs should go.

You need to have this make depends:

makedepends="ghc cabal"

Your prepare() statement should look like:

prepare() {
 cd "$builddir"
 cabal sandbox init
 cabal configure --prefix=/usr
}

Your build() statement should look like:

build() {
 # the cabal install will automatically fetch all dependencies and compile all dependencies and the main program
 cabal install $pkgname-$pkgver
}

After cabal install is done, it will place all the files in a hidden folder at $builddir/.cabal. Dump the contents of that folder into "$pkgdir"/usr/lib/$pkgname. Then, then make a symlink from $pkgname/usr/lib/$pkgname/bin/$pkgname to /usr/bin/$pkgname

Your package() statement should look like:

 package() {
  mkdir -p "$pkgdir/usr/lib"
  mv "$builddir"/.cabal "$builddir"/$pkgname
  mv "$builddir"/$pkgname "$pkgdir"/usr/lib/

  mkdir -p "$pkgdir/usr/bin"
  cd "$pkgdir/usr/bin"
  ln -s /usr/lib/$pkgname/$bin/$pkgname $pkgname
 }