Difference between revisions of "APKBUILD examples:Haskell"

From Alpine Linux
Jump to: navigation, search
m (mention licenses of dependencies)
m (making a note about not needing separate package for a library.)
Line 1: Line 1:
 
'''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 python2-) 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.
 
'''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 python2-) 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.
 +
 +
It is not necessary to create a separate package for a Haskell library with this method.
  
 
At this time, there is no site directory where all Haskell programs should go.
 
At this time, there is no site directory where all Haskell programs should go.

Revision as of 00:16, 7 February 2018

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 python2-) 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.

It is not necessary to create a separate package for a Haskell library with this method.

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 --enable-relocatable
}

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, 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
 }

As with licensing, make sure you put the licenses of the dependencies that cabal pulls also in the license= field.