Please criticize my spec file. I have got it to compile
and run on the 3 distros.
It is heavily ifdefed.
It looks like a bloody battlefield the day after.
-
#
# spec file for package openastro (Version 1.1.23)
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# norootforbuild
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define srcname openastro.org
%define insname openastromod
Name: openastro
Version: 1.1.23
Release: 1
Summary: Open Source Astrology
License: GPLv3
Group: Productivity/Graphics/Other
Source0: https://launchpad.net/~pellesimon/+archive/+files/%{srcname}_%{version}.orig.tar.gz
#Source: %{srcname}_%{version}.orig.tar.bz2
#Source: http://www.openastro.org/download.php?file=source
Patch0: desktop.patch
URL: http://www.openastro.org
BuildRequires: python-devel
BuildRequires: patch
BuildRequires: gettext
BuildRequires: desktop-file-utils
#suse requires desktop file update
%if 0%{?suse_version} >= 1101 || 0%{?sles_version}
#This is a horrible kludge that will remain only till
#this bug is fixed:
# https://bugzilla.novell.com/show_bug.cgi?id=430965
BuildRequires: update-desktop-files
%endif
#fedora requires python-setuptools-devel
%if 0%{?fedora} >= 8
BuildRequires: python-setuptools-devel
%else
BuildRequires: python-setuptools
%endif
#suse version uses fdupes
%if 0%{?suse_version} || 0%{?sles_version}
BuildRequires: fdupes
%endif
#rh fed use gnome-python2-desktop
%if 0%{?fedora} || 0%{?rhel_version} || 0%{?centos_version}
Requires: gnome-python2-desktop
# handled by gnome_python*-desktop under suse mandriva
Requires: gnome-python2-rsvg
Requires: pygtk2
Requires: pycairo
Requires: gnome-python2
%else
Requires: gnome-python-desktop
Requires: python-cairo
%if 0%{?mandriva_version}
# pygtk2 is equivelent of python-gtk
Requires: pygtk2
# mandrivia has gnome-python, but this is
# already required by gnome-python-desktop
%else
Requires: python-gtk
Requires: python-gnome
%endif
%endif
Requires: python-sqlite2
Requires: python-dateutil
Requires: ImageMagick
# only suse vars split into 2 packages.
%if 0%{?suse_version} || 0%{?sles_version}
Requires: %{name}-lang = %{version}
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: on
#only suse supports %%py_requires. %%lang_package
%if 0%{?suse_version} || 0%{?sles_version}
%py_requires
%lang_package
%endif
%description
OpenAstro.org is an open source initiative from the Astro Tiger Astrologer
Consultancy to provide in the growing demand for free horoscopes.
%prep
%setup -q -n %{srcname}-%{version}.orig
%patch0
find icons/ -type f -exec chmod a-x {} \;
find swisseph18/*.cat -type f -exec chmod a-x {} \;
find . *.xml -type f -exec chmod a-x {} \;
%build
%{__python} setup.py build
%install
%{__python} setup.py install --prefix=%{_prefix} --root=%{buildroot}
%{__mkdir} -p %{buildroot}%{_datadir}/pixmaps
%{__cp} icons/openastro.svg %{buildroot}%{_datadir}/pixmaps/
#update suse desktop file
%if 0%{?suse_version} >= 1101 || 0%{?sles_version}
#This is a horrible kludge that will remain only till
#this bug is fixed:
# https://bugzilla.novell.com/show_bug.cgi?id=430965
%suse_update_desktop_file -i "%{srcname}"
%endif
desktop-file-validate %{buildroot}/%{_datadir}/applications/%{srcname}.desktop
%if 0%{?suse_version} || 0%{?sles_version}
#only suse needs to to find_lang
# because suse uses a lang package
# bacause all lang files are in a directory
# owned by openastro %%{_datadir}/%%{srcname}/locale/*
# find lang is not needed.
# if the lang file were in /usr/share/locale
# then find_lang would be needed to find
# the files but not the directory /usr/share/locale which we would not own.
# fedora find_lang only finds lang files in /usr/share/locale
%find_lang %{name}
#if suse do fdupes to detect duplicates.
%fdupes -s %{buildroot}
%endif
pushd %{buildroot}%{python_sitearch}/%{insname}/
%{__chmod} 0755 dignities.py geoname.py importfile.py swiss.py zonetab.py
popd
#mandriva creates geonames.sql with wrong privs! Who knows why
#make it readable.
%if 0%{?mandriva_version}
%{__chmod} a+r %{buildroot}%{_datadir}/%{srcname}/geonames.sql
%endif
%files
%defattr(-,root,root)
%{_bindir}/openastro.py
%dir %{python_sitearch}/%{insname}
%{python_sitearch}/%{insname}/*
%{python_sitearch}/OpenAstro.org-%{version}_-py*.egg-info
%{python_sitearch}/swisseph.so
%dir %{_datadir}/%{srcname}
%{_datadir}/%{srcname}/*
%if 0%{?suse_version} || 0%{?sles_version}
#only suse moves lang files to other package.
%exclude %{_datadir}/%{srcname}/locale/*
%endif
%dir %{_datadir}/swisseph
%{_datadir}/swisseph/*
%{_datadir}/applications/*
%{_datadir}/pixmaps/*
%if 0%{?suse_version} || 0%{?sles_version}
%files lang -f %{name}.lang
%endif
%changelog
* Sat Nov 27 2010 Paul Elliott