- add cabal2spec and cabal-lib-template.spec for easy Cabal library

packaging
- simplify script macros: make ghc_preinst_script and ghc_postun_script
    no-ops and ghc_preun_script only unregister for uninstall
This commit is contained in:
Jens Petersen 2008-11-25 02:52:10 +00:00
parent 6c9b784686
commit 0682b80a1d
5 changed files with 158 additions and 7 deletions

View File

@ -1,7 +1,7 @@
# Makefile for source rpm: ghc
# $Id$
NAME := ghc
SPECFILE = $(firstword $(wildcard *.spec))
SPECFILE = $(NAME).spec
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done

115
cabal-lib-template.spec Normal file
View File

@ -0,0 +1,115 @@
%define pkg_name @PACKAGE@
%define ghc_version @GHC_VERSION@
%define pkg_libdir %{_libdir}/ghc-%{ghc_version}/%{pkg_name}-%{version}
%define pkg_docdir %{_docdir}/ghc/libraries/%{pkg_name}
%define build_prof 1
%define build_doc 1
# ghc does not emit debug information
%define debug_package %{nil}
Name: ghc-%{pkg_name}
Version: @VERSION@
Release: 1%{?dist}
Summary: Haskell %{pkg_name} library *FIXME*
Group: Development/Libraries
License: BSD
URL: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/%{pkg_name}
Source0: http://hackage.haskell.org/packages/archive/%{pkg_name}/%{version}/%{pkg_name}-%{version}.tar.gz
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}
%if %{build_prof}
BuildRequires: ghc-prof = %{ghc_version}
%endif
Requires: ghc = %{ghc_version}
Requires(post): ghc = %{ghc_version}
Requires(preun): ghc = %{ghc_version}
Requires(postun): ghc = %{ghc_version}
%description
Haskell %{pkg_name} library for ghc-%{ghc_version}. *FIXME*
%if %{build_prof}
%package prof
Summary: Profiling libraries for %{name}
Group: Development/Libraries
Requires: ghc-prof = %{ghc_version}
%description prof
This package contains profiling libraries for ghc %{ghc_version}.
%endif
%prep
%setup -q -n %{pkg_name}-%{version}
%build
%cabal_configure --ghc \
%if %{build_prof}
-p
%else
%{nil}
%endif
%cabal_build
%if %{build_doc}
%cabal_haddock
%endif
%ghc_gen_scripts
%install
rm -rf $RPM_BUILD_ROOT
%cabal_install
%ghc_install_scripts
%ghc_gen_filelists %{name}
%clean
rm -rf $RPM_BUILD_ROOT
%post
%ghc_postinst_script
%if %{build_doc}
%ghc_reindex_haddock
%endif
%preun
%ghc_preun_script
%postun
if [ "$1" -eq 0 ] ; then
%if %{build_doc}
%ghc_reindex_haddock
%endif
fi
%files -f %{name}.files
%defattr(-,root,root,-)
%doc LICENSE README
%if %{build_doc}
%{pkg_docdir}
%endif
%if %{build_prof}
%files prof -f %{name}-prof.files
%defattr(-,root,root,-)
%doc LICENSE
%endif
%changelog
* @DATE@ @PACKAGER@ <@EMAIL@> - @VERSION@-1
- initial packaging for Fedora

