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 #!/bin/sh
# find rpm provides and requires for Haskell GHC libraries # 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 set +x
@ -14,7 +14,9 @@ ghc_pkg="/usr/lib/rpm/ghc-pkg-wrapper $pkgbasedir"
case $mode in case $mode in
--provides) field=id ;; --provides) field=id ;;
--requires) field=depends ;; --requires) field=depends ;;
*) echo "`basename $0`: Need --provides or --requires" ; exit 1 *) echo "$(basename $0): Need --provides or --requires"
exit 1
;;
esac esac
ghc_ver=$(basename $pkgbasedir | sed -e s/ghc-//) ghc_ver=$(basename $pkgbasedir | sed -e s/ghc-//)
@ -25,11 +27,8 @@ for i in $files; do
case $i in case $i in
# exclude builtin_rts.conf # exclude builtin_rts.conf
$pkgconfdir/*-*.conf) $pkgconfdir/*-*.conf)
case $ghc_ver in name=$(grep "^name: " $i | sed -e "s/name: //")
8.*) id=$(grep "id: " $i | sed -e "s/id: //") ;; ids=$($ghc_pkg field $name $field | sed -e "s/rts//" -e "s/bin-package-db-[^ ]\+//")
*) 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 for d in $ids; do
case $d in case $d in

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

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

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

Loading…
Cancel
Save