You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
7.8 KiB
226 lines
7.8 KiB
# RPM Macros for packaging Haskell cabalized packages -*-rpm-spec-*-
|
|
# see https://fedoraproject.org/wiki/Packaging:Haskell for more details
|
|
|
|
# "cabal"
|
|
%cabal [ -x Setup ] || ghc --make %{!?ghc_user_conf:-no-user-package-db} %{!?ghc_without_dynamic:-dynamic} Setup\
|
|
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\
|
|
echo "Warning: this ghc build is not self-bootstrapped."\
|
|
%if %{undefined ghc_bootstrapping}\
|
|
echo "The ghc package should be rebuilt against its current version before\
|
|
proceeding, to avoid dependency ABI breakage from a future ghc rebuild."\
|
|
echo "To override set ghc_bootstrapping."\
|
|
echo "Aborting."\
|
|
exit 1\
|
|
%endif\
|
|
fi
|
|
|
|
# configure
|
|
%cabal_configure\
|
|
%ghc_check_bootstrap\
|
|
%global _hardened_ldflags %{nil}\
|
|
# -Wunused-label is extremely noisy: remove for ghc-8.0\
|
|
%ifnarch aarch64 ppc64 ppc64le\
|
|
CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS\
|
|
%endif\
|
|
LDFLAGS="${LDFLAGS:-%{?__global_ldflags}}"; export LDFLAGS\
|
|
%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_subpackaging:--user}%{!?ghc_subpackaging:--global} --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} %{?cabal_install_options}
|
|
|
|
# tests
|
|
%cabal_test\
|
|
%if %{with tests}\
|
|
%cabal test %{?cabal_test_options}\
|
|
%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/html
|
|
# deprecates
|
|
%ghcdocbasedir %ghc_html_dir
|
|
|
|
# libraries doc dir (internal)
|
|
%ghc_html_libraries_dir %{ghc_html_dir}/libraries
|
|
# deprecates
|
|
%ghclibdocdir %ghc_html_libraries_dir
|
|
|
|
# pkg doc dir
|
|
%ghc_html_pkg_dir %{ghc_html_libraries_dir}/%{pkg_name}-%{version}
|
|
# deprecates
|
|
%ghcpkgdocdir %ghc_html_pkg_dir
|
|
|
|
# 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_name}%{!?ghc_name:ghc}-%{pkgname}\
|
|
%define docdir %{ghclibdocdir}/%{pkgnamever}\
|
|
pkgconf=$(echo "%{ghclibdir}/package.conf.d/%{pkgnamever}*.conf")\
|
|
key=$(grep "key: " %{buildroot}${pkgconf} | sed -e "s/key: //")\
|
|
pkgdir="%{ghclibdir}/${key}"\
|
|
rm -f %{basepkg}.files %{basepkg}-devel.files\
|
|
touch %{basepkg}.files %{basepkg}-devel.files\
|
|
echo ${pkgconf} >> %{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*-ghc%{ghc_version}.so" >> %{basepkg}.files\
|
|
%endif\
|
|
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\
|
|
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\
|
|
done\
|
|
%endif\
|
|
for i in %{basepkg}.files %{basepkg}-devel.files; do\
|
|
if [ -f "$i" ]; then\
|
|
sed -i -e "s!%{buildroot}!!g" $i\
|
|
fi\
|
|
done\
|
|
%{nil}
|
|
|
|
# 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\
|
|
install -D --mode=0644 %{pkgnamever}.conf %{buildroot}%{ghclibdir}/package.conf.d/%{pkgnamever}.conf\
|
|
%{nil}
|
|
|
|
# ghc_bin_build
|
|
%ghc_bin_build\
|
|
%global debug_package %{nil}\
|
|
%cabal_configure\
|
|
%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} %{?ghc_with_lib_for_ghci:--enable-library-for-ghci}\
|
|
%cabal build %{?cabal_build_options}\
|
|
%{nil}
|
|
|
|
# ghc_lib_build [name] [version]
|
|
%ghc_lib_build()\
|
|
%ghc_lib_build_without_haddock\
|
|
%if %{undefined without_haddock}\
|
|
%define pkgname %{?1}%{!?1:%{pkg_name}}\
|
|
%define pkgver %{?2}%{!?2:%{version}}\
|
|
if [ -n dist/build/libHS%{pkgname}-%{pkgver}*.so ]; then\
|
|
%cabal haddock --html %{!?without_hscolour:%(if [ -x %{_bindir}/HsColour ]; then echo --hyperlink-source; fi)} --hoogle %{?cabal_haddock_options}\
|
|
fi\
|
|
%endif\
|
|
%{nil}
|
|
|
|
# ghc_strip_dynlinked
|
|
%ghc_strip_dynlinked\
|
|
%if %{undefined __debug_package}\
|
|
find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -exec strip "{}" \\;\
|
|
%endif
|
|
|
|
# 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}\
|
|
%{?ghc_subpackaging:%ghc_fix_rpath %{subpkgs}}\
|
|
%{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\
|
|
%{!?1:%ghc_strip_dynlinked}\
|
|
%{?ghc_subpackaging:%ghc_fix_rpath %{subpkgs}}\
|
|
%{nil}
|
|
|
|
# ghc_fix_rpath lib-ver ...
|
|
%ghc_fix_rpath()\
|
|
%if %{undefined ghc_without_dynamic}\
|
|
if ! type chrpath > /dev/null; then exit 1; fi\
|
|
for i in $(find %{buildroot} -type f -exec sh -c "file {} | grep -q 'dynamically linked'" \\; -print); do\
|
|
for lib in %*; do\
|
|
if [ -x "$i" ]; then\
|
|
rpath=$(chrpath $i | sed -e "s@^$i: R.*PATH=@@")\
|
|
case $rpath in\
|
|
*$PWD/$lib/dist/build*)\
|
|
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)\
|
|
newrpath=$(echo $rpath | sed -e "s@$PWD/$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}\
|
|
if ! type chrpath > /dev/null; then exit 1; fi\
|
|
pdir=$(pwd)\
|
|
for i in %*; do\
|
|
case $i in\
|
|
/*) 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\
|
|
;;\
|
|
esac\
|
|
else\
|
|
echo "%%ghc_fix_dynamic_rpath: no such file $prog"\
|
|
exit 1\
|
|
fi\
|
|
done\
|
|
%endif\
|
|
%{nil}
|
|
|
|
%ghc_pkg_recache %{_bindir}/ghc-pkg-%{ghc_version} recache --no-user-package-db || :
|
|
|
|
# - without_hscolour, without_testsuite, and ghc_bootstrapping
|
|
# need to be set locally in the spec file
|
|
|
|
# skip prof libs and documentation
|
|
%ghc_bootstrap\
|
|
%global without_prof 1\
|
|
%global without_haddock 1\
|
|
%global without_manual 1
|