From Fedora Project Wiki
(Imported from MoinMoin)
 
 
(20 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
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.
 
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
+
Consequently, it's been edited.  The changes can be seen in the changelog below.
  
 
<pre>
 
<pre>
%define hsc_name ghc
+
%define pkg_name someHaLib
%define hsc_version 6.8.2
+
%define ghc_version 6.10.1
%define h_pkg_name xmonad-contrib
+
%define pkg_libdir %{_libdir}/ghc-%{ghc_version}/%{pkg_name}-%{version}
%define f_pkg_name xmonad-contrib
+
%define pkg_docdir %{_docdir}/ghc/libraries/%{pkg_name}
%define pkg_libdir %{_libdir}/%{hsc_name}-%{hsc_version}/%{h_pkg_name}-%{version}
 
%define tar_dir %{_builddir}/%{?buildsubdir}
 
  
 +
# Haskell compilers do not emit debug information
 
%define debug_package %{nil}
 
%define debug_package %{nil}
  
Name: %{hsc_name}-%{f_pkg_name}
+
Name: ghc-%{pkg_name}
Version: 0.7
+
Version: version
 
Release: 1%{?dist}
 
Release: 1%{?dist}
 
License: BSD
 
License: BSD
Group: Development/Languages
+
Group: Development/Libraries
URL: http://xmonad.org/
+
URL: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/%{pkg_name}
Source: xmonad-contrib-0.7.tar.gz
+
Source: http://hackage.haskell.org/packages/archive/%{pkg_name}/%{version}/%{pkg_name}-%{version}.tar.gz
Summary: Third party extensions for xmonad
+
Summary: Summary of %{pkg_name} library
 +
Provides: %{name}-devel = %{version}-%{release}
 
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: ghc = 6.8.2, haddock
+
# ghc has only been bootstrapped on the following archs:
BuildRequires: xmonad-%{hsc_name}-%{hsc_version} = 0.7
+
ExclusiveArch: i386 x86_64 ppc
Requires: xmonad-%{hsc_name}-%{hsc_version} = 0.7
+
BuildRequires: ghc = %{ghc_version}, ghc-prof = %{ghc_version}, haddock
Provides: %{h_pkg_name}-%{hsc_name}-%{hsc_version} = %{version}
+
BuildRequires: ...
 
+
Requires: ghc = %{ghc_version}
 +
Requires: ...
 +
Requires(pre): ghc = %{ghc_version}
 +
Requires(preun): ghc = %{ghc_version}
 +
Requires(post): ghc = %{ghc_version}
 +
Requires(postun): ghc = %{ghc_version}
  
 
%description
 
%description
Third party tiling algorithms, configurations and scripts to xmonad,
+
Description of %{pkg_name} library
a tiling window manager for X.
 
  
For an introduction to building, configuring and using xmonad
+
%package prof
extensions, see "XMonad.Doc". In particular:
+
Summary: Profiling libraries for %{name}
 
 
"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
 
Group: Development/Libraries
Requires: %{hsc_name}-%{f_pkg_name} = %{version}
+
Requires: %{name} = %{version}
Provides: %{h_pkg_name}-%{hsc_name}-%{hsc_version}-prof = %{version}
 
  
 
+
%description prof
%description -n %{hsc_name}-%{f_pkg_name}-prof
+
This package contains profiling libraries for ghc %{ghc_version}.
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
 
%prep
%setup -q -n %{h_pkg_name}-%{version}
+
%setup -q -n %{pkg_name}-%{version}
  
  
 
%build
 
%build
if [ -f configure.ac -a ! -f configure ] ; then autoreconf; fi
+
%cabal_configure -p --ghc
runghc Setup configure --prefix=%{_prefix} --libdir=%{_libdir} --docdir=%{_docdir}/%{hsc_name}-%{f_pkg_name}-%{version} --libsubdir='$compiler/$pkgid' --enable-library-profiling --ghc
+
%cabal_build
if runghc Setup makefile -f cabal-rpm.mk
+
%cabal_haddock
then
+
%ghc_gen_scripts
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
 
%install
 
rm -rf ${RPM_BUILD_ROOT}
 
rm -rf ${RPM_BUILD_ROOT}
runghc Setup copy --destdir=${RPM_BUILD_ROOT}
+
%cabal_install
install -m 755 register.sh unregister.sh ${RPM_BUILD_ROOT}%{pkg_libdir}
+
%ghc_install_scripts
cd ${RPM_BUILD_ROOT}
+
%ghc_gen_filelists %{name}
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}
+
cd ${RPM_BUILD_ROOT}/%{_docdir}/%{name}-%{version}
 
