Hey,
Here is an eclass that would allow me to factor quite a bit of
redundant code.
Potential users:
https://qa-reports.gentoo.org/output/genrdeps/dindex/dev-ml/opam
Examples of conversion:
diff --git a/dev-ml/ocaml-cstruct/ocaml-cstruct-3.1.1.ebuild
b/dev-ml/ocaml-cstruct/ocaml-cstruct-3.1.1.ebuild index
0acf2607860..5e238f762db 100644 ---
a/dev-ml/ocaml-cstruct/ocaml-cstruct-3.1.1.ebuild +++
b/dev-ml/ocaml-cstruct/ocaml-cstruct-3.1.1.ebuild @@ -3,7 +3,7 @@
EAPI=5
-inherit findlib
+inherit findlib opam
DESCRIPTION="Map OCaml arrays onto C-like structs"
HOMEPAGE="https://github.com/mirage/ocaml-cstruct https://mirage.io"
@@ -57,18 +57,6 @@ src_test() {
jbuilder runtest -p $(get_targets) || die
}
-oinstall() {
- opam-installer -i \
- --prefix="${ED}/usr" \
- --libdir="${D}/$(ocamlc -where)" \
- --docdir="${ED}/usr/share/doc/${PF}" \
- ${1}.install || die
-}
-
src_install() {
- oinstall cstruct
- oinstall cstruct-unix
- use lwt && oinstall cstruct-lwt
- use async && oinstall cstruct-async
- use ppx && oinstall ppx_cstruct
+ opam-install $(get_targets | tr ',' ' ')
}
diff --git a/dev-ml/utop/utop-2.0.1.ebuild
b/dev-ml/utop/utop-2.0.1.ebuild index 90056da08e8..c3bec3b1f94 100644
--- a/dev-ml/utop/utop-2.0.1.ebuild
+++ b/dev-ml/utop/utop-2.0.1.ebuild
@@ -3,7 +3,7 @@
EAPI=5
-inherit findlib
+inherit findlib opam
DESCRIPTION="A new toplevel for OCaml with completion and colorization"
HOMEPAGE="https://github.com/diml/utop"
@@ -30,12 +30,3 @@ DEPEND="${DEPEND}
DOCS=( "CHANGES.md" "README.md" )
SITEFILE="50${PN}-gentoo.el"
-
-src_install() {
- opam-installer -i \
- --prefix="${ED}/usr" \
- --libdir="${D}/$(ocamlc -where)" \
- --docdir="${ED}/usr/share/doc/${PF}" \
- --mandir="${ED}/usr/share/man" \
- ${PN}.install || die
-}
Alexis.
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: opam.eclass
# @MAINTAINER:
# Gentoo ML Project <m...@gentoo.org>
# @AUTHOR:
# Alexis Ballier <aball...@gentoo.org>
# @BLURB: Provides functions for installing opam packages.
# @DESCRIPTION:
# Provides dependencies on opam and ocaml, opam-install and a default
# src_install for opam-based packages.
case ${EAPI:-0} in
0|1|2|3|4) die "You need at least EAPI-5 to use opam.eclass";;
*) ;;
esac
RDEPEND=">=dev-lang/ocaml-4:="
DEPEND="${RDEPEND}
dev-ml/opam"
# @FUNCTION: opam-install
# @USAGE: <list of packages>
# @DESCRIPTION:
# Installs the opam packages given as arguments. For each "${pkg}" element in
# that list, "${pkg}.install" must be readable from current working directory.
opam-install() {
for pkg ; do
opam-installer -i \
--prefix="${ED}/usr" \
--libdir="${D}/$(ocamlc -where)" \
--docdir="${ED}/usr/share/doc/${PF}" \
--mandir="${ED}/usr/share/man" \
"${pkg}.install" || die
done
}
opam_src_install() {
opam-install "${PN}"
# Handle opam putting doc in a subdir
if [ -d "${ED}/usr/share/doc/${PF}/${PN}" ] ; then
mv "${ED}/usr/share/doc/${PF}/${PN}/"*
"${ED}/usr/share/doc/${PF}/" || die
rmdir "${ED}/usr/share/doc/${PF}/${PN}" || die
fi
}
EXPORT_FUNCTIONS src_install