1 |
Hi, I am working on a PR to update some dependencies for libguestfs in dev-ml: |
2 |
|
3 |
https://github.com/gentoo/gentoo/pull/15421 |
4 |
|
5 |
I made a new eclass "dune" for the OCaml Dune build system, it is |
6 |
based on the "oasis" eclass for the Oasis build system for OCaml. |
7 |
|
8 |
I was told I need to post it to this list for review, so here it is: |
9 |
|
10 |
# Copyright 1999-2020 Gentoo Authors |
11 |
# Distributed under the terms of the GNU General Public License v2 |
12 |
|
13 |
# @ECLASS: dune.eclass |
14 |
# @MAINTAINER: |
15 |
# maintainer-needed@g.o |
16 |
# @AUTHOR: |
17 |
# Rafael Kitover <rkitover@×××××.com> |
18 |
# @SUPPORTED_EAPIS: 5 6 7 |
19 |
# @BLURB: Provides functions for installing dune packages. |
20 |
# @DESCRIPTION: |
21 |
# Provides dependencies on dune and ocaml and default src_compile, src_test and |
22 |
# src_install for dune-based packages. |
23 |
|
24 |
# @ECLASS-VARIABLE: DUNE_PKG_NAME |
25 |
# @DESCRIPTION: |
26 |
# Sets the actual dune package name, if different from gentoo package name. |
27 |
# Set before inheriting the eclass. |
28 |
|
29 |
case ${EAPI:-0} in |
30 |
5|6|7) ;; |
31 |
*) die "${ECLASS}: EAPI ${EAPI} not supported" ;; |
32 |
esac |
33 |
|
34 |
RDEPEND=">=dev-lang/ocaml-4:=" |
35 |
DEPEND="${RDEPEND} |
36 |
dev-ml/dune" |
37 |
|
38 |
dune_src_compile() { |
39 |
dune build @install || die |
40 |
} |
41 |
|
42 |
dune_src_test() { |
43 |
dune runtest || die |
44 |
} |
45 |
|
46 |
# @FUNCTION: dune-install |
47 |
# @USAGE: <list of packages> |
48 |
# @DESCRIPTION: |
49 |
# Installs the dune packages given as arguments. For each "${pkg}" element in |
50 |
# that list, "${pkg}.install" must be readable from "${PWD}/_build/default" |
51 |
dune-install() { |
52 |
local pkg |
53 |
for pkg ; do |
54 |
dune install \ |
55 |
--prefix="${ED%/}/usr" \ |
56 |
--libdir="${D%/}$(ocamlc -where)" \ |
57 |
"${pkg}" || die |
58 |
done |
59 |
} |
60 |
|
61 |
dune_src_install() { |
62 |
local pkg="${1:-${DUNE_PKG_NAME:-${PN}}}" |
63 |
|
64 |
dune-install "${pkg}" |
65 |
|
66 |
# Move docs to the appropriate place. |
67 |
if [ -d "${ED%/}/usr/doc/${pkg}" ] ; then |
68 |
mkdir -p "${ED%/}/usr/share/doc/${PF}/" || die |
69 |
mv "${ED%/}/usr/doc/${pkg}/"* |
70 |
"${ED%/}/usr/share/doc/${PF}/" || die |
71 |
rm -rf "${ED%/}/usr/doc" || die |
72 |
fi |
73 |
} |
74 |
|
75 |
EXPORT_FUNCTIONS src_compile src_test src_install |