From acff114c1dec0f4f2e9bc2bbbcddeb98a2da2b51 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Thu, 15 Sep 2022 20:37:21 +0800 Subject: [PATCH] add ghc-info.sh to handle hadrian %ghclibdir/lib --- ghc-info.sh | 8 ++++++++ ghc-rpm-macros.spec | 8 ++++++-- macros.ghc | 7 +++++-- 3 files changed, 19 insertions(+), 4 deletions(-) create mode 100755 ghc-info.sh diff --git a/ghc-info.sh b/ghc-info.sh new file mode 100755 index 0000000..af1eabf --- /dev/null +++ b/ghc-info.sh @@ -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/' diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec index b15c0ea..21f5695 100644 --- a/ghc-rpm-macros.spec +++ b/ghc-rpm-macros.spec @@ -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 - 2.4.5-1 +* Thu Sep 15 2022 Jens Petersen - 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 - 2.4.4-2 - F36 obsoletes regex-applicative-text diff --git a/macros.ghc b/macros.ghc index 3c45135..451387f 100644 --- a/macros.ghc +++ b/macros.ghc @@ -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}