## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%undefine _package_note_flags
Name:           opam
Version:        2.1.3
Release:        %autorelease
Summary:        Source-based package manager for OCaml

License:        LGPL-2.1-only WITH OCaml-LGPL-linking-exception
URL:            https://github.com/ocaml/opam
Source0:        https://github.com/ocaml/opam/archive/%{version}/%{name}-%{version}.tar.gz
# Debian patch to port to dose3 version 6 and later
# https://sources.debian.org/patches/opam/2.0.8-1/0005-Port-to-Dose3-6.0.1.patch/
Patch0:         %{name}-port-to-dose3-6.0.1.patch
# Adapt to the removal of Base64 from extlib
Patch1:         %{name}-base64.patch

BuildRequires:  make
BuildRequires:  ocaml >= 4.02.3
BuildRequires:  ocaml-dune
BuildRequires:  ocaml-findlib

BuildRequires:  ocaml-cmdliner-devel
BuildRequires:  ocaml-cppo
BuildRequires:  ocaml-ocamlgraph-devel
BuildRequires:  ocaml-re-devel
BuildRequires:  ocaml-cudf-devel
BuildRequires:  ocaml-opam-file-format-devel
BuildRequires:  ocaml-base64-devel
BuildRequires:  ocaml-dose3-devel
BuildRequires:  ocaml-extlib-devel
BuildRequires:  ocaml-mccs-devel
BuildRequires:  ocaml-z3-devel

BuildRequires:  git
BuildRequires:  gcc-c++
BuildRequires:  bzip2
BuildRequires:  diffutils
BuildRequires:  libacl-devel

# Needed to install packages and run opam init.
Requires:       bubblewrap
Requires:       bzip2
Requires:       diffutils
Requires:       gcc
Requires:       gzip
Requires:       make
Requires:       m4
Requires:       patch
Requires:       unzip
Requires:       tar

Requires:       opam-installer%{?_isa} = %{version}-%{release}

%description
Opam is a source-based package manager for OCaml. It supports multiple
simultaneous compiler installations, flexible package constraints, and
a Git-friendly development workflow.

%package installer
Summary:        Standalone script for opam install files

%description installer
Standalone script for working with opam .install files, see the opam
package for more information.

%prep
%autosetup -p1 -n %{name}-%{version}

%build
%configure
export DUNE_ARGS="--verbose"
# Need to set the path so Makefile can run the opam command.
export PATH=$PWD:$PATH

# Parallel build does not succeed.
make

%install
export DUNE_ARGS="--verbose"
export PATH=$PWD:$PATH

# The makefile looks like it tries to invoke ocamlfind but only if DESTDIR
# isn't set. If it is set (which it is) LIBINSTALLDIR must be set too
# for installing opam-installer metadata.
%make_install

# However it looks like some (extra) documentation gets
# installed in the wrong place so... delete it.
rm -rf %{buildroot}%{_prefix}/doc

# It seems that some tests fail under mock.
# I am not sure why at the moment. So for now I'll just turn them off.
#%%check
#make tests

