From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 4AF45139694 for ; Mon, 24 Jul 2017 15:20:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 760101FC047; Mon, 24 Jul 2017 15:20:41 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1F48DE0D1C for ; Mon, 24 Jul 2017 15:20:39 +0000 (UTC) Received: from localhost (unknown [IPv6:2a01:e34:eeaa:6bd0:4ecc:6aff:fe03:1cfc]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: aballier) by smtp.gentoo.org (Postfix) with ESMTPSA id 8D2753417F3 for ; Mon, 24 Jul 2017 15:20:38 +0000 (UTC) Date: Mon, 24 Jul 2017 17:20:32 +0200 From: Alexis Ballier To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] New eclass: opam.eclass Message-ID: <20170724172032.0a6623dc@gentoo.org> Organization: Gentoo X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/IGq9uD=//B19sHWXM4HQCWu" X-Archives-Salt: f6e3129c-9468-43db-828e-3b53d5dded5b X-Archives-Hash: 7236bde1555f2a47c8f1a9f8426e5710 --MP_/IGq9uD=//B19sHWXM4HQCWu Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline 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. --MP_/IGq9uD=//B19sHWXM4HQCWu Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=opam.eclass # Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @ECLASS: opam.eclass # @MAINTAINER: # Gentoo ML Project # @AUTHOR: # Alexis Ballier # @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=3D">=3Ddev-lang/ocaml-4:=3D" DEPEND=3D"${RDEPEND} dev-ml/opam" # @FUNCTION: opam-install # @USAGE: # @DESCRIPTION: # Installs the opam packages given as arguments. For each "${pkg}" element = in # that list, "${pkg}.install" must be readable from current working directo= ry. opam-install() { for pkg ; do opam-installer -i \ --prefix=3D"${ED}/usr" \ --libdir=3D"${D}/$(ocamlc -where)" \ --docdir=3D"${ED}/usr/share/doc/${PF}" \ --mandir=3D"${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 --MP_/IGq9uD=//B19sHWXM4HQCWu--