File ghc-config-ini.spec of Package ghc-config-ini

#
# spec file for package ghc-config-ini
#
# Copyright (c) 2024 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 config-ini
%global pkgver %{pkg_name}-%{version}
%bcond_with tests
Name:           ghc-%{pkg_name}
Version:        0.2.7.0
Release:        1.1
Summary:        A library for simple INI-based configuration files
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-containers-devel
BuildRequires:  ghc-containers-prof
BuildRequires:  ghc-megaparsec-devel
BuildRequires:  ghc-megaparsec-prof
BuildRequires:  ghc-rpm-macros
BuildRequires:  ghc-text-devel
BuildRequires:  ghc-text-prof
BuildRequires:  ghc-transformers-devel
BuildRequires:  ghc-transformers-prof
BuildRequires:  ghc-unordered-containers-devel
BuildRequires:  ghc-unordered-containers-prof
ExcludeArch:    %{ix86}
%if %{with tests}
BuildRequires:  ghc-directory-devel
BuildRequires:  ghc-directory-prof
BuildRequires:  ghc-hedgehog-devel
BuildRequires:  ghc-hedgehog-prof
BuildRequires:  ghc-ini-devel
BuildRequires:  ghc-ini-prof
%endif

%description
The \\\'config-ini\\\' library is a set of small monadic languages for writing simple
configuration languages with convenient, human-readable error messages.

> parseConfig :: IniParser (Text, Int, Bool) > parseConfig = section "NETWORK"
$ do > user <- field "user" > port <- fieldOf "port" number > enc <-
fieldFlagDef "encryption" True > return (user, port, enc).

%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
# Use %setup to reliably create the expected source directory name
%setup -q -n %{pkg_name}-%{version}
cp -p %{SOURCE1} %{pkg_name}.cabal

%build
# Use a manual configure/build to avoid passing the -fobject-determinism GHC
# option which is not recognised by some GHC versions (causes build failure).
# Enter source directory if present; otherwise try to continue anyway.
if [ -d %{pkg_name}-%{version} ]; then
  cd %{pkg_name}-%{version}
fi
cp /usr/share/ghc-rpm-macros/Setup.hs . || true
if [ ! -x Setup ]; then
  ghc --make -package Cabal -no-user-package-db -dynamic Setup || true
fi
# If a compiled Setup exists, wrap it with a small script that filters out
# the unsupported -fobject-determinism flag from any --ghc-options passed
# (some ghc-rpm-macros variants add that flag globally).
if [ -x Setup ]; then
  mv Setup Setup.real
  cat > Setup <<'EOF'
#!/bin/sh
# Remove -fobject-determinism from --ghc-options and standalone flags
newargs=""
for arg in "$@"; do
  case "$arg" in
    --ghc-options=*)
      opts="${arg#--ghc-options=}"
      # remove occurrences of -fobject-determinism
      opts="$(printf '%s' "$opts" | sed 's/-fobject-determinism//g')"
      # trim leading/trailing whitespace
      opts="$(printf '%s' "$opts" | awk '{$1=$1; print}')"
      newargs="$newargs --ghc-options=$opts"
      ;;
    -fobject-determinism)
      # skip this flag entirely
      ;;
    *)
      # preserve other args (quote them)
      newargs="$newargs \"$arg\""
      ;;
  esac
done
# Execute the real Setup with filtered arguments
eval "exec \"$PWD/Setup.real\" $newargs"
EOF
  chmod +x Setup
fi
LANG=C.utf8
./Setup configure --prefix=/usr --libdir=/usr/lib64 --docdir=/usr/share/licenses/%{name} '--libsubdir=$compiler/lib/$pkgid' '--datasubdir=$pkgid' '--libexecsubdir=$pkgid' --ghc --dynlibdir=/usr/lib64/ghc-%{ghc_version}/lib '--ghc-options=-fhide-source-paths  ' -v --enable-library-profiling --enable-shared --htmldir=/usr/share/doc/packages/ghc-%{ghc_version}/html/libraries/%{pkg_name}-%{version}
./Setup build

%install
%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