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 http://bugs.opensuse.org/
#


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

Name:           webtrees
Version:        1.6.2
Release:        0
Summary:        Online collaborative genealogy application
License:        GPL-2.0
Group:          Productivity/Networking/Web/Frontends
Url:            http://www.webtrees.net
# original source is located here
# Source0:        https://launchpad.net/webtrees/major_version/version/+download/webtrees-version.zip
# Use the download_and_recompress.sh 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
%endif
#%#else # not opsenSUSE
#Requires:       php-ZendFramework
#Requires:       php-ZendFramework-cache-backend-apc
%endif

%description
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.

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

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

%install
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}
%endif

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

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

%files
%defattr(644,root,root,755)

%dir %{webtreesdir}
%{webtreesdir}/[^l]*
%{webtreesdir}/library
%{webtreesdir}/lifespan.php
%{webtreesdir}/login.php
%{webtreesdir}/logout.php

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

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

%changelog