# Basic Information
Name:		minidlna
Version:	1.2.1
Release:	3%{?_dist_release}
# COPYING  などを参照して License を修正してください。
License:	GPLv2
# /usr/share/doc/rpm-4.11.1/GROUPS_for_vine.txt を参照して Group を修正してください。
Group:		Applications/Multimedia
URL:		http://sourceforge.net/projects/minidlna
Source0:	http://sourceforge.net/projects/%{name}/files/%{name}/%{version}/%{name}-%{version}.tar.gz
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Vendor:		Project Vine
Distribution:	Vine Linux
Packager:	Shirow HIGA, iwaim

Summary:	Lightweight DLNA/UPnP-AV server targeted at embedded systems
#Summary(ja):	ここに日本語で概要を記述してください。

# Dependency
# 以下に依存関係を記述してください 。
BuildRequires:  libuuid-devel
BuildRequires:  sqlite3-devel
BuildRequires:  libvorbis-devel
BuildRequires:  flac-devel
BuildRequires:  libid3tag-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  libexif-devel
BuildRequires:  gettext-devel
## *-devel pacages provided by other self-build-* should only be listed
## in self-build-%{name}.spec
#BuildRequires: ffmpeg-devel
#BuildRequires:	ffmpegthumbnailer-devel

Requires:	ffmpegthumbnailer

#追加のソースファイル
Source1:	minidlna.init.d.script
Source2:	minidlna.icons.c.custom

#追加のパッチファイル
#patch1:		minidlna_configure.patch
#Patch2:		minidlna_make.patch
#patch1:		minidlna_configure_v113.patch
#Patch2:		minidlna_make_v116.patch
Patch3:		minidlna_video_thumbnail_v121.patch
#Patch4:		minidlna_bravia_v116.patch

%description
MiniDLNA (aka ReadyDLNA) is server software with the aim of being fully
compliant with DLNA/UPnP-AV clients.

The minidlna daemon serves media files (music, pictures, and video) to
clients on your network.  Example clients include applications such as
Totem and XBMC, and devices such as portable media players, smartphones,
and televisions.

#%description -l ja
#ここに日本語で詳細を記述してください。

%prep
%setup -q

#
sed -i.bak \
	-e "s|^AM_GNU_GETTEXT_VERSION(0.18)|AM_GNU_GETTEXT_VERSION(0.18.3)|" \
	-e "s|if test -f /etc/redhat-release; then|if test -f /etc/vine-release; then|" \
	configure.ac

sed -i.bak \
	-e "s|^#network_interface=eth0|network_interface=eth0|" \
	-e "s|^#db_dir=/var/cache/minidlna|db_dir=/var/cache/minidlna|" \
	-e "s|^#log_dir=/var/log|log_dir=/var/log/minidlna|" \
	minidlna.conf

sed -i.bak \
	-e "s|DLNA.ORG_PN=MPEG_TS_HD_NA_ISO,|DLNA.ORG_PN=MPEG_TS_HD_60_L2_ISO,|" \
	-e "s|DLNA.ORG_PN=MPEG_TS_SD_EU_ISO,|DLNA.ORG_PN=MPEG_TS_SD_JP_ISO,|" \
	upnpglobalvars.h

sed -i.bak \
	-e "s|HD_NA|HD_60_L2|" \
	-e "s|EU|JP|" \
	metadata.c

# MiniDLNA Patch
#%patch1 -p0
#%patch2 -p0
%patch3 -p0
#%patch4 -p0

# icons.cをオリジナルの物に差し替える
cp -a %{SOURCE2} icons.c

%build
./autogen.sh
%configure \
  --disable-silent-rules \
  --with-db-path=%{_localstatedir}/cache/%{name} \
  --with-log-path=%{_localstatedir}/log/%{name} \
  --enable-thumbnail

%{__make} %{?_smp_mflags}

%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__make} install DESTDIR=${RPM_BUILD_ROOT}

# Install config file
mkdir -p %{buildroot}%{_sysconfdir}/minidlna
install -p -m 644 minidlna.conf %{buildroot}%{_sysconfdir}/minidlna/minidlna.conf

