support packaging Cabal bundled internal libraries

for some reason installing with Cabal (rather than cabal-install)
gives different hashes for the sublibrary

simplification of initial work in opensuse by Ondřej Súkup
https://github.com/fedora-haskell/ghc-rpm-macros/pull/7

testcase was haddock-library-1.4.5
epel9
Jens Petersen 7 years ago
parent 3124474192
commit 37fe2b4ab7

@ -1,7 +1,7 @@
#!/bin/sh
# find rpm provides and requires for Haskell GHC libraries
[ $# -ne 2 ] && echo "Usage: `basename $0` [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
[ $# -ne 2 ] && echo "Usage: $(basename $0) [--provides|--requires] %{buildroot}%{ghclibdir}" && exit 1
set +x
@ -14,7 +14,9 @@ ghc_pkg="/usr/lib/rpm/ghc-pkg-wrapper $pkgbasedir"
case $mode in
--provides) field=id ;;
--requires) field=depends ;;
*) echo "`basename $0`: Need --provides or --requires" ; exit 1
*) echo "$(basename $0): Need --provides or --requires"
exit 1
;;
esac
ghc_ver=$(basename $pkgbasedir | sed -e s/ghc-//)
@ -24,20 +26,17 @@ files=$(cat)
for i in $files; do
case $i in
# exclude builtin_rts.conf
$pkgconfdir/*-*.conf)
case $ghc_ver in
8.*) id=$(grep "id: " $i | sed -e "s/id: //") ;;
*) id=$(echo $i | sed -e "s%$pkgconfdir/%%" -e "s%.conf%%") ;;
esac
ids=$($ghc_pkg field $id $field | sed -e "s/rts//" -e "s/bin-package-db-[^ ]\+//")
for d in $ids; do
case $d in
*-*) echo "ghc-devel($d)" ;;
*) ;;
esac
done
;;
$pkgconfdir/*-*.conf)
name=$(grep "^name: " $i | sed -e "s/name: //")
ids=$($ghc_pkg field $name $field | sed -e "s/rts//" -e "s/bin-package-db-[^ ]\+//")
for d in $ids; do
case $d in
*-*) echo "ghc-devel($d)" ;;
*) ;;
esac
done
;;
*)
;;
esac

@ -29,4 +29,4 @@ else
GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER} -f $PKGCONFDIR"
fi
$GHC_PKG -v0 --simple-output --global $* | uniq
$GHC_PKG -v0 --simple-output $* | uniq

@ -10,7 +10,7 @@
#%%global without_hscolour 1
Name: ghc-rpm-macros
Version: 1.8.8
Version: 1.9.0
Release: 1%{?dist}
Summary: RPM macros for building Haskell packages for GHC
@ -166,9 +166,10 @@ EOF
%changelog
* Wed May 23 2018 Jens Petersen <petersen@redhat.com> - 1.8.8-1
- rename ghc_bootstrap to ghc_quick_build (disables prof and haddock)
* Thu May 24 2018 Jens Petersen <petersen@redhat.com> - 1.9.0-1
- support Cabal bundled internal libraries (yuck)
- ghc_check_bootstrap should be redundant now according to upstream
- rename ghc_bootstrap to ghc_quick_build (disables prof and haddock)
* Mon Apr 30 2018 Jens Petersen <petersen@redhat.com> - 1.8.7-6
- obsolete ghc-fail

@ -66,25 +66,23 @@ LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\
%define pkgnamever %{pkgname}-%{pkgver}\
%define basepkg %{?ghc_name}%{!?ghc_name:ghc}-%{pkgname}\
%define docdir %{ghclibdocdir}/%{pkgnamever}\
if [ ! -f %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf ]; then\
echo "%{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf not found"\
if [ -z "$(ls %{buildroot}%{ghclibdir}/package.conf.d/)" ]; then\
echo "%{buildroot}%{ghclibdir}/package.conf.d/*.conf not found"\
exit 1\
fi\
pkgconf=$(echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf")\
pkgdir="%{ghclibdir}/%{pkgnamever}"\
rm -f %{basepkg}.files %{basepkg}-devel.files\
touch %{basepkg}.files %{basepkg}-devel.files\
echo ${pkgconf} >> %{basepkg}-devel.files\
ls %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf >> %{basepkg}-devel.files\
pkgdir="%{ghclibdir}/%{pkgnamever}"\
if [ -d "%{buildroot}${pkgdir}" ]; then\
%if %{defined _ghcdynlibdir}\
echo "%%attr(755,root,root) %{_ghcdynlibdir}/libHS%{pkgnamever}-*ghc%{ghc_version}.so" >> %{basepkg}.files\
echo "${pkgdir}" >> %{basepkg}-devel.files\
%else\
echo "%%dir ${pkgdir}" >> %{basepkg}.files\
echo "%%attr(755,root,root) ${pkgdir}/libHS*-ghc%{ghc_version}.so" >> %{basepkg}.files\
find %{buildroot}${pkgdir} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
find %{buildroot}${pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
%endif\
echo "%%attr(755,root,root) %{?_ghcdynlibdir}%{!?_ghcdynlibdir:${pkgdir}}/libHS%{pkgnamever}-*ghc%{ghc_version}.so" >> %{basepkg}.files\
fi\
if [ -d "%{buildroot}%{docdir}" ]; then\
echo "%{docdir}" >> %{basepkg}-devel.files\
@ -108,7 +106,14 @@ done\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgnamever %{pkgname}-%{pkgver}\
%cabal register --gen-pkg-config\
if [ -d %{pkgnamever}.conf ]; then\
for i in $(ls "%{pkgnamever}.conf/"); do\
sub=$(echo $i | sed -e "s/^[0-9]\\+-//")\
install -D --mode=0644 %{pkgnamever}.conf/${i} %{buildroot}%{ghclibdir}/package.conf.d/${sub}.conf\
done\
else\
install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}.conf\
fi\
%{nil}
# ghc_bin_build
@ -179,10 +184,10 @@ for lib in %*; do\
case %{ghc_version} in\
7.10.*)\
pkgid=$(cd %{buildroot}%{ghclibdir}/package.conf.d; ls ${lib}* | sed -e "s/.conf$//")\
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $pkgid library-dirs) ;;\
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --global --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $pkgid library-dirs) ;;\
8.0)\
pkgid=$(cd %{buildroot}%{ghclibdir}; echo ${lib}*)\
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $lib library-dirs | grep $pkgid) ;;\
syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --global --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $lib library-dirs | grep $pkgid) ;;\
*)\
syspath="" ;;\
esac\

Loading…
Cancel
Save