23
cabal2spec Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
[ $# -ne 1 ] && echo "Usage: $0 lib-ver[.tar.gz]" && exit 1
INPUT=$1
case $INPUT in
*/*) INPUT=$(basename $INPUT) ;;
esac
INPUT=$(echo $INPUT | sed -e "s/.tar.gz//")
VERSION=$(echo $INPUT | sed -e "s/[A-Za-z-]*-//")
NAME=$(echo $INPUT | sed -e "s/-$VERSION//")
[ -r ghc-$NAME.spec ] && echo "ghc-$NAME.spec already exists!" && exit 1
cp /usr/share/ghc/cabal-lib-template.spec ghc-$NAME.spec
echo "created ghc-$NAME.spec"
sed -i -e "s/@PACKAGE@/$NAME/" -e "s/@GHC_VERSION@/$(ghc --numeric-version)/" -e "s/@VERSION@/$VERSION/" -e "s/@DATE@/`date +\"%a %b %e %Y\"`/" ghc-$NAME.spec

View File

@ -40,7 +40,6 @@ install -m 755 register.sh unregister.sh ${RPM_BUILD_ROOT}%{pkg_libdir} \
%{nil}
%ghc_preinst_script \
[ "$1" = 2 ] && %{pkg_libdir}/unregister.sh >&/dev/null || : \
%{nil}
%ghc_postinst_script \
@ -48,11 +47,10 @@ install -m 755 register.sh unregister.sh ${RPM_BUILD_ROOT}%{pkg_libdir} \
%{nil}
%ghc_preun_script \
%{pkg_libdir}/unregister.sh >&/dev/null \
[ "$1" = 0 ] && %{pkg_libdir}/unregister.sh >&/dev/null \
%{nil}
%ghc_postun_script \
[ "$1" = 1 ] && %{pkg_libdir}/register.sh >& /dev/null || : \
%{nil}
%ghc_reindex_haddock \

View File

@ -16,7 +16,7 @@
Name: ghc
Version: 6.10.1
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Glasgow Haskell Compilation system
# See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=239713
ExcludeArch: alpha ppc64
@ -25,6 +25,8 @@ Group: Development/Languages
Source0: http://www.haskell.org/ghc/dist/%{version}/ghc-%{version}-src.tar.bz2
Source1: http://www.haskell.org/ghc/dist/%{version}/ghc-%{version}-src-extralibs.tar.bz2
Source2: ghc-rpm-macros.ghc
Source3: cabal-lib-template.spec
Source4: cabal2spec
URL: http://haskell.org/ghc/
Requires: gcc, gmp-devel, libedit-devel
Requires(post): policycoreutils
@ -67,7 +69,7 @@ Summary: Documentation for GHC
Group: Development/Languages
Requires: %{name} = %{version}-%{release}
# for haddock
Requires(post): %{name} = %{version}-%{release}
Requires(posttrans): %{name} = %{version}-%{release}
%description doc
Preformatted documentation for the Glorious Glasgow Haskell
@ -126,7 +128,14 @@ make DESTDIR=${RPM_BUILD_ROOT} install-docs
# install rpm macros
mkdir -p ${RPM_BUILD_ROOT}/%{_sysconfdir}/rpm
cp -p %{SOURCE2} ${RPM_BUILD_ROOT}/%{_sysconfdir}/rpm/macros.ghc
# spec templating
# cabal-lib-template.spec
mkdir -p ${RPM_BUILD_ROOT}/%{_datadir}/ghc
cp -p %{SOURCE3} ${RPM_BUILD_ROOT}/%{_datadir}/ghc/
# cabal2spec
install -m 0755 -p %{SOURCE4} ${RPM_BUILD_ROOT}/%{_bindir}
SRC_TOP=$PWD
rm -f rpm-*-filelist rpm-*.files
( cd $RPM_BUILD_ROOT
@ -192,6 +201,7 @@ fi
%{_bindir}/*
%{_sysconfdir}/rpm/macros.ghc
%config(noreplace) %{_libdir}/ghc-%{version}/package.conf
%{_datadir}/ghc
%if %{build_prof}
%files prof -f rpm-prof-filelist
@ -217,6 +227,11 @@ fi
%endif
%changelog
* Tue Nov 25 2008 Jens Petersen <petersen@redhat.com> - 6.10.1-5
- add cabal2spec and cabal-lib-template.spec for easy Cabal library packaging
- simplify script macros: make ghc_preinst_script and ghc_postun_script no-ops
and ghc_preun_script only unregister for uninstall
* Tue Nov 11 2008 Jens Petersen <petersen@redhat.com> - 6.10.1-4
- fix broken urls to haddock docs created by gen_contents_index script
- avoid haddock errors when upgrading by making doc post script posttrans