File webtrees.spec of Package webtrees

# spec file for package webtrees
# Copyright (c) 2015 SUSE LINUX 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

%define        webtreesdir       %{_datadir}/%{name}
%if 0%{?suse_version}
%define        httpconfdir        %{_sysconfdir}/apache2
%define        httpduser         wwwrun
%define        httpdgroup        www
%define        phplibdir         %{_datadir}/php5
%define        httpconfdir        %{_sysconfdir}/httpd
%define        httpduser         apache
%define        httpdgroup        apache
%define        phplibdir         %{_datadir}/php

Name:           webtrees
Version:        1.6.2
Release:        0
Summary:        Online collaborative genealogy application
License:        GPL-2.0
Group:          Productivity/Networking/Web/Frontends
# original source is located here
# Source0:
# Use the script to download the sources matching the spec file's version.
Source0:        %{name}-%{version}.tar.xz
Source1:        webtrees.conf
BuildRequires:  xz
Requires:       httpd
BuildRequires:  httpd
Requires:       mysql >= 5.0.13
Requires:       php >= 5.3
Requires:       php-gd
Requires:       php-mbstring
Requires:       php-mysql
Requires:       php-pdo
Requires:       php-xml
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
%if 0%{?suse_version}
BuildRequires:  apache2
#Requires:       php5-ZendFramework
#Requires:       php5-ZendFramework-cache-backend-apc
%if 0%{?suse_version} > 1020
BuildRequires:  fdupes
#%#else # not opsenSUSE
#Requires:       php-ZendFramework
#Requires:       php-ZendFramework-cache-backend-apc

View and edit family history on your website, with collaboration, privacy, and
photo features. Webtrees works from standard GEDCOM files, and is therefore
compatible with every major desktop application; and it aims to be efficient
and effective by using the right combination of third-party tools, design
techniques and open standards.

%setup -q
# remove .htaccess files
find . -name \.htaccess -print | xargs rm -f

# build .mo files
find -type f -name '*.po' -exec "FN=`echo {} | cut -d'.' --complement -f2-` ; msgcat $FN.po | msgfmt -o $ - " -exec rm {} \;

install -m 755 -d %{buildroot}%{_datadir}/%{name}
cp -r . %{buildroot}%{_datadir}/%{name}

# move data directory to /var/lib/ and set symlink
install -m 755 -d %{buildroot}%{_localstatedir}/lib/
mv %{buildroot}%{_datadir}/%{name}/data %{buildroot}%{_localstatedir}/lib/%{name}
ln -s %{_localstatedir}/lib/%{name} %{buildroot}%{_datadir}/%{name}/data

# install (empty) configuration-file
touch %{buildroot}%{_localstatedir}/lib/%{name}/config.ini.php

# install apache config-file and fix paths
install -m 755 -d %{buildroot}%{httpconfdir}/conf.d
install -m 644 %{SOURCE1} %{buildroot}%{httpconfdir}/conf.d/%{name}.conf
sed -i -e 's|WEBTREESDIR|%{webtreesdir}|g ;
	s|WEBDATAROOT|%{_localstatedir}/lib/%{name}|g ;
	s|PHPLIBDIR|%{phplibdir}|g' %{buildroot}%{httpconfdir}/conf.d/%{name}.conf

%if 0%{?suse_version} > 1020
%fdupes %{buildroot}%{webtreesdir}

