File ghc-cryptonite-conduit.spec of Package ghc-cryptonite-conduit

#
# spec file for package ghc-cryptonite-conduit
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%global pkg_name cryptonite-conduit
%global pkgver %{pkg_name}-%{version}
%bcond_with tests
%global ghc_options -fhide-source-paths
Name:           ghc-%{pkg_name}
Version:        0.2.2
Release:        0
Summary:        Cryptonite conduit
License:        BSD-3-Clause
URL:            https://hackage.haskell.org/package/%{pkg_name}
Source0:        https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
Source1:        https://hackage.haskell.org/package/%{pkg_name}-%{version}/revision/1.cabal#/%{pkg_name}.cabal
BuildRequires:  ghc-Cabal-devel
BuildRequires:  ghc-base-devel
BuildRequires:  ghc-base-prof
BuildRequires:  ghc-bytestring-devel
BuildRequires:  ghc-bytestring-prof
BuildRequires:  ghc-conduit-devel
BuildRequires:  ghc-conduit-extra-devel
BuildRequires:  ghc-conduit-extra-prof
BuildRequires:  ghc-conduit-prof
BuildRequires:  ghc-cryptonite-devel
BuildRequires:  ghc-cryptonite-prof
BuildRequires:  ghc-exceptions-devel
BuildRequires:  ghc-exceptions-prof
BuildRequires:  ghc-memory-devel
BuildRequires:  ghc-memory-prof
BuildRequires:  ghc-resourcet-devel
BuildRequires:  ghc-resourcet-prof
BuildRequires:  ghc-rpm-macros
BuildRequires:  ghc-transformers-devel
BuildRequires:  ghc-transformers-prof
ExcludeArch:    %{ix86}
%if %{with tests}
BuildRequires:  ghc-conduit-combinators-devel
BuildRequires:  ghc-conduit-combinators-prof
BuildRequires:  ghc-tasty-devel
BuildRequires:  ghc-tasty-hunit-devel
BuildRequires:  ghc-tasty-hunit-prof
BuildRequires:  ghc-tasty-prof
BuildRequires:  ghc-tasty-quickcheck-devel
BuildRequires:  ghc-tasty-quickcheck-prof
%endif

%description
Conduit bridge for cryptonite

For now only provide a conduit version for hash and hmac, but with
contribution, this could provide cipher conduits too, and probably other
things.

%package devel
Summary:        Haskell %{pkg_name} library development files
Requires:       %{name} = %{version}-%{release}
Requires:       ghc-compiler = %{ghc_version}
Requires(post): ghc-compiler = %{ghc_version}
Requires(postun): ghc-compiler = %{ghc_version}

%description devel
This package provides the Haskell %{pkg_name} library development
files.

%package -n ghc-%{pkg_name}-doc
Summary:        Haskell %{pkg_name} library documentation
Requires:       ghc-filesystem
BuildArch:      noarch

%description -n ghc-%{pkg_name}-doc
This package provides the Haskell %{pkg_name} library documentation.

%package -n ghc-%{pkg_name}-prof
Summary:        Haskell %{pkg_name} profiling library
Requires:       ghc-%{pkg_name}-devel = %{version}-%{release}
Supplements:    (ghc-%{pkg_name}-devel and ghc-prof)

%description -n ghc-%{pkg_name}-prof
This package provides the Haskell %{pkg_name} profiling library.

%prep
%autosetup -n %{pkg_name}-%{version}
cp -p %{SOURCE1} %{pkg_name}.cabal

%build
# Use an explicit build sequence to avoid passing -fobject-determinism to ghc
# which some ghc versions (used on aarch64) do not recognize.
if [ -f Setup.hs -o -f Setup.lhs ]; then
  ghc --make -package Cabal -no-user-package-db -dynamic Setup
fi
LANG=C.utf8
# Configure without the -fobject-determinism flag; keep -fhide-source-paths
./Setup configure --prefix=/usr --libdir=/usr/lib64 --ghc --global "--ghc-options=-fhide-source-paths" -v --enable-library-profiling --enable-shared --global
./Setup build

%install
# Use Setup copy to install into the buildroot. Do not use %ghc_lib_install which
# assumes a specific ghc libdir layout; on aarch64 cabal places files in
# architecture-specific libdirs (e.g. /usr/lib64/aarch64-linux-ghc-9.x.y-...),
# so perform a direct copy to the buildroot to match the files produced by Cabal.
if [ -x Setup ]; then
  LANG=C.utf8
  ./Setup copy --destdir=%{buildroot} -v
fi

# Bring any generated package .conf files from the destination into the
# build directory so that the downstream packaging helper (%ghc_lib_install)
# can find and install them. Cabal writes the .conf files relative to the
# destdir we passed above, so copy them back into the current source
# directory for the packaging macros to consume.
find "%{buildroot}" -type f -path "*/package.conf.d/*.conf" -print0 | \
  while IFS= read -r -d '' f; do
    cp -a "$f" .
done

# Create a compatibility ghc libdir layout expected by the rpm helper scripts.
# Some packaging logic expects libraries in /usr/lib64/ghc-<version>/lib,
# but Cabal on multi-arch installs into /usr/lib64/<arch>-linux-ghc-<version>-<hash>/...
# Copy the produced GHC library artifacts into the compat path so the rest
# of the %install processing can find them.
compat_libdir="%{buildroot}/usr/lib64/ghc-%{ghc_version}/lib"
mkdir -p "$compat_libdir"
# Copy any built libHScryptonite-conduit artifacts (.so, .a, .p_hi, .hi, .dyn_hi)
find "%{buildroot}" -type f -name 'libHScryptonite-conduit-*' -print0 | \
  while IFS= read -r -d '' f; do
    cp -a "$f" "$compat_libdir/"
  done

# Delegate remaining installation steps (package.conf.d etc.) to the standard
# GHC packaging macro which knows how to handle the generated .conf files and
# other GHC-specific installation details.
%ghc_lib_install

%check
%cabal_test

%post devel
%ghc_pkg_recache

%postun devel
%ghc_pkg_recache

%files -f %{name}.files
%license LICENSE

%files devel -f %{name}-devel.files
%doc CHANGELOG.md README.md

%files -n ghc-%{pkg_name}-doc -f ghc-%{pkg_name}-doc.files
%license LICENSE

%files -n ghc-%{pkg_name}-prof -f ghc-%{pkg_name}-prof.files

%changelog
openSUSE Build Service is sponsored by