From 7e15be09630a7de5442dc27339635a0691cb36c2 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Jun 03 2016 04:19:05 +0000 Subject: backport changes from ghc-7.10.3 copr as 1.6.0 - ghc_gen_filelists: determine keyname with pkgnamever not just pkgname (fixes building newer version of installed package) - use _rpmconfigdir macro - support el6 (no fileattrs or /usr/lib/rpm/macros.d) - change url to github - add and use ghc-pkg-wrapper script - use ghc-pkg key field (for ghc-7.10) - configure libsubdir using pkgkey like ghc-cabal - handle no ghc-srpm-macros for fedora < 21 - fix ghc-pkg path in ghc-deps.sh for ghc-7.10 - version ghc-pkg in ghc_pkg_recache - update ghc_gen_filelists to use new keyed library filepaths and specify libHS*.so more loosely - ghc-dep.sh now just makes versioned devel reqs - rename ghc_lib.attr to ghc.attr and drop ghc_bin.attr - enable debuginfo package --- diff --git a/ghc-deps.sh b/ghc-deps.sh index 7efd52f..c21e4d6 100755 --- a/ghc-deps.sh +++ b/ghc-deps.sh @@ -8,26 +8,6 @@ set +x MODE=$1 PKGBASEDIR=$2 PKGCONFDIR=$PKGBASEDIR/package.conf.d -GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//) - -# 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 case $MODE in --provides) FIELD=id ;; @@ -38,47 +18,19 @@ esac files=$(cat) for i in $files; do - META="" - SELF="" case $i in - */libHSrts.*) ;; - */libHS*_p.a) ;; - */libHS*.so) - META=ghc - PKGVER=$(echo $i | sed -e "s%$PKGBASEDIR/[^/]\+/libHS\(.\+-[0-9.]\+\)\(-.\+\)\?-ghc${GHC_VER}\.so%\1%") - ;; - */libHS*.a) - META=ghc-devel - PKGVER=$(echo $i | sed -e "s%$PKGBASEDIR/[^/]\+/libHS\(.\+-[0-9.]\+\)\(-.\+\)\?\.a%\1%") - if [ -f $PKGBASEDIR/$PKGVER/libHS$PKGVER-ghc${GHC_VER}.so ]; then - SELF=ghc - fi + # exclude builtin_rts.conf + $PKGCONFDIR/*-*.conf) + PKGVER=$(echo $i | sed -e "s%$PKGCONFDIR/\(.\+\)-.\+.conf%\1%") + OUT=$(/usr/lib/rpm/ghc-pkg-wrapper $PKGBASEDIR field $PKGVER $FIELD | sed -e "s/^depends: \+//" -e "s/rts//" -e "s/bin-package-db-[^ ]\+//") + for d in $OUT; do + case $d in + *-*) echo "ghc-devel($d)" ;; + *) ;; + esac + done + ;; + *) ;; esac - if [ "$META" -a -d "$PKGCONFDIR" ]; then - HASHS=$(${GHC_PKG} -f $PKGCONFDIR field $PKGVER $FIELD | sed -e "s/^$FIELD: \+//") - for i in $HASHS; do - case $i in - *-*) echo "$META($i)" ;; - *) ;; - esac - done - if [ "$MODE" = "--requires" -a "$SELF" ]; then - HASHS=$(${GHC_PKG} -f $PKGCONFDIR field $PKGVER id | sed -e "s/^id: \+//") - for i in $HASHS; do - echo "$SELF($i)" - done - fi - elif [ "$MODE" = "--requires" ]; then - if file $i | grep -q 'executable, .* dynamically linked'; then - BIN_DEPS=$(objdump -p $i | grep NEEDED | grep libHS | grep -v libHSrts | sed -e "s%^ *NEEDED *libHS\(.*\)-ghc${GHC_VER}\.so%\1%") - if [ -d "$PKGCONFDIR" ]; then - PACKAGE_CONF_OPT="--package-conf=$PKGCONFDIR" - fi - for p in ${BIN_DEPS}; do - HASH=$(${GHC_PKG} --global $PACKAGE_CONF_OPT field $p id | sed -e "s/^id: \+//" | uniq) - echo "ghc($HASH)" - done - fi - fi done diff --git a/ghc-pkg-wrapper b/ghc-pkg-wrapper new file mode 100755 index 0000000..6cfd4f3 --- /dev/null +++ b/ghc-pkg-wrapper @@ -0,0 +1,32 @@ +#!/bin/sh + +[ $# -lt 1 ] && echo "Usage: `basename $0` %{buildroot}%{ghclibdir} ..." && exit 1 + +set +x + +PKGBASEDIR=$1 +shift +PKGCONFDIR=$PKGBASEDIR/package.conf.d +GHC_VER=$(basename $PKGBASEDIR | sed -e s/ghc-//) + +# 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.4.*) + GHC_PKG="$PKGBASEDIR/ghc-pkg --global-conf=$PKGCONFDIR" + ;; + 7.6.*) + GHC_PKG="$PKGBASEDIR/ghc-pkg --global-package-db=$PKGCONFDIR" + ;; + # 7.8 and 7.10 + *) + GHC_PKG="$PKGBASEDIR/bin/ghc-pkg --global-package-db=$PKGCONFDIR" + ;; + esac +else + GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER} -f $PKGCONFDIR" +fi + +$GHC_PKG --global $* diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec index 9686a8d..9688f8e 100644 --- a/ghc-rpm-macros.spec +++ b/ghc-rpm-macros.spec @@ -1,22 +1,22 @@ %global debug_package %{nil} +%if 0%{?fedora} || 0%{?rhel} >= 7 %global macros_dir %{_rpmconfigdir}/macros.d +%else +%global macros_dir %{_sysconfdir}/rpm +%endif # uncomment to bootstrap without hscolour #%%global without_hscolour 1 Name: ghc-rpm-macros -Version: 1.4.15 -Release: 5%{?dist} +Version: 1.6.0 +Release: 1%{?dist} Summary: RPM macros for building packages for GHC License: GPLv3+ -URL: https://fedoraproject.org/wiki/Packaging:Haskell - -# This is a Fedora maintained package, originally made for -# the distribution. Hence the source is currently only available -# from this package. But it could be hosted on fedorahosted.org -# for example if other rpm distros would prefer that. +URL: https://github.com/fedora-haskell/ghc-rpm-macros +# Currently source is only in git but tarballs could be made if it helps Source0: macros.ghc Source1: COPYING Source2: AUTHORS @@ -24,15 +24,12 @@ Source3: ghc-deps.sh Source4: cabal-tweak-dep-ver Source5: cabal-tweak-flag Source6: macros.ghc-extra -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 +Source7: ghc.attr +Source8: ghc-pkg-wrapper +Requires: redhat-rpm-config # for ghc_version Requires: ghc-compiler %if %{undefined without_hscolour} -# could use ghc_arches here %ifarch %{ix86} %{ix86} x86_64 ppc ppc64 alpha sparcv9 armv7hl armv5tel s390 s390x ppc64le aarch64 Requires: hscolour %endif @@ -88,19 +85,31 @@ 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_bin.attr -install -p -D -m 0644 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr + +%if 0%{?fedora} || 0%{?rhel} >= 7 +install -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc.attr +%endif install -p -D -m 0755 %{SOURCE4} %{buildroot}/%{_bindir}/cabal-tweak-dep-ver install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag +install -p -D -m 0755 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/ghc-pkg-wrapper + +%if 0%{?rhel} && 0%{?rhel} < 7 +cat >> %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh <= 7 +%{_prefix}/lib/rpm/fileattrs/ghc.attr +%endif %{_prefix}/lib/rpm/ghc-deps.sh +%{_prefix}/lib/rpm/ghc-pkg-wrapper %{_bindir}/cabal-tweak-dep-ver %{_bindir}/cabal-tweak-flag @@ -115,6 +124,25 @@ install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag %changelog +* Fri Jun 3 2016 Jens Petersen - 1.6.0-1 +- enable debuginfo package +- ghc-7.10 support from copr http://github.com/fedora-haskell/ghc-rpm-macros: +- ghc_gen_filelists: determine keyname with pkgnamever not just pkgname + (fixes building newer version of installed package) +- use _rpmconfigdir macro +- support el6 (no fileattrs or /usr/lib/rpm/macros.d) +- change url to github +- add and use ghc-pkg-wrapper script +- use ghc-pkg key field (for ghc-7.10) +- configure libsubdir using pkgkey like ghc-cabal +- handle no ghc-srpm-macros for fedora < 21 +- fix ghc-pkg path in ghc-deps.sh for ghc-7.10 +- version ghc-pkg in ghc_pkg_recache +- update ghc_gen_filelists to use new keyed library filepaths + and specify libHS*.so more loosely +- ghc-dep.sh now just makes versioned devel reqs +- rename ghc_lib.attr to ghc.attr and drop ghc_bin.attr + * Tue Mar 8 2016 Jens Petersen - 1.4.15-5 - add ghc-citeproc-hs to obsoletes diff --git a/ghc.attr b/ghc.attr new file mode 100644 index 0000000..7703f9e --- /dev/null +++ b/ghc.attr @@ -0,0 +1,3 @@ +%__ghc_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir} +%__ghc_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir} +%__ghc_path ^%{ghclibdir}/package.conf.d/.*\.conf$ diff --git a/ghc_bin.attr b/ghc_bin.attr deleted file mode 100644 index 4563546..0000000 --- a/ghc_bin.attr +++ /dev/null @@ -1,3 +0,0 @@ -%__ghc_bin_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir} -%__ghc_bin_magic executable, .* dynamically linked -%__ghc_bin_flags exeonly diff --git a/ghc_lib.attr b/ghc_lib.attr deleted file mode 100644 index c3722c0..0000000 --- a/ghc_lib.attr +++ /dev/null @@ -1,3 +0,0 @@ -%__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)$ diff --git a/macros.ghc b/macros.ghc index 8b5dc11..97930c9 100644 --- a/macros.ghc +++ b/macros.ghc @@ -24,8 +24,8 @@ fi %ghc_check_bootstrap\ %global _hardened_ldflags %{nil}\ CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS\ -LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS\ -%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{ghc_pkgdocdir} --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 +LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\ +%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{ghc_pkgdocdir} --libsubdir='$compiler/$pkgkey' --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 @@ -40,7 +40,7 @@ LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS\ %ghc_pkgdocdir %{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}} # root dir for ghc docs (used by ghc.spec) -%ghc_html_dir %{_docdir}/%{?ghc_name}%{!?ghc_name:ghc}/html +%ghc_html_dir %{_docdir}/ghc/html # deprecates %ghcdocbasedir %ghc_html_dir @@ -63,20 +63,19 @@ LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS\ %define pkgver %{?2}%{!?2:%{version}}\ %define pkgnamever %{pkgname}-%{pkgver}\ %define basepkg %{?ghc_name}%{!?ghc_name:ghc}-%{pkgname}\ -%define pkgdir %{ghclibdir}/%{pkgnamever}\ %define docdir %{ghclibdocdir}/%{pkgnamever}\ +keyname=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} field %{pkgnamever} key | sed -e "s/key: //")\ +pkgdir="%{ghclibdir}/${keyname}"\ rm -f %{basepkg}.files %{basepkg}-devel.files\ touch %{basepkg}.files %{basepkg}-devel.files\ -if [ -d "%{buildroot}%{pkgdir}" ]; then\ -echo "%dir %{pkgdir}" >> %{basepkg}.files\ +echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\ +if [ -d "%{buildroot}${pkgdir}" ]; then\ +echo "%dir ${pkgdir}" >> %{basepkg}.files\ %if %{undefined ghc_without_shared}\ -echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\ +echo "%attr(755,root,root) ${pkgdir}/libHS*-ghc%{ghc_version}.so" >> %{basepkg}.files\ %endif\ -fi\ -echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\ -if [ -d "%{buildroot}%{pkgdir}" ]; then\ -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} -mindepth 1 -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\ +find %{buildroot}${pkgdir} ! \\( -type d -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\ fi\ if [ -d "%{buildroot}%{docdir}" ]; then\ echo "%{docdir}" >> %{basepkg}-devel.files\ @@ -103,13 +102,11 @@ install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf. # ghc_bin_build %ghc_bin_build\ -%global debug_package %{nil}\ %cabal_configure\ %cabal build # ghc_lib_build_without_haddock [name] [version] %ghc_lib_build_without_haddock()\ -%global debug_package %{nil}\ %cabal_configure %{!?without_prof:-p} %{!?ghc_without_shared:--enable-shared} %{?ghc_without_shared:--disable-shared} %{?pkg_name:--htmldir=%{ghclibdocdir}/%{pkg_name}-%{version}} %{?1:--docdir=%{_docdir}/ghc-%1%{!?fedora:-%2} --htmldir=%{ghclibdocdir}/%1-%2} %{!?1:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\ %cabal build\ %{nil} @@ -134,12 +131,17 @@ find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \ # install bin package %ghc_bin_install()\ +%{!?_fileattrsdir:%global _use_internal_dependency_generator 0}\ +%{!?_fileattrsdir:%global __find_requires %{_rpmconfigdir}/ghc-deps.sh %{buildroot}%{ghclibdir}}\ %cabal_install\ %{!?1:%ghc_strip_dynlinked}\ %{nil} # ghc_lib_install [name] [version] %ghc_lib_install()\ +%{!?_fileattrsdir:%global _use_internal_dependency_generator 0}\ +%{!?_fileattrsdir:%global __find_provides %{_rpmconfigdir}/rpmdeps --provides}\ +%{!?_fileattrsdir:%global __find_requires %{_rpmconfigdir}/ghc-deps.sh %{buildroot}%{ghclibdir}}\ %cabal_install\ %cabal_pkg_conf\ %ghc_gen_filelists\ diff --git a/macros.ghc-extra b/macros.ghc-extra index d25557a..38983c0 100644 --- a/macros.ghc-extra +++ b/macros.ghc-extra @@ -9,6 +9,9 @@ %define basepkg %{ghc_prefix}-%{pkgname}\ %package -n %{basepkg}\ Summary: Haskell %{pkgname} library\ +%if 0%{?rhel} && 0%{?rhel} < 7\ +Group: System/Libraries\ +%endif\ %{?1:Version: %{pkgver}}\ %{-l:License: %{-l*}}\ Url: http://hackage.haskell.org/package/%{pkgname}\ @@ -19,6 +22,9 @@ This package provides the Haskell %{pkgname} library.\ \ %package -n %{basepkg}-devel\ Summary: Haskell %{pkgname} library development files\ +%if 0%{?rhel} && 0%{?rhel} < 7\ +Group: Development/Languages/Other\ +%endif\ %{?1:Version: %{pkgver}}\ %{-l:License: %{-l*}}\ Requires(post): %{ghc_prefix}-compiler = %{ghc_version}\ @@ -38,8 +44,14 @@ This package provides the Haskell %{pkgname} library development files.\ %ghc_pkg_recache\ \ %files -n %{basepkg} -f %{basepkg}.files\ +%if 0%{?rhel} && 0%{?rhel} < 7\ +%defattr(-,root,root,-)\ +%endif\ %{?base_doc_files:%doc %base_doc_files}\ \ %files -n %{basepkg}-devel -f %{basepkg}-devel.files\ +%if 0%{?rhel} && 0%{?rhel} < 7\ +%defattr(-,root,root,-)\ +%endif\ %{?devel_doc_files:%doc %devel_doc_files}\ %{nil}