# move data directory from old locations to the new location
if [ -d '/srv/www/webtrees' ] ; then
if [ -d '%{_localstatedir}/www/webtrees' ] ; then
if [ -n "$OLDDIR" ] ; then
	if [ -d "$OLDDIR/data" ] ; then
		# move data directory from old /srv/www and /var/www locations
		mv $OLDDIR/data/* %{_localstatedir}/lib/%{name}/
		rmdir "$OLDDIR/data"
	rmdir --ignore-fail-on-non-empty "$OLDDIR"
	if [ -d "$OLDDIR" ] ; then
		mv $OLDDIR/* %{_localstatedir}/lib/%{name}/
		rmdir "$OLDDIR/"
if [ -d "$OLDDIR" ] ; then
	mv "$OLDDIR" "$OLDDIR.backup"
	echo "WARNING: Check content of $OLDDIR.backup! Should have been migrated to %{_localstatedir}/lib/%{name}"

if [ -x %{_sbindir}/semanage ] ; then
	# check is SELinux is installed and update settings
	semanage fcontext -a -t httpd_var_lib_t %{_localstatedir}/lib/%{name}


%dir %{webtreesdir}

# language-related files
%dir %{webtreesdir}/language
%dir %{webtreesdir}/language/extra
%lang(ar) %{webtreesdir}/language/
%lang(bg) %{webtreesdir}/language/
%lang(bs) %{webtreesdir}/language/
%lang(ca) %{webtreesdir}/language/
%lang(cs) %{webtreesdir}/language/
%lang(da) %{webtreesdir}/language/
%lang(de) %{webtreesdir}/language/
%lang(el) %{webtreesdir}/language/
%lang(en_GB) %{webtreesdir}/language/
%lang(en_US) %{webtreesdir}/language/
%lang(es) %{webtreesdir}/language/
%lang(et) %{webtreesdir}/language/
%lang(af) %{webtreesdir}/language/extra/
%lang(dv) %{webtreesdir}/language/extra/
%lang(en_AU) %{webtreesdir}/language/extra/
%lang(fa) %{webtreesdir}/language/extra/
%lang(fo) %{webtreesdir}/language/extra/
%lang(fr_CA) %{webtreesdir}/language/extra/
%lang(gl) %{webtreesdir}/language/extra/
%lang(id) %{webtreesdir}/language/extra/
%lang(ja) %{webtreesdir}/language/extra/
%lang(ka) %{webtreesdir}/language/extra/
%lang(ko) %{webtreesdir}/language/extra/
%lang(lv) %{webtreesdir}/language/extra/
%lang(mi) %{webtreesdir}/language/extra/
%lang(ms) %{webtreesdir}/language/extra/
%lang(ne) %{webtreesdir}/language/extra/
%lang(oc) %{webtreesdir}/language/extra/
%lang(ro) %{webtreesdir}/language/extra/
%lang(sl) %{webtreesdir}/language/extra/
%lang(sr) %{webtreesdir}/language/extra/
%lang(ta) %{webtreesdir}/language/extra/
%lang(tt) %{webtreesdir}/language/extra/
%lang(yi) %{webtreesdir}/language/extra/
%lang(zh_TW) %{webtreesdir}/language/extra/
%lang(fi) %{webtreesdir}/language/
%lang(fr) %{webtreesdir}/language/
%lang(he) %{webtreesdir}/language/
%lang(hr) %{webtreesdir}/language/
%lang(hu) %{webtreesdir}/language/
%lang(is) %{webtreesdir}/language/
%lang(it) %{webtreesdir}/language/
%lang(lt) %{webtreesdir}/language/
%lang(mr) %{webtreesdir}/language/
%lang(nb) %{webtreesdir}/language/
%lang(nl) %{webtreesdir}/language/
%lang(nn) %{webtreesdir}/language/
%lang(pl) %{webtreesdir}/language/
%lang(pt) %{webtreesdir}/language/
%lang(pt_BR) %{webtreesdir}/language/
%lang(ru) %{webtreesdir}/language/
%lang(sk) %{webtreesdir}/language/
%lang(sv) %{webtreesdir}/language/
%lang(tr) %{webtreesdir}/language/
%lang(uk) %{webtreesdir}/language/
%lang(vi) %{webtreesdir}/language/
%lang(zh_CN) %{webtreesdir}/language/

# configuration and data repository
%dir %attr(750, %{httpduser}, %{httpdgroup}) %{_localstatedir}/lib/%{name}
%config(noreplace) %{_localstatedir}/lib/%{name}/config.ini.php
%config(noreplace) %{httpconfdir}/conf.d/%{name}.conf