File ghc-persistent-template.spec of Package ghc-persistent-template
#
# spec file for package ghc-persistent-template
#
# Copyright (c) 2021 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 persistent-template
%global pkgver %{pkg_name}-%{version}
%bcond_with haddock
Name: ghc-%{pkg_name}
Version: 2.12.0.0
Release: 9.1
Summary: Type-safe, non-relational, multi-backend persistence
BuildArch: noarch
License: MIT
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-base-devel
BuildRequires: ghc-base-prof
BuildRequires: ghc-rpm-macros
ExcludeArch: %{ix86}
%description
Hackage documentation generation is not reliable. For up to date documentation,
please see: <http://www.stackage.org/package/persistent-template>.
%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
BuildArch: noarch
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
# Use explicit build steps to avoid passing the -fobject-determinism flag
# which is not supported by some GHC versions/architectures (e.g. aarch64).
# Enter the source directory. Prefer %{pkg_name}-%{version}, otherwise locate
# the directory that contains Setup.lhs/Setup.hs.
if [ -d %{pkg_name}-%{version} ]; then
cd %{pkg_name}-%{version}
else
for d in */ ; do
if [ -f "$d/Setup.lhs" -o -f "$d/Setup.hs" ]; then
cd "$d"
break
fi
done
fi
# Create small ghc wrapper(s) in the source dir that strip -fobject-determinism
# from arguments (packaging may append this flag). Prepend the source dir to
# PATH so Cabal/Setup uses these wrappers; ensure they call the real ghc.
REAL_GHC=$(command -v ghc)
GHCVER=$($REAL_GHC --numeric-version 2>/dev/null || true)
WRAPPERS="ghc"
if [ -n "$GHCVER" ]; then
WRAPPERS="$WRAPPERS ghc-$GHCVER"
fi
for name in $WRAPPERS; do
cat > ./"$name" <<'__EOF'
#!/bin/sh
REAL_GHC="__REAL_GHC__"
newargs=
for arg in "$@"; do
case "$arg" in
-fobject-determinism|-fobject-determinism=*) ;;
*-fobject-determinism*)
# remove all occurrences of -fobject-determinism inside the argument
cleaned=$(printf "%s" "$arg" | sed -e 's/-fobject-determinism//g' -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ *//; s/ *$//')
if [ -n "$cleaned" ]; then
newargs="$newargs \"$cleaned\""
fi
;;
*) newargs="$newargs \"$arg\"" ;;
esac
done
# shellcheck disable=SC2086
eval exec "$REAL_GHC" $newargs
__EOF
sed -i "s|__REAL_GHC__|$REAL_GHC|" ./"$name"
chmod +x ./"$name"
done
export PATH="$PWD:$PATH"
# Build Setup program. Compile it to Setup.real and use a wrapper script
# named Setup that strips any -fobject-determinism occurrences from the
# configure/build arguments (handles both separate flags and those inside
# --ghc-options=...). This ensures the compiled Setup.real never receives
# the unsupported flag.
if [ -f Setup.lhs -o -f Setup.hs ]; then
ghc --make -o Setup.real -package Cabal -no-user-package-db -dynamic Setup
cat > ./Setup <<'__SETUP_WRAPPER__'
#!/bin/sh
newargs=
for arg in "$@"; do
case "$arg" in
-fobject-determinism|-fobject-determinism=*) ;;
--ghc-options=*)
val="${arg#--ghc-options=}"
cleaned=$(printf "%s" "$val" | sed -e 's/-fobject-determinism//g' -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ *//; s/ *$//')
if [ -n "$cleaned" ]; then
newargs="$newargs --ghc-options=$cleaned"
fi
;;
*-fobject-determinism*)
# catch any other combined occurrences
cleaned=$(printf "%s" "$arg" | sed -e 's/-fobject-determinism//g' -e 's/[[:space:]][[:space:]]*/ /g' -e 's/^ *//; s/ *$//')
if [ -n "$cleaned" ]; then
newargs="$newargs \"$cleaned\""
fi
;;
*) newargs="$newargs \"$arg\"" ;;
esac
done
# shellcheck disable=SC2086
eval exec "$PWD/Setup.real" $newargs
__SETUP_WRAPPER__
chmod +x ./Setup
# Configure without -fobject-determinism, keep other ghc options
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-9.10.2/lib --global '--ghc-options=-fhide-source-paths ' -v \
--enable-library-profiling --enable-shared \
--htmldir=/usr/share/doc/packages/ghc-9.10.2/html/libraries/persistent-template-2.12.0.0 --global
./Setup build
fi
%install
%ghc_lib_install -m
%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