Compare commits

...

5 Commits
master ... f24

Author SHA1 Message Date
Jens Petersen 9638c450b3 merge some trivial changes from f25
mostly conditional _defaultlicensedir
2017-01-18 12:00:46 +09:00
Jens Petersen 46263192c8 fix ghc-pkg-wrapper to only use "ghc-pkg -f" if PKGCONFDIR exists
this was causing BIN only packages to require "ghc()" due to
null hashes/ghc-pkg errors.
2017-01-18 10:35:59 +09:00
Jens Petersen f0013d55f8 backport from f25: %ghc_lib_subpackage backcompat
don't set CFLAGS for aarch64 to avoid -Wunused flood
2016-10-31 13:07:41 +09:00
Jens Petersen df44ccca69 backports from f25:
- new ghc_fix_rpath macro
- add ghc_libs_build and ghc_libs_install
- ghc_gen_filelists now handles license files automatically
- set Cabal docdir to licensedir so licenses end up in right place
- ghc_lib_subpackage now takes name-version processed with lua
- add ghc-pkg-wrapper
- cabal_verbose
2016-10-12 18:54:08 +09:00
Jens Petersen 3ccb91acff obsoletes for hakyll and leksah-server 2016-06-22 17:16:48 +09:00
5 changed files with 185 additions and 51 deletions

View File

@ -10,24 +10,7 @@ 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
GHC_PKG="/usr/lib/rpm/ghc-pkg-wrapper $PKGBASEDIR"
case $MODE in
--provides) FIELD=id ;;
@ -56,7 +39,7 @@ for i in $files; do
;;
esac
if [ "$META" -a -d "$PKGCONFDIR" ]; then
HASHS=$(${GHC_PKG} -f $PKGCONFDIR field $PKGVER $FIELD | sed -e "s/^$FIELD: \+//")
HASHS=$(${GHC_PKG} field $PKGVER $FIELD)
for i in $HASHS; do
case $i in
*-*) echo "$META($i)" ;;
@ -64,7 +47,7 @@ for i in $files; do
esac
done
if [ "$MODE" = "--requires" -a "$SELF" ]; then
HASHS=$(${GHC_PKG} -f $PKGCONFDIR field $PKGVER id | sed -e "s/^id: \+//")
HASHS=$(${GHC_PKG} field $PKGVER id | sed -e "s/^id: \+//")
for i in $HASHS; do
echo "$SELF($i)"
done
@ -72,11 +55,8 @@ for i in $files; do
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)
HASH=$(${GHC_PKG} field $p id | uniq)
echo "ghc($HASH)"
done
fi

35
ghc-pkg-wrapper Executable file
View File

@ -0,0 +1,35 @@
#!/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
if [ -d "$PKGCONFDIR" ]; then
PACKAGE_CONF_OPT="-f $PKGCONFDIR"
fi
GHC_PKG="/usr/bin/ghc-pkg-${GHC_VER} $PACKAGE_CONF_OPT"
fi
$GHC_PKG -v0 --simple-output --global $*

View File

@ -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}
Summary: RPM macros for building packages for GHC
Version: 1.4.18
Release: 1%{?dist}
Summary: RPM macros for building Haskell 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
@ -26,14 +26,12 @@ 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
Source9: 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
%ifarch %{ix86} x86_64 ppc ppc64 alpha sparcv9 armv7hl armv5tel s390 s390x ppc64le aarch64
Requires: hscolour
%endif
%endif
@ -47,6 +45,7 @@ these macros.
%package extra
Summary: Extra RPM macros for building Haskell library subpackages
Requires: %{name} = %{version}-%{release}
Requires: chrpath
%description extra
Extra macros used for subpackaging of Haskell libraries,
@ -67,6 +66,8 @@ Obsoletes: leksah < 0.14, ghc-leksah < 0.14, ghc-leksah-devel < 0.14
Obsoletes: ghc-cgi < 3001.1.8, ghc-cgi-devel < 3001.1.8
# for f24
Obsoletes: ghc-citeproc-hs < 0.3.10-3, ghc-citeproc-hs-devel < 0.3.10-3
Obsoletes: ghc-hakyll < 4.5.4.0-6, ghc-hakyll-devel < 4.5.4.0-6
Obsoletes: ghc-leksah-server < 0.14.3.1-4, ghc-leksah-server-devel < 0.14.3.1-4
%description -n ghc-obsoletes
Meta package for obsoleting deprecated Haskell packages.
@ -93,14 +94,17 @@ install -p -D -m 0644 %{SOURCE8} %{buildroot}/%{_prefix}/lib/rpm/fileattrs/ghc_l
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 %{SOURCE9} %{buildroot}/%{_prefix}/lib/rpm/ghc-pkg-wrapper
%files
%doc COPYING AUTHORS
%license COPYING
%doc AUTHORS
%{macros_dir}/macros.ghc
%{_prefix}/lib/rpm/fileattrs/ghc_bin.attr
%{_prefix}/lib/rpm/fileattrs/ghc_lib.attr
%{_prefix}/lib/rpm/ghc-deps.sh
%{_prefix}/lib/rpm/ghc-pkg-wrapper
%{_bindir}/cabal-tweak-dep-ver
%{_bindir}/cabal-tweak-flag
@ -115,6 +119,33 @@ install -p -D -m 0755 %{SOURCE5} %{buildroot}/%{_bindir}/cabal-tweak-flag
%changelog
* Wed Jan 18 2017 Jens Petersen <petersen@redhat.com> - 1.4.18-1
- fix ghc-pkg-wrapper to only use "ghc-pkg -f" if PKGCONFDIR exists
* Mon Oct 31 2016 Jens Petersen <petersen@redhat.com> - 1.4.17-1
- make ghc_lib_subpackage backward compatible with older 2 args form
- for aarch64 do not set CFLAGS
* Wed Oct 12 2016 Jens Petersen <petersen@redhat.com> - 1.4.16-1
- some backports from f25 beta:
- macros.ghc-extra requires chrpath
- new ghc_fix_rpath macro deprecates ghc_fix_dynamic_rpath
- ghc-pkg-wrapper: quieter and simple output
- ghc_libs_install now runs ghc_fix_rpath to fix subpackage rpaths
- set Cabal docdir to licensedir so licenses end up in right place
- ghc_lib_subpackage now takes name-version processed with lua
- ghc_gen_filelists: support packages with more than one license file
- ghc_gen_filelists now handles license files automatically
- add ghc_libs_build and ghc_libs_install to ease bundling libraries
- cabal_verbose from github fedora-haskell/ghc-rpm-macros
- support el6 (no fileattrs or /usr/lib/rpm/macros.d)
- change url to github
- add and use ghc-pkg-wrapper script
- handle no ghc-srpm-macros for fedora < 21
* Wed Jun 22 2016 Jens Petersen <petersen@redhat.com> - 1.4.15-6
- obsoletes for hakyll and leksah-server
* Tue Mar 8 2016 Jens Petersen <petersen@redhat.com> - 1.4.15-5
- add ghc-citeproc-hs to obsoletes