rm -rf doc LICENSE README
 
rm -rf doc LICENSE README
  
Line 108: Line 72:
  
  
%pre
+
%pre  
[ "$1" = 2 ]  && %{pkg_libdir}/unregister.sh >&/dev/null || :
+
%ghc_preinst_script
  
  
%post
+
%post  
%{pkg_libdir}/register.sh >&/dev/null
+
%ghc_postinst_script
 +
%ghc_reindex_haddock
  
  
%preun
+
%preun  
%{pkg_libdir}/unregister.sh >&/dev/null
+
%ghc_preun_script
  
  
%postun
+
%postun  
[ "$1" = 1 ]  && %{pkg_libdir}/register.sh >& /dev/null || :
+
%ghc_postun_script
 +
%ghc_reindex_haddock
  
  
%files  -f %{name}-files.nonprof
+
%files  -f %{name}.files
%doc dist/doc/html
+
%defattr(-,root,root,-)
 
%doc LICENSE README
 
%doc LICENSE README
  
  
%files -n %{hsc_name}-%{f_pkg_name}-prof -f %{name}-files.prof
+
%files prof -f %{name}-prof.files
%%doc LICENSE
+
%defattr(-,root,root,-)
 
+
%doc LICENSE
 
+
%{pkg_docdir}
  
  
 
%changelog
 
%changelog
* Thu May 01 2008 cabal-rpm <cabal-devel@haskell.org> - 0.7-1
+
* Day Month Date Year Fedora Packager <email@address> - version-release
- spec file autogenerated by cabal-rpm
+
- initial packaging for Fedora
 
</pre>
 
</pre>

Latest revision as of 00:53, 14 November 2008

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.

Consequently, it's been edited. The changes can be seen in the changelog below.

%define pkg_name someHaLib
%define ghc_version 6.10.1
%define pkg_libdir %{_libdir}/ghc-%{ghc_version}/%{pkg_name}-%{version}
%define pkg_docdir %{_docdir}/ghc/libraries/%{pkg_name}

# Haskell compilers do not emit debug information
%define debug_package %{nil}

Name: ghc-%{pkg_name}
Version: version
Release: 1%{?dist}
License: BSD
Group: Development/Libraries
URL: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/%{pkg_name}
Source: http://hackage.haskell.org/packages/archive/%{pkg_name}/%{version}/%{pkg_name}-%{version}.tar.gz
Summary: Summary of %{pkg_name} library
Provides: %{name}-devel = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
# ghc has only been bootstrapped on the following archs:
ExclusiveArch:	i386 x86_64 ppc
BuildRequires: ghc = %{ghc_version}, ghc-prof = %{ghc_version}, haddock
BuildRequires: ...
Requires: ghc = %{ghc_version}
Requires: ...
Requires(pre): ghc = %{ghc_version}
Requires(preun): ghc = %{ghc_version}
Requires(post): ghc = %{ghc_version}
Requires(postun): ghc = %{ghc_version}

%description
Description of %{pkg_name} library

%package prof
Summary: Profiling libraries for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}

%description prof
This package contains profiling libraries for ghc %{ghc_version}.


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


%build
%cabal_configure -p --ghc
%cabal_build
%cabal_haddock
%ghc_gen_scripts


%install
rm -rf ${RPM_BUILD_ROOT}
%cabal_install
%ghc_install_scripts
%ghc_gen_filelists %{name}

cd ${RPM_BUILD_ROOT}/%{_docdir}/%{name}-%{version}
rm -rf doc LICENSE README


%clean
rm -rf ${RPM_BUILD_ROOT}


%pre 
%ghc_preinst_script


%post 
%ghc_postinst_script
%ghc_reindex_haddock


%preun 
%ghc_preun_script


%postun 
%ghc_postun_script
%ghc_reindex_haddock


%files  -f %{name}.files
%defattr(-,root,root,-)
%doc LICENSE README


%files prof -f %{name}-prof.files
%defattr(-,root,root,-)
%doc LICENSE
%{pkg_docdir}


%changelog
* Day Month Date Year Fedora Packager <email@address> - version-release
- initial packaging for Fedora