backport various recent improvements from rawhide

- split ghc.attr into ghc_lib.attr and ghc_bin.attr for finer grained handling
- require ghc-compiler for ghc_version
- macros.ghc: cabal_configure now passes CFLAGS and LDFLAGS to ghc (#1138982)
  (thanks to Sergei Trofimovich and Ville Skyttä)
- ghc-deps.sh: support ghc-pkg for ghc build <= 7.4.2 as well
This commit is contained in:
Jens Petersen 2014-11-14 18:27:31 +09:00
parent b154c1ea88
commit afcae244ac
6 changed files with 40 additions and 18 deletions

View File

@ -1,11 +1,6 @@
#!/bin/sh
# find rpm provides and requires for Haskell GHC libraries
# To use add the following lines to spec file:
# %define _use_internal_dependency_generator 0
# %define __find_requires /usr/lib/rpm/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
# %define __find_provides /usr/lib/rpm/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
[ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
set +x
@ -15,11 +10,21 @@ PKGBASEDIR=$2
PKGCONFDIR=$PKGBASEDIR/package.conf.d
GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//)
if [ -x "$PKGBASEDIR/bin/ghc-pkg" ]; then
# ghc-7.8
GHC_PKG="$PKGBASEDIR/bin/ghc-pkg --global-package-db=$PKGCONFDIR"
elif [ -x "$PKGBASEDIR/ghc-pkg" ]; then
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-package-db=$PKGCONFDIR"
# for a ghc build use the new ghc-pkg
INPLACE_GHCPKG=$PKGBASEDIR/../../bin/ghc-pkg-$GHC_VER
if [ -x "$INPLACE_GHCPKG" ]; then
case $GHC_VER in
7.8.*)
GHC_PKG="$PKGBASEDIR/bin/ghc-pkg --global-package-db=$PKGCONFDIR"
;;
7.6.*)
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-package-db=$PKGCONFDIR"
;;
*)
GHC_PKG="$PKGBASEDIR/ghc-pkg --global-conf=$PKGCONFDIR"
;;
esac
else
GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER}"
fi

View File

@ -6,7 +6,7 @@
#%%global without_hscolour 1
Name: ghc-rpm-macros
Version: 1.2.16
Version: 1.2.17
Release: 1%{?dist}
Summary: RPM macros for building packages for GHC
@ -24,10 +24,13 @@ Source3: ghc-deps.sh
Source4: cabal-tweak-dep-ver
Source5: cabal-tweak-flag
Source6: macros.ghc-extra
Source7: ghc.attr
Source7: ghc_bin.attr
Source8: ghc_lib.attr
Requires: ghc-srpm-macros
# macros.ghc-srpm moved out from redhat-rpm-config-21
Requires: redhat-rpm-config > 20-1.fc21
# for ghc_version
Requires: ghc-compiler
%if %{undefined without_hscolour}
%ifarch %{ix86} %{ix86} x86_64 ppc ppc64 alpha sparcv9 armv7hl armv5tel s390 s390x ppc64le aarch64
Requires: hscolour
@ -67,7 +70,8 @@ install -p -D -m 0644 %{SOURCE0} %{buildroot}/%{macros_dir}/macros.ghc
install -p -D -m 0644 %{SOURCE6} %{buildroot}/%{macros_dir}/macros.ghc-extra
install -p -D -m 0755 %{SOURCE3} %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh
install -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc.attr
install -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_bin.attr
install -p -D -m 0644 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr
install -p -D -m 0755 %{SOURCE4} %{buildroot}/%{_bindir}/cabal-tweak-dep-ver
install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag
@ -86,7 +90,8 @@ EOF
%files
%doc COPYING AUTHORS
%{macros_dir}/macros.ghc
%{_prefix}/lib/rpm/fileattrs/ghc.attr
%{_prefix}/lib/rpm/fileattrs/ghc_bin.attr
%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr
%{_prefix}/lib/rpm/ghc-deps.sh
%{_bindir}/cabal-tweak-dep-ver
%{_bindir}/cabal-tweak-flag
@ -97,6 +102,13 @@ EOF
%changelog
* Fri Nov 14 2014 Jens Petersen <petersen@redhat.com> - 1.2.17-1
- split ghc.attr into ghc_lib.attr and ghc_bin.attr for finer grained handling
- require ghc-compiler for ghc_version
- macros.ghc: cabal_configure now passes CFLAGS and LDFLAGS to ghc (#1138982)
(thanks to Sergei Trofimovich and Ville Skyttä)
- ghc-deps.sh: support ghc-pkg for ghc build <= 7.4.2 as well
* Thu Oct 16 2014 Jens Petersen <petersen@redhat.com> - 1.2.16-1
- ghc.attr needs to handle requires for /usr/bin files too

View File

@ -1,3 +0,0 @@
%__ghc_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
%__ghc_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
%__ghc_path ^%{ghclibdir}/.*/libHS.*\\.(so|a)$ || ^%{_bindir}/.*

3
ghc_bin.attr Normal file
View File

@ -0,0 +1,3 @@
%__ghc_bin_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
%__ghc_bin_magic executable, .* dynamically linked
%__ghc_bin_flags exeonly

3
ghc_lib.attr Normal file
View File

@ -0,0 +1,3 @@
%__ghc_lib_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}
%__ghc_lib_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}
%__ghc_lib_path ^%{ghclibdir}/.*/libHS.*\\.(so|a)$

View File

@ -21,7 +21,9 @@ fi
# configure
%cabal_configure\
%ghc_check_bootstrap\
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} %{?cabal_configure_options} $cabal_configure_extra_options
CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS\
LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS\
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} --ghc-options="$(echo ' '$CFLAGS | sed -e 's/ / -optc/g') $(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')" %{?cabal_configure_options} $cabal_configure_extra_options
# install
%cabal_install %cabal copy --destdir=%{buildroot} -v