From Fedora Project Wiki

Revision as of 14:13, 24 May 2008 by fp-wiki>ImportUser (Imported from MoinMoin)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Library Only Template

This is a sample spec file for a Haskell Cabal package. This sample demonstrates how to package a Haskell Cabal package that is only a library. It was generated automatically using cabal-rpm. It contains a few minor bugs, including missing dependency declarations. This is due to a limitation in cabal-rpm that needs to be fixed.

  • Bug me enough and I'll fill them in manually - YaakovNemoy
%define hsc_name ghc
%define hsc_version 6.8.2
%define h_pkg_name xmonad-contrib
%define f_pkg_name xmonad-contrib
%define pkg_libdir %{_libdir}/%{hsc_name}-%{hsc_version}/%{h_pkg_name}-%{version}
%define tar_dir %{_builddir}/%{?buildsubdir}

%define debug_package %{nil}

Name: %{hsc_name}-%{f_pkg_name}
Version: 0.7
Release: 1%{?dist}
License: BSD
Group: Development/Languages
URL: http://xmonad.org/
Source: xmonad-contrib-0.7.tar.gz
Summary: Third party extensions for xmonad
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ghc = 6.8.2, haddock
BuildRequires: xmonad-%{hsc_name}-%{hsc_version} = 0.7
Requires: xmonad-%{hsc_name}-%{hsc_version} = 0.7
Provides: %{h_pkg_name}-%{hsc_name}-%{hsc_version} = %{version}


%description
Third party tiling algorithms, configurations and scripts to xmonad,
a tiling window manager for X.

For an introduction to building, configuring and using xmonad
extensions, see "XMonad.Doc". In particular:

"XMonad.Doc.Configuring", a guide to configuring xmonad

"XMonad.Doc.Extending", using the contributed extensions library

"XMonad.Doc.Developing", introduction to xmonad internals and writing
your own extensions.



%package -n %{hsc_name}-%{f_pkg_name}-prof
Summary: Profiling libraries for %{hsc_name}-%{f_pkg_name}
Group: Development/Libraries
Requires: %{hsc_name}-%{f_pkg_name} = %{version}
Provides: %{h_pkg_name}-%{hsc_name}-%{hsc_version}-prof = %{version}


%description -n %{hsc_name}-%{f_pkg_name}-prof
Third party tiling algorithms, configurations and scripts to xmonad,
a tiling window manager for X.

For an introduction to building, configuring and using xmonad
extensions, see "XMonad.Doc". In particular:

"XMonad.Doc.Configuring", a guide to configuring xmonad

"XMonad.Doc.Extending", using the contributed extensions library

"XMonad.Doc.Developing", introduction to xmonad internals and writing
your own extensions.


This package contains profiling libraries for %{hsc_name} %{hsc_version}.


%prep
%setup -q -n %{h_pkg_name}-%{version}


%build
if [ -f configure.ac -a ! -f configure ] ; then autoreconf; fi
runghc Setup configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{hsc_name}-%{f_pkg_name}-%{version} --libsubdir='$compiler/$pkgid' --enable-library-profiling --ghc
if runghc Setup makefile -f cabal-rpm.mk
then
make -f cabal-rpm.mk %{_smp_mflags} || :
fi
runghc Setup build
runghc Setup haddock || :
runghc Setup register --gen-script
runghc Setup unregister --gen-script


%install
rm -rf ${RPM_BUILD_ROOT}
runghc Setup copy --destdir=${RPM_BUILD_ROOT}
install -m 755 register.sh unregister.sh ${RPM_BUILD_ROOT}%{pkg_libdir}
cd ${RPM_BUILD_ROOT}
echo '%defattr(-,root,root,-)' > %{tar_dir}/%{name}-files.prof
find .%{pkg_libdir} \( -name '*_p.a' -o -name '*.p_hi' \) | sed s/^.// >> %{tar_dir}/%{name}-files.prof
echo '%defattr(-,root,root,-)' > %{tar_dir}/%{name}-files.nonprof
find .%{pkg_libdir} -type d | sed 's/^./%dir /' >> %{tar_dir}/%{name}-files.nonprof
find .%{pkg_libdir} ! \( -type d -o -name '*_p.a' -o -name '*.p_hi' \) | sed s/^.// >> %{tar_dir}/%{name}-files.nonprof
sed 's,^/,%exclude /,' %{tar_dir}/%{name}-files.prof >> %{tar_dir}/%{name}-files.nonprof

cd ${RPM_BUILD_ROOT}/%{_datadir}/doc/%{hsc_name}-%{f_pkg_name}-%{version}
rm -rf doc LICENSE README


%clean
rm -rf ${RPM_BUILD_ROOT}


%pre
[ "$1" = 2 ]  && %{pkg_libdir}/unregister.sh >&/dev/null || :


%post
%{pkg_libdir}/register.sh >&/dev/null


%preun
%{pkg_libdir}/unregister.sh >&/dev/null


%postun
[ "$1" = 1 ]  && %{pkg_libdir}/register.sh >& /dev/null || :


%files  -f %{name}-files.nonprof
%doc dist/doc/html
%doc LICENSE README


%files -n %{hsc_name}-%{f_pkg_name}-prof -f %{name}-files.prof
%%doc LICENSE




%changelog
* Thu May 01 2008 cabal-rpm <cabal-devel@haskell.org> - 0.7-1
- spec file autogenerated by cabal-rpm