232 lines
8.1 KiB
Plaintext
232 lines
8.1 KiB
Plaintext
# RPM Macros for packaging Haskell cabalized packages
|
|
# see https://fedoraproject.org/wiki/PackagingDrafts/Haskell for more details
|
|
|
|
# "cabal"
|
|
%cabal [ -x Setup ] || ghc --make %{!?without_shared:%{!?without_dynamic:-dynamic}} Setup\
|
|
./Setup
|
|
|
|
# configure
|
|
%cabal_configure\
|
|
%cabal configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{name}-%{version} --htmldir=%{ghclibdocdir}/%{pkg_name}-%{version} --libsubdir='$compiler/$pkgid' --ghc %{!?without_shared:--enable-shared} %{!?without_dynamic:--enable-executable-dynamic} %{?cabal_configure_options}
|
|
|
|
# install
|
|
%cabal_install %cabal copy --destdir=%{buildroot} -v
|
|
|
|
# root dir for ghc docs
|
|
%ghcdocbasedir %{_docdir}/ghc/html
|
|
# libraries doc dir
|
|
%ghclibdocdir %{ghcdocbasedir}/libraries
|
|
# top library dir
|
|
%ghclibdir %{_libdir}/ghc-%{ghc_version}
|
|
|
|
# ghc_gen_filelists [name] [version]
|
|
%ghc_gen_filelists()\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%define pkgdir %{ghclibdir}/%{pkgnamever}\
|
|
%define docdir %{ghclibdocdir}/%{pkgnamever}\
|
|
rm -f %{basepkg}.files %{basepkg}-devel.files %{basepkg}-prof.files\
|
|
%if 0%{!?without_shared:1}\
|
|
echo "%defattr(-,root,root,-)" > %{basepkg}.files\
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
|
echo "%dir %{pkgdir}" >> %{basepkg}.files\
|
|
echo "%attr(755,root,root) %{pkgdir}/libHS%{pkgnamever}-ghc%{ghc_version}.so" >> %{basepkg}.files\
|
|
fi\
|
|
%endif\
|
|
echo "%defattr(-,root,root,-)" > %{basepkg}-devel.files\
|
|
%if 0%{!?1:1}\
|
|
if [ -d "%{buildroot}%{_docdir}/%{name}-%{version}" ]; then\
|
|
echo "%{_docdir}/%{name}-%{version}" >> %{basepkg}%{?without_shared:-devel}.files\
|
|
fi\
|
|
%endif\
|
|
echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf" >> %{basepkg}-devel.files\
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
|
find %{buildroot}%{pkgdir} -type d | sed "s/^/%dir /" >> %{basepkg}-devel.files\
|
|
find %{buildroot}%{pkgdir} ! \\( -type d -o -name "*_p.a" -o -name "*.p_hi" -o -name "libHS*.so" \\) >> %{basepkg}-devel.files\
|
|
fi\
|
|
echo "%defattr(-,root,root,-)" > %{basepkg}-prof.files\
|
|
if [ -d "%{buildroot}%{pkgdir}" ]; then\
|
|
find %{buildroot}%{pkgdir} \\( -name "*_p.a" -o -name "*.p_hi" \\) >> %{basepkg}-prof.files\
|
|
fi\
|
|
if [ -d "%{buildroot}%{docdir}" ]; then\
|
|
echo "%{docdir}" >> %{basepkg}-devel.files\
|
|
fi\
|
|
sed -i -e "s!%{buildroot}!!g" %{!?without_shared:%{basepkg}.files} %{basepkg}-devel.files %{basepkg}-prof.files\
|
|
%{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()\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%cabal register --gen-pkg-config\
|
|
mkdir -p %{buildroot}%{ghclibdir}/package.conf.d\
|
|
install --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d\
|
|
%{nil}
|
|
|
|
# devel pkg basic requires
|
|
%ghc_devel_requires Requires: ghc = %{ghc_version}\
|
|
Requires(post): ghc = %{ghc_version}\
|
|
Requires(postun): ghc = %{ghc_version}\
|
|
%if 0%{!?without_shared:1}\
|
|
Requires: ghc-%{?pkg_name}%{!?pkg_name:%{pkgname}} = %{?pkgver}%{!?pkgver:%{version}}-%{release}\
|
|
%endif
|
|
|
|
# prof pkg basic requires
|
|
%ghc_prof_requires Requires: ghc-%{?pkg_name}%{!?pkg_name:%{pkgname}}-devel = %{?pkgver}%{!?pkgver:%{version}}-%{release}\
|
|
%{nil}
|
|
|
|
# ghc_lib_package [-c cdepslist] [-h pkgdepslist]
|
|
%ghc_lib_package(c:h:)\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%if 0%{!?without_shared:1}\
|
|
%files -n %{basepkg} -f %{basepkg}.files\
|
|
%defattr(-,root,root,-)\
|
|
%endif\
|
|
\
|
|
%ghc_package_devel\
|
|
\
|
|
%ghc_package_prof\
|
|
%{nil}
|
|
|
|
# ghc_binlib_package [-c cdepslist] [-h pkgdepslist] [-l licensetag] [-x] [name] [version]
|
|
%ghc_binlib_package(c:h:l:x)\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%{!-x:%{?1:%global ghc_packages_list %{?ghc_packages_list} %{pkgnamever}}}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%package -n %{basepkg}\
|
|
Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname} library}\
|
|
Group: System Environment/Libraries\
|
|
%{?1:Version: %{pkgver}}\
|
|
%{-l:License: %{-l*}}\
|
|
\
|
|
%description -n %{basepkg}\
|
|
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
|
|
\
|
|
%if 0%{?ghc_version:%{!?without_shared:1}}\
|
|
This package provides the shared library.\
|
|
%endif\
|
|
\
|
|
%ghc_lib_package\
|
|
%{nil}
|
|
|
|
%ghc_pkg_recache %{_bindir}/ghc-pkg recache --no-user-package-conf || :
|
|
|
|
# for docs post and postun
|
|
%ghc_reindex_haddock\
|
|
%{nil}
|
|
|
|
# ghc_package_devel [-c cdepslist] [-h pkgdepslist] [-l licensetag] [name] [version]
|
|
%ghc_package_devel(c:h:l:)\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%global _use_internal_dependency_generator 0\
|
|
%global __find_provides %{_rpmconfigdir}/ghc-deps.sh --provides %{buildroot}%{ghclibdir}\
|
|
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
|
|
%package -n %{basepkg}-devel\
|
|
Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname} library} development files\
|
|
Group: Development/Libraries\
|
|
%{?1:Version: %{pkgver}}\
|
|
%{-l:License: %{-l*}}\
|
|
%{?ghc_devel_requires}\
|
|
%{!-h:%{?ghc_pkg_deps:Requires: %{ghc_pkg_deps}}}\
|
|
%{-h:Requires: %{-h*}}\
|
|
%{!-c:%{?ghc_pkg_c_deps:Requires: %{ghc_pkg_c_deps}}}\
|
|
%{-c:Requires: %{-c*}}\
|
|
%{?ghc_pkg_obsoletes:Obsoletes: %{ghc_pkg_obsoletes}}\
|
|
%{?ghc_pkg_obsoletes:Obsoletes: %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-doc/g")}\
|
|
Obsoletes: %{basepkg}-doc < %{version}-%{release}\
|
|
Provides: %{basepkg}-doc = %{version}-%{release}\
|
|
\
|
|
%description -n %{basepkg}-devel\
|
|
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
|
|
\
|
|
This package contains the development files.\
|
|
\
|
|
%post -n %{basepkg}-devel\
|
|
%ghc_pkg_recache\
|
|
%ghc_reindex_haddock\
|
|
\
|
|
%postun -n %{basepkg}-devel\
|
|
%ghc_pkg_recache\
|
|
%ghc_reindex_haddock\
|
|
\
|
|
%files -n %{basepkg}-devel -f %{basepkg}-devel.files\
|
|
%defattr(-,root,root,-)\
|
|
%{nil}
|
|
|
|
# ghc_package_prof [-h pkgdepslist] [-l licensetag]
|
|
%ghc_package_prof(h:l:)\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
%define pkgnamever %{pkgname}-%{pkgver}\
|
|
%define basepkg ghc-%{pkgname}\
|
|
%package -n %{basepkg}-prof\
|
|
Summary: %{?common_summary}%{!?common_summary:Haskell %{pkgname}} profiling libraries\
|
|
Group: Development/Libraries\
|
|
%{?1:Version: %{pkgver}}\
|
|
%{-l:License: %{-l*}}\
|
|
%{?ghc_prof_requires}\
|
|
%{!-h:%{?ghc_pkg_deps:Requires: %(echo "%{ghc_pkg_deps}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}}\
|
|
%{-h:Requires: %(echo "%{-h*}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}\
|
|
%{?ghc_pkg_obsoletes:Obsoletes: %(echo "%{ghc_pkg_obsoletes}" | sed -e "s/\\(ghc-[^, ]*\\)-devel/\\1-prof/g")}\
|
|
\
|
|
%description -n %{basepkg}-prof\
|
|
%{?common_description}%{!?common_description:Haskell %{pkgname} library.}\
|
|
\
|
|
This package contains the profiling development files.\
|
|
\
|
|
%files -n %{basepkg}-prof -f %{basepkg}-prof.files\
|
|
%defattr(-,root,root,-)\
|
|
%{nil}
|
|
|
|
# ghc_strip_dynlinked
|
|
%ghc_strip_dynlinked\
|
|
%if 0%{!?__debug_package:1}\
|
|
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
|
|
%endif
|
|
|
|
# ghc_bin_build
|
|
%ghc_bin_build\
|
|
%cabal_configure\
|
|
%cabal build
|
|
|
|
# ghc_lib_build [name] [version]
|
|
%ghc_lib_build()\
|
|
%{?1:cd %1-%2}\
|
|
%cabal_configure %{!?without_prof:-p} %{?1:--docdir=%{_docdir}/ghc-%1-%2 --htmldir=%{ghclibdocdir}/%1-%2}\
|
|
%cabal build\
|
|
%{!?without_haddock:%cabal haddock %{!?without_hscolour:--hyperlink-source}}\
|
|
%{?1:cd -}\
|
|
%{nil}
|
|
|
|
# install bin package
|
|
%ghc_bin_install\
|
|
%global _use_internal_dependency_generator 0\
|
|
%global __find_requires %{_rpmconfigdir}/ghc-deps.sh --requires %{buildroot}%{ghclibdir}\
|
|
%cabal_install\
|
|
%ghc_strip_dynlinked
|
|
|
|
# ghc_lib_install [name] [version]
|
|
%ghc_lib_install()\
|
|
%{?1:cd %1-%2}\
|
|
%cabal_install\
|
|
%cabal_pkg_conf\
|
|
%{?1:cd -}\
|
|
%ghc_gen_filelists\
|
|
%{!?1:%ghc_strip_dynlinked}\
|
|
%{nil}
|