From Fedora Project Wiki

< PackagingDrafts‎ | Haskell

Revision as of 16:28, 24 May 2008 by Admin (talk | contribs) (1 revision(s))

Library and Binary Template

This is a sample spec file for a Haskell Cabal package. This sample demonstrates how to package a Haskell Cabal package that contains a library and binary together. 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 might fill them in manually - YaakovNemoy
%define hsc_name ghc
%define hsc_version 6.8.2
%define h_pkg_name xmonad
%define f_pkg_name xmonad
%define pkg_libdir %{_libdir}/%{hsc_name}-%{hsc_version}/%{h_pkg_name}-%{version}
%define tar_dir %{_builddir}/%{?buildsubdir}

%define debug_package %{nil}

Name: %{f_pkg_name}
Version: 0.7
Release: 1%{?dist}
License: BSD
Group: Development/Languages
URL: http://xmonad.org
Source: xmonad-0.7.tar.gz
Summary: A tiling window manager
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ghc = 6.8.2, haddock


%description
xmonad is a tiling window manager for X. Windows are arranged
automatically to tile the screen without gaps or overlap, maximising
screen use. All features of the window manager are accessible from
the keyboard: a mouse is strictly optional. xmonad is written and
extensible in Haskell. Custom layout algorithms, and other
extensions, may be written by the user in config files. Layouts are
applied dynamically, and different layouts may be used on each
workspace. Xinerama is fully supported, allowing windows to be tiled
on several screens.


%package -n %{hsc_name}-%{f_pkg_name}
Summary: A tiling window manager
Group: Development/Libraries
Requires: %{hsc_name} = %{hsc_version}
Provides: %{h_pkg_name}-%{hsc_name}-%{hsc_version} = %{version}


%description -n %{hsc_name}-%{f_pkg_name}
xmonad is a tiling window manager for X. Windows are arranged
automatically to tile the screen without gaps or overlap, maximising
screen use. All features of the window manager are accessible from
the keyboard: a mouse is strictly optional. xmonad is written and
extensible in Haskell. Custom layout algorithms, and other
extensions, may be written by the user in config files. Layouts are
applied dynamically, and different layouts may be used on each
workspace. Xinerama is fully supported, allowing windows to be tiled
on several screens.

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


%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
xmonad is a tiling window manager for X. Windows are arranged
automatically to tile the screen without gaps or overlap, maximising
screen use. All features of the window manager are accessible from
the keyboard: a mouse is strictly optional. xmonad is written and
extensible in Haskell. Custom layout algorithms, and other
extensions, may be written by the user in config files. Layouts are
applied dynamically, and different layouts may be used on each
workspace. Xinerama is fully supported, allowing windows to be tiled
on several screens.

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 TODO README


%clean
rm -rf ${RPM_BUILD_ROOT}


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


%post -n %{hsc_name}-%{f_pkg_name}
%{pkg_libdir}/register.sh >&/dev/null


%preun -n %{hsc_name}-%{f_pkg_name}
%{pkg_libdir}/unregister.sh >&/dev/null


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


%files -n %{hsc_name}-%{f_pkg_name} -f %{name}-files.nonprof
%doc dist/doc/html
%doc LICENSE TODO README


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


%files
%defattr(-,root,root,-)
%{_bindir}/xmonad
%doc LICENSE


%changelog
* Wed Apr 30 2008 cabal-rpm <cabal-devel@haskell.org> - 0.7-1
- spec file autogenerated by cabal-rpm