From 5517c1f361b268d1cea429c1d0579567ef2cb520 Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Wed, 8 Feb 2017 15:26:07 +0900 Subject: [PATCH] new cabal-tweak-drop-dep and other merges from github - no longer use a topdir for subpackage building - only autopackage license if subpackaging - move uniq to ghc-pkg-wrapper - add macros.ghc-fedora for Fedora specific config - replace cabal_verbose with cabal_configure_verbose, cabal_build_verbose, cabal_install_verbose, cabal_haddock_verbose, and cabal_test_verbose - new _ghcdocdir --- AUTHORS | 4 +++ cabal-tweak-drop-dep | 30 ++++++++++++++++++++++ ghc-deps.sh | 23 +++++++++-------- ghc-pkg-wrapper | 2 +- ghc-rpm-macros.spec | 20 +++++++++++++-- macros.ghc | 58 ++++++++++++++++++++++--------------------- macros.ghc-extra | 5 ++-- macros.ghc-fedora | 5 ++++ tests/test-rebuild.sh | 2 +- 9 files changed, 103 insertions(+), 46 deletions(-) create mode 100755 cabal-tweak-drop-dep create mode 100644 macros.ghc-fedora diff --git a/AUTHORS b/AUTHORS index adc72fc..14e0d42 100644 --- a/AUTHORS +++ b/AUTHORS @@ -5,3 +5,7 @@ Initial implementation: Bryan O'Sullivan Jens Petersen Yaakov Nemoy + +Contributions from: +Peter Trommler +Ondřej Súkup diff --git a/cabal-tweak-drop-dep b/cabal-tweak-drop-dep new file mode 100755 index 0000000..3bc5d58 --- /dev/null +++ b/cabal-tweak-drop-dep @@ -0,0 +1,30 @@ +#!/bin/sh + +set -e +x + +USAGE="Usage: $0 dep" + +if [ $# -ne 1 ]; then + echo "$USAGE" + exit 1 +fi + +DEP=$1 + +CABALFILE=$(ls *.cabal) + +if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then + echo "There needs to be one .cabal file in the current dir!" + exit 1 +fi + +if [ ! -f $CABALFILE.orig ]; then + BACKUP=.orig +fi + +if grep $DEP $CABALFILE | sed -e "s/$DEP//" | grep -q -e "[A-Za-z]"; then + echo "$0: deleting whole $DEP lines not safe - try more precise pattern" + exit 1 +fi + +sed -i$BACKUP -e "/$DEP/d" $CABALFILE diff --git a/ghc-deps.sh b/ghc-deps.sh index 831c8c5..de838cb 100755 --- a/ghc-deps.sh +++ b/ghc-deps.sh @@ -5,15 +5,15 @@ set +x -MODE=$1 -PKGBASEDIR=$2 -PKGCONFDIR=$PKGBASEDIR/package.conf.d +mode=$1 +pkgbasedir=$2 +pkgconfdir=$pkgbasedir/package.conf.d -GHC_PKG="/usr/lib/rpm/ghc-pkg-wrapper $PKGBASEDIR" +ghc_pkg="/usr/lib/rpm/ghc-pkg-wrapper $pkgbasedir" -case $MODE in - --provides) FIELD=id ;; - --requires) FIELD=depends ;; +case $mode in + --provides) field=id ;; + --requires) field=depends ;; *) echo "`basename $0`: Need --provides or --requires" ; exit 1 esac @@ -22,10 +22,11 @@ files=$(cat) for i in $files; do case $i in # exclude builtin_rts.conf - $PKGCONFDIR/*-*.conf) - PKGVER=$(echo $i | sed -e "s%$PKGCONFDIR/\(.\+\)-.\+.conf%\1%") - OUT=$($GHC_PKG field $PKGVER $FIELD | sed -e "s/rts//" -e "s/bin-package-db-[^ ]\+//") - for d in $OUT; do + $pkgconfdir/*-*.conf) + pkgver=$(echo $i | sed -e "s%$pkgconfdir/\(.\+\)-.\+.conf%\1%") + ids=$($ghc_pkg field $pkgver $field | sed -e "s/rts//" -e "s/bin-package-db-[^ ]\+//") + + for d in $ids; do case $d in *-*) echo "ghc-devel($d)" ;; *) ;; diff --git a/ghc-pkg-wrapper b/ghc-pkg-wrapper index cd3778c..716cccf 100755 --- a/ghc-pkg-wrapper +++ b/ghc-pkg-wrapper @@ -29,4 +29,4 @@ else GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER} -f $PKGCONFDIR" fi -$GHC_PKG -v0 --simple-output --global $* +$GHC_PKG -v0 --simple-output --global $* | uniq diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec index baf9f9a..7c915c2 100644 --- a/ghc-rpm-macros.spec +++ b/ghc-rpm-macros.spec @@ -10,8 +10,8 @@ #%%global without_hscolour 1 Name: ghc-rpm-macros -Version: 1.6.11 -Release: 2%{?dist} +Version: 1.6.12 +Release: 1%{?dist} Summary: RPM macros for building Haskell packages for GHC License: GPLv3+ @@ -26,6 +26,8 @@ Source5: cabal-tweak-flag Source6: macros.ghc-extra Source7: ghc.attr Source8: ghc-pkg-wrapper +Source9: macros.ghc-fedora +Source11: cabal-tweak-drop-dep Requires: redhat-rpm-config # for ghc_version Requires: ghc-compiler @@ -99,6 +101,7 @@ echo no build stage needed %install 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 0644 %{SOURCE9} %{buildroot}/%{macros_dir}/macros.ghc-fedora install -p -D -m 0755 %{SOURCE3} %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh @@ -108,6 +111,7 @@ install -p -D -m 0644 %{SOURCE7} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc.a 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 %{SOURCE11} %{buildroot}/%{_bindir}/cabal-tweak-drop-dep install -p -D -m 0755 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/ghc-pkg-wrapper %if 0%{?rhel} && 0%{?rhel} < 7 @@ -122,12 +126,14 @@ EOF %license COPYING %doc AUTHORS %{macros_dir}/macros.ghc +%{macros_dir}/macros.ghc-fedora %if 0%{?fedora} || 0%{?rhel} >= 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-drop-dep %{_bindir}/cabal-tweak-flag @@ -141,6 +147,16 @@ EOF %changelog +* Wed Feb 8 2017 Jens Petersen - 1.6.12-1 +- no longer use a topdir for subpackage building +- only autopackage license if subpackaging +- add new cabal-tweak-drop-dep script for excluding trivial deps +- move uniq to ghc-pkg-wrapper +- add macros.ghc-fedora for Fedora specific config +- replace cabal_verbose with cabal_configure_verbose, cabal_build_verbose, + cabal_install_verbose, cabal_haddock_verbose, and cabal_test_verbose +- new _ghcdocdir + * Fri Dec 2 2016 Jens Petersen - 1.6.11-2 - add more F25 obsoletes for: editline, hashed-storage, nats, primes diff --git a/macros.ghc b/macros.ghc index 7a5347f..9e2f4a1 100644 --- a/macros.ghc +++ b/macros.ghc @@ -6,6 +6,9 @@ LANG=en_US.utf8\ ./Setup +# compiler version +%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override} + # check ghc version was rebuilt against self %ghc_check_bootstrap\ if [ ! "$(ghc --info | grep \\"Booter\\ version\\",\\"%{ghc_version}\\")" ]; then\ @@ -28,15 +31,15 @@ fi CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS\ %endif\ LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\ -%cabal configure %{?cabal_verbose} --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/%{name} --libsubdir='$compiler/$pkgkey' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} --ghc-options="${CFLAGS:+$(echo ' '$CFLAGS | sed -e 's/ / -optc/g')} ${LDFLAGS:+$(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')}" %{?cabal_configure_options} $cabal_configure_extra_options +%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_ghcdocdir} --libsubdir='$compiler/$pkgkey' --datasubdir='$pkgid' --ghc %{!?ghc_without_dynamic:--enable-executable-dynamic} %{?with_tests:--enable-tests} --ghc-options="${CFLAGS:+$(echo ' '$CFLAGS | sed -e 's/ / -optc/g')} ${LDFLAGS:+$(echo ' '$LDFLAGS | sed -e 's/ / -optl/g')}" %{?cabal_configure_options} $cabal_configure_extra_options # install -%cabal_install %cabal copy %{?cabal_verbose} %{!?cabal_verbose:-v} --destdir=%{buildroot} +%cabal_install %cabal copy --destdir=%{buildroot} %{?cabal_install_options} # tests %cabal_test\ %if %{with tests}\ -%cabal test %{?cabal_verbose}\ +%cabal test %{?cabal_test_options}\ %endif # no _pkgdocdir in EPEL <= 7 @@ -67,7 +70,7 @@ LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\ %define pkgnamever %{pkgname}-%{pkgver}\ %define basepkg %{?ghc_name}%{!?ghc_name:ghc}-%{pkgname}\ %define docdir %{ghclibdocdir}/%{pkgnamever}\ -keyname=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} field %{pkgnamever} key | uniq)\ +keyname=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} field %{pkgnamever} key)\ pkgdir="%{ghclibdir}/${keyname}"\ rm -f %{basepkg}.files %{basepkg}-devel.files\ touch %{basepkg}.files %{basepkg}-devel.files\ @@ -83,9 +86,11 @@ fi\ if [ -d "%{buildroot}%{docdir}" ]; then\ echo "%{docdir}" >> %{basepkg}-devel.files\ fi\ +%if 0%{?1:1}\ for i in $(ls %{buildroot}%{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/%{!?1:%{name}}%{?1:%{basepkg}}); do\ -echo "%%license %{?1:%{pkgnamever}/}$i" >> %{basepkg}.files\ +echo "%%license %{?1:../%{pkgnamever}/}$i" >> %{basepkg}.files\ done\ +%endif\ for i in %{basepkg}.files %{basepkg}-devel.files; do\ if [ -f "$i" ]; then\ sed -i -e "s!%{buildroot}!!g" $i\ @@ -93,9 +98,6 @@ fi\ done\ %{nil} -# compiler version -%ghc_version %{!?ghc_version_override:%(ghc --numeric-version)}%{?ghc_version_override} - # create and install package.conf file # cabal_pkg_conf [name] [version] %cabal_pkg_conf()\ @@ -110,13 +112,13 @@ install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf. %ghc_bin_build\ %global debug_package %{nil}\ %cabal_configure\ -%cabal build %{?cabal_verbose} +%cabal build %{?cabal_build_options} # 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=%{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/ghc-%1%{!?fedora:-%2} --htmldir=%{ghclibdocdir}/%1-%2} %{!?1:--global} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\ -%cabal build %{?cabal_verbose}\ +%cabal build %{?cabal_build_options}\ %{nil} # ghc_lib_build [name] [version] @@ -126,7 +128,7 @@ install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf. %define pkgname %{?1}%{!?1:%{pkg_name}}\ %define pkgver %{?2}%{!?2:%{version}}\ if [ -f dist/build/libHS%{pkgname}-%{pkgver}.a ]; then\ -%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle\ +%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle %{?cabal_haddock_options}\ fi\ %endif\ %{nil} @@ -160,16 +162,16 @@ find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \ %ghc_fix_rpath()\ %if %{undefined ghc_without_dynamic}\ if ! type chrpath > /dev/null; then exit 1; fi\ -PDIR=$(pwd)\ +pdir=$(pwd)\ for lib in %*; do\ for i in $(find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -print); do\ if [ -x "$i" ]; then\ - RPATH=$(chrpath $i | sed -e "s@^$i: R.*PATH=@@")\ - case $RPATH in\ - *$PDIR/$lib/*)\ - SYSPATH=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $lib library-dirs | uniq)\ - NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR/$lib/dist/build@${SYSPATH}@g")\ - chrpath -r $NEWRPATH $i\ + rpath=$(chrpath $i | sed -e "s@^$i: R.*PATH=@@")\ + case $rpath in\ + *$pdir/$lib/*)\ + syspath=$(%{_rpmconfigdir}/ghc-pkg-wrapper %{buildroot}%{ghclibdir} --package-db=%{buildroot}%{ghclibdir}/package.conf.d field $lib library-dirs)\ + NEWRPATH=$(echo $rpath | sed -e "s@$pdir/$lib/dist/build@${syspath}@g")\ + chrpath -r $newrpath $i\ ;;\ esac\ else\ @@ -186,22 +188,22 @@ done\ %ghc_fix_dynamic_rpath()\ %if %{undefined ghc_without_dynamic}\ if ! type chrpath > /dev/null; then exit 1; fi\ -PDIR=$(pwd)\ +pdir=$(pwd)\ for i in %*; do\ case $i in\ - /*) PROG=%{buildroot}$i ;;\ - *) PROG=%{buildroot}%{_bindir}/$i ;;\ + /*) prog=%{buildroot}$i ;;\ + *) prog=%{buildroot}%{_bindir}/$i ;;\ esac\ - if [ -x "$PROG" ]; then\ - RPATH=$(chrpath $PROG | sed -e "s@^$PROG: R.*PATH=@@")\ - case $RPATH in\ - *$PDIR*)\ - NEWRPATH=$(echo $RPATH | sed -e "s@$PDIR/dist/build@%{ghclibdir}/%{pkg_name}-%{version}@g")\ - chrpath -r $NEWRPATH $PROG\ + if [ -x "$prog" ]; then\ + RPATH=$(chrpath $prog | sed -e "s@^$prog: R.*PATH=@@")\ + case $rpath in\ + *$pdir*)\ + newrpath=$(echo $rpath | sed -e "s@$pdir/dist/build@%{ghclibdir}/%{pkg_name}-%{version}@g")\ + chrpath -r $newrpath $prog\ ;;\ esac\ else\ - echo "%%ghc_fix_dynamic_rpath: no such file $PROG"\ + echo "%%ghc_fix_dynamic_rpath: no such file $prog"\ exit 1\ fi\ done\ diff --git a/macros.ghc-extra b/macros.ghc-extra index c5cdafc..9c525af 100644 --- a/macros.ghc-extra +++ b/macros.ghc-extra @@ -51,13 +51,13 @@ This package provides the Haskell %{pkgname} library development files.\ %postun -n %{basepkg}-devel\ %ghc_pkg_recache\ \ -%files -n %{basepkg} -f %{basepkg}.files\ +%files -n %{basepkg} -f ../%{pkgname}-%{pkgver}/%{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\ +%files -n %{basepkg}-devel -f ../%{pkgname}-%{pkgver}/%{basepkg}-devel.files\ %if 0%{?rhel} && 0%{?rhel} < 7\ %defattr(-,root,root,-)\ %endif\ @@ -94,7 +94,6 @@ cd $i\ name=$(echo $i | sed -e "s/\\(.*\\)-.*/\\1/")\ ver=$(echo $i | sed -e "s/.*-\\(.*\\)/\\1/")\ %ghc_lib_install $name $ver\ -mv *.files ..\ cd ..\ done\ %ghc_fix_rpath $args\ diff --git a/macros.ghc-fedora b/macros.ghc-fedora new file mode 100644 index 0000000..1bfd7b8 --- /dev/null +++ b/macros.ghc-fedora @@ -0,0 +1,5 @@ +# Fedora specific settings + +%_ghcdocdir %{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/%{name} + +%cabal_install_options -v diff --git a/tests/test-rebuild.sh b/tests/test-rebuild.sh index 2e25766..e6dc976 100755 --- a/tests/test-rebuild.sh +++ b/tests/test-rebuild.sh @@ -24,7 +24,7 @@ ARCH=$(arch) if [ -f /etc/os-release ]; then eval $(grep VERSION_ID /etc/os-release) case $VERSION_ID in - 22) BRANCH=master ;; + 26) BRANCH=master ;; 7.*) BRANCH=epel7 ;; *) BRANCH="f$VERSION_ID" ;; esac