View File

@ -23,24 +23,27 @@ fi
%cabal_configure\
%ghc_check_bootstrap\
%global _hardened_ldflags %{nil}\
# -Wunused-label is extremely noisy: remove for ghc-8.0\
%ifnarch aarch64\
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
%endif\
LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\
%cabal configure %{?cabal_verbose} --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/%{name} --libsubdir='$compiler/$pkgid' --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 --destdir=%{buildroot} -v
%cabal_install %cabal copy %{?cabal_verbose} %{!?cabal_verbose:-v} --destdir=%{buildroot}
# tests
%cabal_test\
%if %{with tests}\
%cabal test\
%cabal test %{?cabal_verbose}\
%endif
# no _pkgdocdir in EPEL <= 7
%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
@ -70,7 +73,7 @@ touch %{basepkg}.files %{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%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
%endif\
fi\
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
@ -81,6 +84,9 @@ fi\
if [ -d "%{buildroot}%{docdir}" ]; then\
echo "%{docdir}" >> %{basepkg}-devel.files\
fi\
for i in $(ls %{buildroot}%{?_defaultlicensedir}%{!?_defaultlicensedir:%_docdir}/%{!?1:%{name}}%{?1:%{basepkg}}); do\
echo "%%license %{?1:%{pkgnamever}/}$i" >> %{basepkg}.files\
done\
for i in %{basepkg}.files %{basepkg}-devel.files; do\
if [ -f "$i" ]; then\
sed -i -e "s!%{buildroot}!!g" $i\
@ -105,13 +111,13 @@ install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.
%ghc_bin_build\
%global debug_package %{nil}\
%cabal_configure\
%cabal build
%cabal build %{?cabal_verbose}
# 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\
%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}\
%{nil}
# ghc_lib_build [name] [version]
@ -146,6 +152,32 @@ find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \
%{!?1:%ghc_strip_dynlinked}\
%{nil}
# ghc_fix_rpath lib-ver ...
%ghc_fix_rpath()\
%if %{undefined ghc_without_dynamic}\
if ! type chrpath > /dev/null; then exit 1; fi\
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\
;;\
esac\
else\
echo "%%ghc_fix_rpath: no $i executable"\
exit 1\
fi\
done\
done\
%endif\
%{nil}
# Deprecated by ghc_fix_rpath:
# ghc_fix_dynamic_rpath prog ...
%ghc_fix_dynamic_rpath()\
%if %{undefined ghc_without_dynamic}\

View File

@ -1,14 +1,25 @@
# RPM Macros for packaging Haskell packages with multiple libs -*-rpm-spec-*-
# ghc_lib_subpackage [-c cdepslist] [-l licensetag] [-x] [name] [version]
# ghc_lib_subpackage [-c cdepslist] [-l licensetag] [-x] [name-version]
# for backward compat also support: ghc_lib_subpackage name version
%ghc_lib_subpackage(c:l:x)\
%define pkgname %{?1}%{!?1:%{pkg_name}}\
%define pkgver %{?2}%{!?2:%{version}}\
%define pkgname %{?2:%{1}}%{!?2:%{lua:\
local pv = rpm.expand("%1")\
local _, _, name = string.find(pv, "^([%a-]+)-")\
print(name)\
}}\
%define pkgver %{?2}%{!?2:%{lua:\
local pv = rpm.expand("%1")\
print(string.sub(pv, string.find(pv, "[%d.]+$")))\
}}\
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgname}-%{pkgver}}}\
%define ghc_prefix %{?ghc_name}%{!?ghc_name:ghc}\
%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 +30,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 +52,50 @@ 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}
# ghc_libs_build [name-version] ...
%ghc_libs_build()\
HOME=$PWD\
%define cabal_configure_options --user\
for i in %*; do\
name=$(echo $i | sed -e "s/\\(.*\\)-.*/\\1/")\
ver=$(echo $i | sed -e "s/.*-\\(.*\\)/\\1/")\
cd $name-$ver\
case $name in\
haskell-platform)\
%ghc_lib_build_without_haddock $name $ver\
;;\
*)\
%ghc_lib_build $name $ver\
./Setup register --inplace\
;;\
esac\
cd ..\
done\
%{nil}
# ghc_libs_install [name-version] ...
%ghc_libs_install()\
HOME=$PWD\
args="%*"\
for i in $args; do\
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\
%{nil}