Haskell package guidelines: Difference between revisions
(add zh-hans link) |
Felixonmars (talk | contribs) (add --datasubdir) |
||
(11 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:Arch package guidelines]] | [[Category:Arch package guidelines]] | ||
[[ja:Haskell パッケージガイドライン]] | [[ja:Haskell パッケージガイドライン]] | ||
[[pt:Haskell package guidelines]] | [[pt:Haskell package guidelines]] | ||
Line 10: | Line 9: | ||
This document aims to cover standards and guidelines for producing good [[Haskell]] [[Creating packages|packages]] on Arch. | This document aims to cover standards and guidelines for producing good [[Haskell]] [[Creating packages|packages]] on Arch. | ||
Until this document is written, contact [[User:Felixonmars]] | Until this document is written, contact [[User:Felixonmars]]. | ||
== Package naming == | == Package naming == | ||
Line 28: | Line 27: | ||
The preferred source of a Haskell program or library is from [https://hackage.haskell.org hackage]. [[PKGBUILD#source]] {{ic|1=source=()}} array should use the following URL template: | The preferred source of a Haskell program or library is from [https://hackage.haskell.org hackage]. [[PKGBUILD#source]] {{ic|1=source=()}} array should use the following URL template: | ||
<nowiki>https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz</nowiki> | |||
Note that a custom {{ic|_hkgname}} variable is used instead of {{ic|pkgname}} since Haskell packages are generally prefixed with ''haskell-''. This variable can generically be defined as follows: | |||
_hkgname=stm-delay | _hkgname=stm-delay | ||
== Rebuild order == | == Rebuild order == | ||
When a Haskell library changes | When a Haskell library changes its build flags or is updated, all dependent packages need to be rebuilt. The [https://github.com/felixonmars/archlinux-futils/blob/master/genrebuild genrebuild] tool can be used to find out what needs rebuilding and how. Example usage: | ||
$ ./genrebuild -H haskell-basement | |||
== Using arch-hs == | |||
{{Pkg|arch-hs}} is provided to automate {{ic|PKGBUILD}} generation and maintenance. | |||
To generate a series of {{ic|PKGBUILD}}s for a Hackage package (and its unpackaged dependencies): | |||
$ arch-hs -o /path/to/workdir library_name | |||
To compare dependencies and other packaging metadata for updating an existing package: | |||
$ arch-hs-diff library_name old_version new_version | |||
To compare Arch [extra] package versions and their corresponding Hackage package versions: | |||
$ arch-hs-sync check | |||
Note that {{ic|arch-hs}} uses {{Pkg|cabal-install}} to maintain Hackage databases, so please update your ''cabal-install'' database regularly to keep them fresh: | |||
$ cabal update | |||
== PKGBUILD library example == | == PKGBUILD library example == | ||
Line 42: | Line 64: | ||
{{hc|PKGBUILD|<nowiki> | {{hc|PKGBUILD|<nowiki> | ||
# | # Maintainer: Your Name <youremail@domain.com> | ||
_hkgname=stm-delay | _hkgname=stm-delay | ||
pkgname=haskell-stm-delay | pkgname=haskell-stm-delay | ||
pkgver= | |||
pkgrel=1 | |||
license=() | |||
arch=('x86_64') | arch=('x86_64') | ||
url="https://hackage.haskell.org/package/$ | url="https://hackage.haskell.org/package/$_hkgname" | ||
depends=(ghc-libs) | depends=(ghc-libs) | ||
makedepends=(ghc) | makedepends=(ghc) | ||
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz") | source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz") | ||
sha256sums=() | |||
build() { | build() { | ||
cd $_hkgname-$pkgver | cd "$_hkgname-$pkgver" | ||
runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \ | runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \ | ||
--prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \ | --prefix=/usr --docdir="/usr/share/doc/$pkgname" --datasubdir=$pkgname --enable-tests \ | ||
--dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \ | --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \ | ||
--ghc-option=-optl-Wl\,-z\,relro\,-z\,now \ | --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \ | ||
--ghc-option='-pie' | --ghc-option='-pie' | ||
runhaskell Setup build | runhaskell Setup build $MAKEFLAGS | ||
runhaskell Setup register --gen-script | runhaskell Setup register --gen-script | ||
runhaskell Setup unregister --gen-script | runhaskell Setup unregister --gen-script | ||
Line 68: | Line 94: | ||
check() { | check() { | ||
cd $_hkgname-$pkgver | cd "$_hkgname-$pkgver" | ||
runhaskell Setup test | runhaskell Setup test | ||
} | } | ||
package() { | package() { | ||
cd $_hkgname-$pkgver | cd "$_hkgname-$pkgver" | ||
install -D -m744 register.sh "$pkgdir | install -D -m744 register.sh "$pkgdir/usr/share/haskell/register/$pkgname.sh" | ||
install -D -m744 unregister.sh "$pkgdir | install -D -m744 unregister.sh "$pkgdir/usr/share/haskell/unregister/$pkgname.sh" | ||
runhaskell Setup copy --destdir="$pkgdir" | runhaskell Setup copy --destdir="$pkgdir" | ||
install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" | install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" |
Latest revision as of 03:17, 19 August 2023
32-bit – CLR – CMake – Cross – DKMS – Eclipse – Electron – Font – Free Pascal – GNOME – Go – Haskell – Java – KDE – Kernel – Lisp – Meson – MinGW – Node.js – Nonfree – OCaml – Perl – PHP – Python – R – Ruby – Rust – Shell – VCS – Web – Wine
This document aims to cover standards and guidelines for producing good Haskell packages on Arch.
Until this document is written, contact User:Felixonmars.
Package naming
For Haskell libraries, use haskell-libraryname
usually the same name as on hackage.
Architecture
See PKGBUILD#arch.
Every Haskell library or program is architecture-dependent.
Source
The preferred source of a Haskell program or library is from hackage. PKGBUILD#source source=()
array should use the following URL template:
https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz
Note that a custom _hkgname
variable is used instead of pkgname
since Haskell packages are generally prefixed with haskell-. This variable can generically be defined as follows:
_hkgname=stm-delay
Rebuild order
When a Haskell library changes its build flags or is updated, all dependent packages need to be rebuilt. The genrebuild tool can be used to find out what needs rebuilding and how. Example usage:
$ ./genrebuild -H haskell-basement
Using arch-hs
arch-hs is provided to automate PKGBUILD
generation and maintenance.
To generate a series of PKGBUILD
s for a Hackage package (and its unpackaged dependencies):
$ arch-hs -o /path/to/workdir library_name
To compare dependencies and other packaging metadata for updating an existing package:
$ arch-hs-diff library_name old_version new_version
To compare Arch [extra] package versions and their corresponding Hackage package versions:
$ arch-hs-sync check
Note that arch-hs
uses cabal-install to maintain Hackage databases, so please update your cabal-install database regularly to keep them fresh:
$ cabal update
PKGBUILD library example
Packaging a Haskell library is different from packaging a Haskell program, the libraries packaged in Arch Linux are meant to be used by packaged Haskell programs.
PKGBUILD
# Maintainer: Your Name <youremail@domain.com> _hkgname=stm-delay pkgname=haskell-stm-delay pkgver= pkgrel=1 license=() arch=('x86_64') url="https://hackage.haskell.org/package/$_hkgname" depends=(ghc-libs) makedepends=(ghc) source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz") sha256sums=() build() { cd "$_hkgname-$pkgver" runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \ --prefix=/usr --docdir="/usr/share/doc/$pkgname" --datasubdir=$pkgname --enable-tests \ --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \ --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \ --ghc-option='-pie' runhaskell Setup build $MAKEFLAGS runhaskell Setup register --gen-script runhaskell Setup unregister --gen-script sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh } check() { cd "$_hkgname-$pkgver" runhaskell Setup test } package() { cd "$_hkgname-$pkgver" install -D -m744 register.sh "$pkgdir/usr/share/haskell/register/$pkgname.sh" install -D -m744 unregister.sh "$pkgdir/usr/share/haskell/unregister/$pkgname.sh" runhaskell Setup copy --destdir="$pkgdir" install -D -m644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" rm -f "${pkgdir}/usr/share/doc/${pkgname}/LICENSE" }