Blob Blame History Raw
%global commit  d7fb6caf0f84ad56c2ce2a0d9ef8b554d230ec75
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global gitdate 20140505

## This macro activates/deactivates debug option
%global without_debug 1

Name:           vdr-epg-daemon
Version:        0.1.0
Release:        8.%{gitdate}git%{shortcommit}%{?dist}
Summary:        A daemon to download EPG data from internet and manage it in a mysql database

Group:          Applications/Multimedia
License:        GPL+ and GPLv2 and BSD
URL:            http://projects.vdr-developer.org/projects/vdr-epg-daemon
Source0:        http://projects.vdr-developer.org/git/vdr-epg-daemon.git/snapshot/vdr-epg-daemon-%{commit}.tar.bz2
# fix Optimization flags are not honored.
Patch0:         vdr-epg-daemon-makefile.patch

BuildRequires:  libcurl-devel
BuildRequires:  libxslt-devel
BuildRequires:  libxml2-devel
BuildRequires:  libuuid-devel
BuildRequires:  jansson-devel
BuildRequires:  zlib-devel
BuildRequires:  openssl-devel
BuildRequires:  mariadb-devel
BuildRequires:  libarchive-devel
BuildRequires:  systemd-units
Requires:       mariadb-server
Requires(post):   systemd-units
Requires(preun):  systemd-units
Requires(postun): systemd-units
Requires:         vdr


%description 
epgd is part of the double team epgd+epg2vdr to effectively retrieve,
store and import epg data to vdr. It is designed to handle large amount of
data and pictures in a distributed environment with one epg-server and
many possible vdr-clients - therefore it relays on mysql. 

Though it is possible to use epgd alone with mysql it only makes sense to
use it as backend to the vdr-plugin epg2vdr. That being said you need to
install, setup and configure mysql, epgd and epg2vdr in order to get a
working environment.


%prep
%setup -qn vdr-epg-daemon-%{commit}
%patch0 -p0
iconv -f iso-8859-1 -t utf-8 README > README.utf8 ; mv README.utf8 README

## Optimization flags in 'Make.config' file
sed -i \
    -e 's|PREFIX   = /usr/local|PREFIX   =  %{_prefix}|' \
    -e 's|PLGDEST  = $(DESTDIR)$(PREFIX)/lib/epgd/plugins|PLGDEST  = $(DESTDIR)%{_libdir}/epgd|' \
    -e 's|@@OPTFLAGS | %{optflags}|' \
    Make.config

%if 0%{?without_debug}
sed -i -e 's|DEBUG = 1||' Make.config
%else
##Nothing
%endif

## Optimization flags for ../epglv
sed -i \
    -e 's|@@LIBDIR| %{_libdir}|' \
    -e 's|@@OPTFLAGS | %{optflags}|' \
    epglv/Makefile

##epglv readme file
mv epglv/README epglv/README-epglv

# add bash to beginning of file
sed -i '1 i\#!/bin/bash' scripts/epgd-showmerge

%build
make %{?_smp_mflags} all

%install
make install-scripts install-config install-plugins DESTDIR=%{buildroot}

# Fedora mysql plugindir /usr/lib64/mysql/plugin
install -dm 755 %{buildroot}%{_bindir}
install -dm 755 %{buildroot}%{_libdir}/mysql/plugin
install -pm 755 epgd %{buildroot}%{_bindir}
install -pm 755 epglv/mysqlepglv.so %{buildroot}%{_libdir}/mysql/plugin

# Systemd unit files
# copy epgd.service to unitdir /lib/systemd/system
mkdir -p %{buildroot}%{_unitdir}
install -Dpm 644 contrib/epgd.service %{buildroot}/%{_unitdir}/epgd.service

%post
%systemd_post epgd.service

%preun
%systemd_preun epgd.service

%postun
%systemd_postun_with_restart epgd.service

%files
%doc COPYING HISTORY* README epglv/README*
%{_bindir}/epg*
%dir %{_sysconfdir}/epgd
%config(noreplace) %{_sysconfdir}/epgd/*
%{_unitdir}/epgd.service
%dir %{_libdir}/epgd
%{_libdir}/epgd/libepgd-epgdata.so
%{_libdir}/mysql/plugin/mysqlepglv.so

%changelog
* Mon May 05 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-8.20140505gitd7fb6ca
- removed unnecessary BR: mariadb-server
- added mariadb-server to Requires 
- used %%install for installing and fix perm of files from buildroot
- shortened summary text

* Mon May 05 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-7.20140505gitd7fb6ca
- added macro for activate/deactivate debug option
- optflags settings
- added epglv README
- used 'cp -p' rather than 'mv' for copying files from buildroot

* Mon May 05 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-6.20140505gitd7fb6ca
- rebuild for new git release
- replaced hardlinks by macro in %%prep section
- Fixed the License tag
- added %%dir %%{_libdir}/epgd because it's owned by the package
- added BR mariadb-server
- added BR systemd-units
- added comment about upstream patch
- added fedora optflags to Make.config

* Sat May 03 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-5.20140428giteb7f12a
- fixed description

* Thu May 01 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-4.20140428giteb7f12a
- added patch for epgd-tool.diff

* Mon Apr 28 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-3.20140428giteb7f12a
- rebuild for new git release

* Fri Apr 25 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-2.20140424gita9d880b
- added missing epgd binary
- removed vdr-devel dependencies
- placed libepg in %%{_libdir}

* Thu Apr 24 2014 Martin Gansser <martinkg@fedoraproject.org> - 0.1.0-1.20140424gita9d880b
- rebuild for initial release