File ghc-attoparsec-aeson.spec of Package ghc-attoparsec-aeson
#
# spec file for package ghc-attoparsec-aeson
#
# 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 attoparsec-aeson
%global pkgver %{pkg_name}-%{version}
Name: ghc-%{pkg_name}
Version: 2.2.2.0
Release: 0
Summary: Parsing of aeson's Value with attoparsec
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
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-aeson-devel
BuildRequires: ghc-aeson-prof
BuildRequires: ghc-attoparsec-devel
BuildRequires: ghc-attoparsec-prof
BuildRequires: ghc-base-devel
BuildRequires: ghc-base-prof
BuildRequires: ghc-bytestring-devel
BuildRequires: ghc-bytestring-prof
BuildRequires: ghc-character-ps-devel
BuildRequires: ghc-character-ps-prof
BuildRequires: ghc-integer-conversion-devel
BuildRequires: ghc-integer-conversion-prof
BuildRequires: ghc-primitive-devel
BuildRequires: ghc-primitive-prof
BuildRequires: ghc-rpm-macros
BuildRequires: ghc-scientific-devel
BuildRequires: ghc-scientific-prof
BuildRequires: ghc-text-devel
BuildRequires: ghc-text-prof
BuildRequires: ghc-vector-devel
BuildRequires: ghc-vector-prof
ExcludeArch: %{ix86}
%description
Parsing of aeson's Value with attoparsec, originally from aeson.
%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}
%build
# Workaround: ghc-rpm-macros currently pass an unsupported GHC flag
# Filter out -fobject-determinism which ghc-9.10 does not recognise
cat > ghc-wrapper << 'EOF'
#!/bin/sh
# Filter out unsupported GHC flags and delegate to the real ghc
args=""
for a in "$@"; do
if [ "$a" = "-fobject-determinism" ]; then
continue
fi
# quote each arg safely
esc=$(printf %s "$a" | sed "s/'/'\\''/g")
args="$args '$esc'"
done
# Use eval to pass the reconstructed arguments safely
eval exec /usr/bin/ghc $args
EOF
chmod +x ghc-wrapper
# Ensure our wrapper is found before /usr/bin in PATH
export PATH=$PWD:$PATH
# Provide wrappers for both ghc and version-suffixed ghc binary names
ln -sf ghc-wrapper ghc
ln -sf ghc-wrapper ghc-9.10
ln -sf ghc-wrapper ghc-9.10.2
# Manually build using Setup to avoid passing unsupported -fobject-determinism
# Compile Setup
ghc --make -package Cabal -no-user-package-db -dynamic Setup
# Configure without the problematic ghc-options
./Setup configure \
--prefix=/usr \
--libdir=%{_libdir} \
'--libsubdir=$compiler/lib/$pkgid' \
'--datasubdir=$pkgid' \
'--libexecsubdir=$pkgid' \
--ghc \
--dynlibdir=%{_libdir}/ghc-%{ghc_version}/lib \
--global \
-v \
--enable-library-profiling \
--enable-shared \
--docdir=/usr/share/licenses/%{name} \
--htmldir=%{_docdir}/packages/ghc-%{ghc_version}/html/libraries/%{pkg_name}-%{version} \
--global
# Build
./Setup build -v
%install
%ghc_lib_install
%post devel
%ghc_pkg_recache
%postun devel
%ghc_pkg_recache
%files -f %{name}.files
%license LICENSE
%files devel -f %{name}-devel.files
%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