* [gentoo-dev] New eclass: opam.eclass
@ 2017-07-24 15:20 Alexis Ballier
2017-07-24 22:11 ` Aaron W. Swenson
2017-07-25 14:18 ` Michał Górny
0 siblings, 2 replies; 8+ messages in thread
From: Alexis Ballier @ 2017-07-24 15:20 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]
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.
[-- Attachment #2: opam.eclass --]
[-- Type: text/plain, Size: 1387 bytes --]
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: opam.eclass
# @MAINTAINER:
# Gentoo ML Project <ml@gentoo.org>
# @AUTHOR:
# Alexis Ballier <aballier@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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-24 15:20 [gentoo-dev] New eclass: opam.eclass Alexis Ballier
@ 2017-07-24 22:11 ` Aaron W. Swenson
2017-07-25 8:25 ` Alexis Ballier
2017-07-25 14:18 ` Michał Górny
1 sibling, 1 reply; 8+ messages in thread
From: Aaron W. Swenson @ 2017-07-24 22:11 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 318 bytes --]
On 2017-07-24 17:20, Alexis Ballier wrote:
> Hey,
>
> Here is an eclass that would allow me to factor quite a bit of
> redundant code.
>
> …
> if [ -d "${ED}/usr/share/doc/${PF}/${PN}" ] ; then
It’s always been recommended to me that we should use the [[ … ]] form.
Otherwise, looks good to me.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 376 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-24 22:11 ` Aaron W. Swenson
@ 2017-07-25 8:25 ` Alexis Ballier
2017-07-25 12:48 ` Peter Stuge
0 siblings, 1 reply; 8+ messages in thread
From: Alexis Ballier @ 2017-07-25 8:25 UTC (permalink / raw
To: gentoo-dev
On Mon, 24 Jul 2017 18:11:39 -0400
"Aaron W. Swenson" <titanofold@gentoo.org> wrote:
> On 2017-07-24 17:20, Alexis Ballier wrote:
> > Hey,
> >
> > Here is an eclass that would allow me to factor quite a bit of
> > redundant code.
> >
> > …
> > if [ -d "${ED}/usr/share/doc/${PF}/${PN}" ] ; then
>
> It’s always been recommended to me that we should use the [[ … ]]
> form.
Doesn't make much difference here and I've always been recommending the
other way :p
(the idea is that you don't get to write the [[ ]] in a /bin/sh script
just because you're used to it; if you only do ebuilds or bash, then
you don't care, but I definitely do other scripts)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-25 8:25 ` Alexis Ballier
@ 2017-07-25 12:48 ` Peter Stuge
2017-07-25 13:37 ` Michał Górny
0 siblings, 1 reply; 8+ messages in thread
From: Peter Stuge @ 2017-07-25 12:48 UTC (permalink / raw
To: gentoo-dev
Good work on the refactoring!
Alexis Ballier wrote:
> > > if [ -d "${ED}/usr/share/doc/${PF}/${PN}" ] ; then
> >
> > It’s always been recommended to me that we should use the [[ … ]]
> > form.
>
> Doesn't make much difference here
Some; you need neither quote nor {} in expansions within [[ ]]. So
instead of the above one could write:
if [[ -d $ED/usr/share/doc/$PF/$PN ]]; then
> and I've always been recommending the other way :p
..
> if you only do ebuilds or bash, then you don't care, but I definitely
> do other scripts
Be that as it may this is an eclass, and I think conforming to an
established coding style has significant value. I too have understood
that to be [[ ]].
Thanks
//Peter
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-25 12:48 ` Peter Stuge
@ 2017-07-25 13:37 ` Michał Górny
0 siblings, 0 replies; 8+ messages in thread
From: Michał Górny @ 2017-07-25 13:37 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 969 bytes --]
On wto, 2017-07-25 at 12:48 +0000, Peter Stuge wrote:
> Good work on the refactoring!
>
> Alexis Ballier wrote:
> > > > if [ -d "${ED}/usr/share/doc/${PF}/${PN}" ] ; then
> > >
> > > It’s always been recommended to me that we should use the [[ … ]]
> > > form.
> >
> > Doesn't make much difference here
>
> Some; you need neither quote nor {} in expansions within [[ ]]. So
> instead of the above one could write:
{} is completely irrelevant to [ ] vs [[ ]].
>
> if [[ -d $ED/usr/share/doc/$PF/$PN ]]; then
>
>
> > and I've always been recommending the other way :p
>
> ..
> > if you only do ebuilds or bash, then you don't care, but I definitely
> > do other scripts
>
> Be that as it may this is an eclass, and I think conforming to an
> established coding style has significant value. I too have understood
> that to be [[ ]].
...and ${}.
>
>
> Thanks
>
> //Peter
>
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 988 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-24 15:20 [gentoo-dev] New eclass: opam.eclass Alexis Ballier
2017-07-24 22:11 ` Aaron W. Swenson
@ 2017-07-25 14:18 ` Michał Górny
2017-08-02 10:09 ` Alexis Ballier
1 sibling, 1 reply; 8+ messages in thread
From: Michał Górny @ 2017-07-25 14:18 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1820 bytes --]
On pon, 2017-07-24 at 17:20 +0200, Alexis Ballier wrote:
> # Copyright 1999-2017 Gentoo Foundation
> # Distributed under the terms of the GNU General Public License v2
>
> # @ECLASS: opam.eclass
> # @MAINTAINER:
> # Gentoo ML Project <ml@gentoo.org>
> # @AUTHOR:
> # Alexis Ballier <aballier@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";;
Why not start straight with EAPI 6? You will have less to clean up
later.
> *) ;;
> 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() {
local pkg
> for pkg ; do
> opam-installer -i \
> --prefix="${ED}/usr" \
> --libdir="${D}/$(ocamlc -where)" \
> --docdir="${ED}/usr/share/doc/${PF}" \
> --mandir="${ED}/usr/share/man" \
Both ED and D include the trailing slash, so either remove the extra
slash or use ${ED%/}.
> "${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
Is PN always the correct subdirectory here?
> 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
--
Best regards,
Michał Górny
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 988 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-07-25 14:18 ` Michał Górny
@ 2017-08-02 10:09 ` Alexis Ballier
2017-08-02 10:27 ` Alexis Ballier
0 siblings, 1 reply; 8+ messages in thread
From: Alexis Ballier @ 2017-08-02 10:09 UTC (permalink / raw
To: gentoo-dev
On Tue, 25 Jul 2017 16:18:10 +0200
Michał Górny <mgorny@gentoo.org> wrote:
> On pon, 2017-07-24 at 17:20 +0200, Alexis Ballier wrote:
> > # Copyright 1999-2017 Gentoo Foundation
> > # Distributed under the terms of the GNU General Public License v2
> >
> > # @ECLASS: opam.eclass
> > # @MAINTAINER:
> > # Gentoo ML Project <ml@gentoo.org>
> > # @AUTHOR:
> > # Alexis Ballier <aballier@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";;
>
> Why not start straight with EAPI 6? You will have less to clean up
> later.
opam-based ebuilds are good with EAPI 6 but some other ocaml
eclasses are still waiting for patches from those deprecating
eclasses/features with EAPI6. So, EAPI5 is still the norm in ocaml
(it really is min for := though), and EAPI update can happen later, I'm
definitely not in a hurry to go for new EAPIs :)
>
> > *) ;;
> > 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() {
>
> local pkg
fixed
>
> > for pkg ; do
> > opam-installer -i \
> > --prefix="${ED}/usr" \
> > --libdir="${D}/$(ocamlc -where)" \
> > --docdir="${ED}/usr/share/doc/${PF}" \
> > --mandir="${ED}/usr/share/man" \
>
> Both ED and D include the trailing slash, so either remove the extra
> slash or use ${ED%/}.
thx, removed /
by the way, is there any technical reason to use ${ED%/} ?
as in, let the shell do it when the OS can probably do it much better ?
>
> > "${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
>
> Is PN always the correct subdirectory here?
yes because opam-install is called for $PN only here
for multiple packages in one ebuild that won't work well, that is why I
didn't include this in opam-install itself.
the idea with the eclass is to use it to split all opam based package to
have only 1 ebuild per corresponding opam package though
And pushed in a few minutes
Thanks!
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-dev] New eclass: opam.eclass
2017-08-02 10:09 ` Alexis Ballier
@ 2017-08-02 10:27 ` Alexis Ballier
0 siblings, 0 replies; 8+ messages in thread
From: Alexis Ballier @ 2017-08-02 10:27 UTC (permalink / raw
To: gentoo-dev
> >
> > > "${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
> >
> > Is PN always the correct subdirectory here?
>
> yes because opam-install is called for $PN only here
and guess what: $PN is not always the proper package name...
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-08-02 10:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-24 15:20 [gentoo-dev] New eclass: opam.eclass Alexis Ballier
2017-07-24 22:11 ` Aaron W. Swenson
2017-07-25 8:25 ` Alexis Ballier
2017-07-25 12:48 ` Peter Stuge
2017-07-25 13:37 ` Michał Górny
2017-07-25 14:18 ` Michał Górny
2017-08-02 10:09 ` Alexis Ballier
2017-08-02 10:27 ` Alexis Ballier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox