add ghc-info.sh to handle hadrian %ghclibdir/lib

This commit is contained in:
Jens Petersen 2022-09-15 20:37:21 +08:00
parent 1e680edbc7
commit acff114c1d
3 changed files with 19 additions and 4 deletions

8
ghc-info.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
[ $# -lt 2 ] && echo "Usage: $(basename "$0") GHCVERSION INFOFIELD"
GHCVER=$1
FIELD=$2
/usr/bin/ghc-${GHCVER} --info | grep \"$FIELD\" | sed -e 's/.*","\(.*\)")/\1/'

View File

@ -7,7 +7,7 @@
%endif
Name: ghc-rpm-macros
Version: 2.4.5
Version: 2.5.0
Release: 1%{?dist}
Summary: RPM macros for building Haskell packages for GHC
@ -27,6 +27,7 @@ Source9: macros.ghc-os
Source10: Setup.hs
Source11: cabal-tweak-drop-dep
Source12: cabal-tweak-remove-upperbound
Source13: ghc-info.sh
Requires: redhat-rpm-config
# ghc_version needs ghc-compiler or ghcX.Y-compiler-default
Requires: chrpath
@ -131,6 +132,7 @@ install -p -D -m 0644 %{SOURCE6} %{buildroot}%{macros_dir}/macros.ghc-extra
install -p -D -m 0644 %{SOURCE9} %{buildroot}%{macros_dir}/macros.ghc-os
install -p -D -m 0755 %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/ghc-deps.sh
install -p -D -m 0755 %{SOURCE13} %{buildroot}%{_prefix}/lib/rpm/ghc-info.sh
%if 0%{?fedora} || 0%{?rhel} >= 7
install -p -D -m 0644 %{SOURCE7} %{buildroot}%{_prefix}/lib/rpm/fileattrs/ghc.attr
@ -165,6 +167,7 @@ EOF
%{_prefix}/lib/rpm/fileattrs/ghc.attr
%endif
%{_prefix}/lib/rpm/ghc-deps.sh
%{_prefix}/lib/rpm/ghc-info.sh
%{_prefix}/lib/rpm/ghc-pkg-wrapper
%{_bindir}/cabal-tweak-dep-ver
%{_bindir}/cabal-tweak-drop-dep
@ -193,9 +196,10 @@ EOF
%changelog
* Thu Sep 15 2022 Jens Petersen <petersen@redhat.com> - 2.4.5-1
* Thu Sep 15 2022 Jens Petersen <petersen@redhat.com> - 2.5.0-1
- define ghc_smp_mflags to speed up package builds
- ghc_configure and ghc_version now respect ghc_name for ghcX.Y (via rpmquery)
- add ghc-info.sh to read fields from ghc --info
* Sat Aug 6 2022 Jens Petersen <petersen@redhat.com> - 2.4.4-2
- F36 obsoletes regex-applicative-text

View File

@ -30,8 +30,11 @@ export LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"\
if ! [ -f Setup.hs -o -f Setup.lhs ]; then\
cp %{_datadir}/ghc-rpm-macros/Setup.hs .\
fi\
if [ "$(/usr/lib/rpm/ghc-info.sh %{ghc_version} 'LibDir')" != "%{ghclibdir}" ]; then\
subsubdir=lib/\
fi\
%cabal --version\
%cabal configure %{?ghc_name:--with-compiler=%{_bindir}/ghc-%{ghc_version}} --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_ghcdocdir} --libsubdir='$compiler/$pkgid' --datasubdir='$pkgid' --libexecsubdir='$pkgid' --ghc %{?_ghcdynlibdir:--dynlibdir=%{_ghcdynlibdir}} %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} %{?ghc_subpackaging:--user}%{!?ghc_subpackaging:--global} --ghc-options="${CFLAGS:+$(echo ' '$CFLAGS | sed -e 's/ / -optc/g')} ${LDFLAGS:+$(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')} -fhide-source-paths" %{?cabal_configure_options} $cabal_configure_extra_options
%cabal configure %{?ghc_name:--with-compiler=%{_bindir}/ghc-%{ghc_version}} --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_ghcdocdir} --libsubdir='$compiler/'${subsubdir}'$pkgid' --datasubdir='$pkgid' --libexecsubdir='$pkgid' --ghc %{?_ghcdynlibdir:--dynlibdir=%{_ghcdynlibdir}} %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} %{?ghc_subpackaging:--user}%{!?ghc_subpackaging:--global} --ghc-options="${CFLAGS:+$(echo ' '$CFLAGS | sed -e 's/ / -optc/g')} ${LDFLAGS:+$(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')} -fhide-source-paths" %{?cabal_configure_options} $cabal_configure_extra_options
# install
%cabal_install %cabal copy --destdir=%{buildroot} %{?cabal_install_options}
@ -69,7 +72,7 @@ fi\
# top library dir
%ghclibdir %{_libdir}/ghc-%{ghc_version}
%ghcliblib %{ghclibdir}%{?with_hadrian:/lib}
%ghcliblib %{?with_hadrian:%{ghclibdir}/lib}%{!?with_hadrian:%(/usr/lib/rpm/ghc-info.sh %{ghc_version} 'LibDir')}
%_ghclicensedir %{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}