File ghc-email-validate.spec of Package ghc-email-validate
#
# spec file for package ghc-email-validate
#
# 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 email-validate
%global pkgver %{pkg_name}-%{version}
%bcond_with tests
Name: ghc-%{pkg_name}
Version: 2.3.2.21
Release: 1.1
Summary: Email address validation
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-attoparsec-devel
BuildRequires: ghc-attoparsec-prof
BuildRequires: ghc-base-devel
BuildRequires: ghc-base-prof
BuildRequires: ghc-bytestring-devel
BuildRequires: ghc-bytestring-prof
BuildRequires: ghc-rpm-macros
BuildRequires: ghc-template-haskell-devel
BuildRequires: ghc-template-haskell-prof
ExcludeArch: %{ix86}
%if %{with tests}
BuildRequires: ghc-QuickCheck-devel
BuildRequires: ghc-QuickCheck-prof
BuildRequires: ghc-hspec-devel
BuildRequires: ghc-hspec-prof
%endif
%description
Validating an email address string against RFC 5322.
%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}
sed -i 's/\r//g' LICENSE
%build
# Build without passing -fobject-determinism which is not supported by some ghc versions
# We replicate the essential behavior of %ghc_lib_build but avoid the unsupported flag.
# Create small ghc wrappers that strip unsupported -fobject-determinism from arguments
mkdir -p localbin
cat > localbin/ghc <<'EOF'
#!/bin/sh
# wrapper to filter out -fobject-determinism and other Setup-only options
filtered_args=""
for a in "$@"; do
# drop Setup-specific --ghc-options=... entirely (they are meant for Setup, not ghc)
case "$a" in
--ghc-options=*|--ghc-options) continue ;;
esac
# remove occurrences of the flag from other arguments
cleaned=$(printf '%s' "$a" | sed 's/-fobject-determinism//g; s/ */ /g')
# skip empty results
case "$cleaned" in
"") continue ;;
esac
# escape double quotes for safe eval later
esc=$(printf '%s' "$cleaned" | sed 's/"/\\"/g')
filtered_args="$filtered_args \"$esc\""
done
# exec real ghc with filtered args
# shellcheck disable=SC2086
eval "exec /usr/bin/ghc $filtered_args"
EOF
cat > localbin/ghc-%{ghc_version} <<'EOF'
#!/bin/sh
# wrapper for versioned ghc name (e.g. ghc-9.10.2)
filtered_args=""
for a in "$@"; do
case "$a" in
--ghc-options=*|--ghc-options) continue ;;
esac
cleaned=$(printf '%s' "$a" | sed 's/-fobject-determinism//g; s/ */ /g')
case "$cleaned" in
"") continue ;;
esac
esc=$(printf '%s' "$cleaned" | sed 's/"/\\"/g')
filtered_args="$filtered_args \"$esc\""
done
# shellcheck disable=SC2086
eval "exec /usr/bin/ghc $filtered_args"
EOF
chmod +x localbin/ghc localbin/ghc-%{ghc_version}
export PATH="$PWD/localbin:$PATH"
ghc --make -package Cabal -no-user-package-db -dynamic Setup
LANG=C.utf8
./Setup configure --prefix=/usr --libdir=/usr/lib64 --docdir=/usr/share/licenses/ghc-email-validate '--libsubdir=$compiler/lib/$pkgid' '--datasubdir=$pkgid' '--libexecsubdir=$pkgid' --ghc --dynlibdir=/usr/lib64/ghc-%{ghc_version}/lib --global '--ghc-options=-fhide-source-paths' -v --enable-library-profiling --enable-shared --htmldir=/usr/share/doc/packages/ghc-%{ghc_version}/html/libraries/%{pkg_name}-%{version} --global
./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
%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