# Install init.d file
mkdir -p %{buildroot}%{_sysconfdir}/init.d
install -p -m 755 %{SOURCE1} %{buildroot}%{_sysconfdir}/init.d/minidlna

# Install man pages
mkdir -p %{buildroot}%{_mandir}/man5
install -m 644 minidlna.conf.5 %{buildroot}%{_mandir}/man5/
mkdir -p %{buildroot}%{_mandir}/man8
install -m 644 minidlnad.8 %{buildroot}%{_mandir}/man8/

# Create cache and log directories
mkdir -p %{buildroot}%{_localstatedir}/cache
install -d -m 0755 %{buildroot}%{_localstatedir}/cache/%{name}/
mkdir -p %{buildroot}%{_localstatedir}/log
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}/

%find_lang %{name}

%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%pre
if [ -x /etc/rc.d/init.d/%{name} ]; then
    /etc/rc.d/init.d/%{name} stop
fi

%post
    /sbin/chkconfig --add %{name}

%preun
if [ $1 = 0 ]; then
    /etc/rc.d/init.d/%{name} stop > /dev/null 2>&1
    /sbin/chkconfig --del %{name}
fi

%postun
if [ $1 = 0 ]; then
    rm -rf /var/cache/%{name}
fi

%files -f %{name}.lang
%defattr(-,root,root)
%doc AUTHORS COPYING LICENCE.miniupnpd ChangeLog NEWS README TODO
%config(noreplace) %{_sysconfdir}/minidlna/minidlna.conf
%{_sysconfdir}/init.d/minidlna
%{_sbindir}/minidlnad
%{_mandir}/man5/%{name}.conf.5*
%{_mandir}/man8/minidlnad.8*
%{_localstatedir}/cache/%{name}/
%{_localstatedir}/log/%{name}/
#%{_datadir}/minidlna/icons/*

%changelog
* Sun Jun 17 2018 IWAI, Masaharu <iwaim.sub@gmail.com> 1.2.1-3
- add Packager
- update BuildRequires
- stop updating 'notify_interval' configuration

* Tue Apr 24 2018 Shirow HIGA <shirowxxx@gmail.com> 1.2.1-2
- Rebuild with ffmpeg 4.0

* Fri Sep 15 2017 Shirow HIGA <shirowxxx@gmail.com> 1.2.1-1
- new upstream release 1.2.1
- Update Patch3 (minidlna_video_thumbnail_v120.patch -> minidlna_video_thumbnail_v121.patch)

* Fri May 26 2017 Shirow HIGA <shirowxxx@gmail.com> 1.2.0-1
- new upstream release 1.2.0
- Update Patch3 (minidlna_video_thumbnail_v116.patch -> minidlna_video_thumbnail_v120.patch)

* Sun Jan 22 2017 Shirow HIGA <shirowxxx@gmail.com> 1.1.6-3
- Remove Patch1 (minidlna_configure_v113.patch)
- Remove Patch2 (minidlna_make_v116.patch)
- Remove Patch4 (minidlna_bravia_v116.patch)

* Mon Sep 19 2016 Shirow HIGA <shirowxxx@gmail.com> 1.1.6-2
- add new Patch (minidlna_bravia_v116.patch)

* Mon Sep 12 2016 Shirow HIGA <shirowxxx@gmail.com> 1.1.6-1
- new upstream release 1.1.6

* Mon Sep 14 2015 Shirow HIGA <shirowxxx@gmail.com> 1.1.5-1
- new upstream release 1.1.5

* Sun Jan 11 2015 Shirow HIGA <shirowxxx@gmail.com> 1.1.4-1
- new upstream release 1.1.4

* Sun Jun 08 2014 Shirow HIGA <shirowxxx@gmail.com> 1.1.3-1
- new upstream release 1.1.3

* Sun Apr 13 2014 Shirow HIGA <shirowxxx@gmail.com> 1.1.2-1
- initial build for Vine Linux