%files
%license LICENSE
%{_bindir}/opam
%exclude %{_mandir}/man1/opam-installer.1*
%{_mandir}/man1/*.1*

%files installer
%license LICENSE
# Upstream puts this documentation under opam-installer, not opam.
# Since I have opam require opam-installer anyway, this seems reasonable.
# (And there are lots of man pages in the opam package, so it has docs).
%doc README.md CHANGES AUTHORS CONTRIBUTING.md
%{_bindir}/opam-installer
%{_mandir}/man1/opam-installer.1*

%changelog
* Tue Sep 20 2022 Jerry James <loganjerry@gmail.com> 2.1.3-3
- Rebuild for ocaml-cmdliner 1.1.1

* Sat Aug 20 2022 Jerry James <loganjerry@gmail.com> 2.1.3-2
- Bump and rebuild to fix z3 dependency in F37

* Sat Aug 20 2022 Robin Lee <cheeselee@fedoraproject.org> 2.1.3-1
- Version 2.1.3 (RHBZ#2117903)

* Fri Aug 19 2022 Jerry James <loganjerry@gmail.com> 2.1.2-7
- Rebuild for z3 4.11.0.  Convert License tag to SPDX.

* Mon Aug 08 2022 Jerry James <loganjerry@gmail.com> 2.1.2-6
- Rebuild for z3 4.10.2

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.1.2-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Sun Jun 19 2022 Richard W.M. Jones <rjones@redhat.com> 2.1.2-4
- local build

* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> 2.1.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Fri Dec 31 2021 Jerry James <loganjerry@gmail.com> 2.1.2-2
- Rebuild for ocaml-zip 1.11

* Sat Dec 18 2021 Robin Lee <cheeselee@fedoraproject.org> 2.1.2-1
- Version 2.1.2 (RHBZ#2030270)

* Sat Nov 06 2021 Robin Lee <cheeselee@fedoraproject.org> 2.1.1-1
- New release (RHBZ#2019288, RHBZ#2020451)

* Tue Oct 05 2021 Richard W.M. Jones <rjones@redhat.com> 2.1.0-3
- OCaml 4.13.1 build

* Fri Aug 27 2021 Jerry James <loganjerry@gmail.com> - 2.1.0-1
- Version 2.1.0
- Drop upstreamed makefile patch
- Add patch to use ocaml-base64 due to lack of base64 support in extlib
- Add debian patch to adapt to dose3 6.0.1+
- Build with bzip2, libacl, and z3 support

* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Mon Mar  1 21:51:49 GMT 2021 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-12
- OCaml 4.12.0 build

* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Tue Sep 01 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-10
- OCaml 4.11.1 rebuild

* Fri Aug 21 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-9
- OCaml 4.11.0 rebuild

* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-8
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sat May 30 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-6
- Rebuild for updated ocaml-extlib (RHBZ#1837823).

* Tue May 05 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-5
- OCaml 4.11.0+dev2-2020-04-22 rebuild

* Wed Apr 22 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-4
- OCaml 4.11.0 pre-release attempt 2

* Sat Apr 04 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-3
- Update all OCaml dependencies for RPM 4.16.

* Thu Feb 27 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.6-2
- OCaml 4.10.0 final.

* Fri Feb 07 2020 Ben Rosser <rosser.bjr@gmail.com> - 2.0.6-1
- Update to version 2.0.6.

* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Sun Jan 19 2020 Richard W.M. Jones <rjones@redhat.com> - 2.0.5-3
- OCaml 4.10.0+beta1 rebuild.

* Fri Aug 16 2019 Richard W.M. Jones <rjones@redhat.com> - 2.0.5-2
- OCaml 4.08.1 (final) rebuild.

* Wed Aug 07 2019 Ben Rosser <rosser.bjr@gmail.com> - 2.0.5-1
- Update to latest upstream release.
- dune switch "-p" infers "--profile release", so remove it from JBUILDER_ARGS.

* Thu Aug 01 2019 Richard W.M. Jones <rjones@redhat.com> - 2.0.1-4
- OCaml 4.08.1 (rc2) rebuild.
- Miscellaneous build fixes to disable warnings.

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Thu Nov 01 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.1-1
- Updated to latest upstream release (rhbz#1643738).

* Wed Oct 24 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-4
- Add requires on make and m4 for opam init setup.

* Tue Oct 02 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-3
- Add Requires on bubblewrap, gcc as well.

* Sat Sep 22 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-2
- Add missing Requires on patch, unzip (rhbz#1631969).

* Wed Aug 22 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-1
- Updated to opam 2.0.0 final release!

* Tue Aug 21 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.9.rc1
- Updated to opam 2.0 rc1.
- Fix FTBFS on Fedora 29/Rawhide.

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-0.8.beta6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Apr 30 2018 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.7.beta6
- Add missing dependency on bzip2 (#1572862).

* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-0.6.beta6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Wed Dec 13 2017 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.5.beta6
- Update to beta6, with a few fixes from beta5.

* Mon Dec 04 2017 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.4.beta5
- Add upstream patch correctly indicating LGPLv2 license of a few files.

* Tue Nov 28 2017 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.3.beta5
- Updated to latest upstream release.
- Split opam-installer out as a subpackage.

* Mon Oct 02 2017 Ben Rosser <rosser.bjr@gmail.com> - 2.0.0-0.2.beta4
- Updated to latest upstream release.

* Tue Aug 15 2017 Ben Rosser <rosser.bjr@gmail.com> 2.0.0-0.1.beta31
- Initial package.