File ghc-rpm-macros.spec of Package ghc-rpm-macros

#
# spec file for package ghc-rpm-macros
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%global git_hash  48199c851a2c672494e295b3cbfc4eded20c3a11

%global macros_dir %{_sysconfdir}/rpm

%global without_hscolour 1

Name:           ghc-rpm-macros
Version:        1.2.7
Release:        0
Summary:        RPM Macros for building packages for GHC
License:        GPL-3.0+
Group:          Development/Libraries/Other

Url:            https://fedoraproject.org/wiki/Haskell_SIG

Source0:        http://pkgs.fedoraproject.org/cgit/%{name}.git/snapshot/%{name}-%{git_hash}.tar.xz
Source1:        ghc-rpm-macros-rpmlintrc
# PATCH-FIX-OPENSUSE suse-disable-debug-packages.patch peter.trommler@ohm-hochschule.de -- openSUSE way to disable debug packages
Patch1:         suse-disable-debug-packages.patch
# PATCH-FIX-OPENSUSE add-group.patch sbahling@suse.com -- Make sure a Group: tag is generated in subpackages; peter.trommler@ohm-hochschule.de: also puts libraries in System/Libraries, see package group guidelines
Patch2:         add-group.patch
# PATCH-FIX-OPENSUSE files-defattr.patch sbahling@suse.com -- Make sure defattr macro used in files sections; peter.trommler@ohm-hochschule.de: see also specfile guidelines, files section, permissions
Patch3:         files-defattr.patch
# PATCH-FIX-OPENSUSE suse-docdir.patch peter.trommler@ohm-hochschule.de -- fix location of docdir
Patch4:         suse-docdir.patch
# PATCH-FIX_UPSTREAM fix-gen-filelists.patch
Patch5:         fix-gen-filelists.patch
# PATCH-FIX-OPENSUSE disable-execstack.patch peter.trommler@ohm-hochschule.de -- disable execstack workaround 
Patch6:         disable-execstack.patch
# PATCH-FIX-SLE sle-sp1-rpmdeps.patch peter.trommler@ohm-hochschule.de -- SLE's RPM is too old in 11 SP1 and SP2 and SP3
Patch100:       sle-sp1-rpmdeps.patch

BuildRequires:  xz
Requires:       ghc-srpm-macros = %{version}-%{release}
%ifnarch ppc64le aarch64 %arm
# for execstack
Requires:       prelink
%endif
Requires:       rpm
%if %{undefined without_hscolour}
Requires:       hscolour
%endif
# This is a workaround for a bug in the automatic dependencies generator
# ghc-deps.sh generates this symbol for extra libraries installed with a
# dynamic ghc, currently only %%{ix86} and x86_64
%ifarch %{ix86} x86_64
Provides:       ghc()
%endif

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
A set of macros for building GHC packages following the openSUSE
Haskell Guidelines.  ghc needs to be installed in
order to make use of these macros.

%package extra
Summary:        Extra RPM macros for building Haskell packages with several libs
Group:          Development/Libraries/Other
Requires:       %{name} = %{version}-%{release}

%description extra
Extra macros used for subpackaging of Haskell libraries,
for example in ghc and haskell-platform.


%package -n ghc-srpm-macros
Summary:        RPM macros for building Haskell source packages
Group:          Development/Libraries/Other
%if 0%{?suse_version} > 1110
BuildArch:      noarch
%endif

%description -n ghc-srpm-macros
Macros used when generating source Haskell rpm packages.

%prep
%setup -q -n %{name}-%{git_hash}
%patch1 -p1 -b .debug
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
# remove when prelink is available on any of those architectures
%ifarch ppc64le aarch64 %arm
%patch6 -p1
%endif
%if 0%{?sles_version}
%patch -P 100 -p1
%endif

%build
echo no build stage needed

%install
install -p -D -m 0644 ./ghc-rpm-macros.ghc %{buildroot}%{macros_dir}/macros.ghc
install -p -D -m 0644 ./ghc-rpm-macros.ghc-extra %{buildroot}/%{macros_dir}/macros.ghc-extra
install -p -D -m 0755 ghc-deps.sh %{buildroot}/%{_prefix}/lib/rpm/ghc-deps.sh
install -p -D -m 0755 cabal-tweak-dep-ver %{buildroot}/%{_bindir}/cabal-tweak-dep-ver
install -p -D -m 0755 cabal-tweak-flag %{buildroot}/%{_bindir}/cabal-tweak-flag
install -p -D -m 0644 ghc-rpm-macros.ghc-srpm %{buildroot}/%{macros_dir}/macros.ghc-srpm

# this is why this package is now arch-dependent:
# turn off shared libs and dynamic linking on secondary archs
%ifnarch %{ix86} x86_64
cat >> %{buildroot}%{macros_dir}/macros.ghc <<EOF

# shared libraries are only supported on primary intel archs
%%ghc_without_dynamic 1
%%ghc_without_shared 1
EOF
%endif

%files
%defattr(-,root,root,-)
%doc COPYING AUTHORS
%config %{macros_dir}/macros.ghc
%{_prefix}/lib/rpm/ghc-deps.sh
%{_bindir}/cabal-tweak-dep-ver
%{_bindir}/cabal-tweak-flag

%files extra
%defattr(-,root,root,-)
%config %{macros_dir}/macros.ghc-extra

%files -n ghc-srpm-macros
%defattr(-,root,root,-)
%config %{macros_dir}/macros.ghc-srpm

%changelog
openSUSE Build Service is sponsored by