File yacy.spec of Package yacy

#
# spec file for package yacy
#
# Copyright (c) 2013 SUSE LINUX Products 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/
#


# Author: 
# previous Author: Michael Benz <michaelbenz@gmx.net>, Florian Richter <Florian_Richter@gmx.de>, Franz Brausse <mike-nought@gmx.de>
# 
# Date: 21.08.2014
# Based on previous spec files found in OBS
# Distributed under the terms of the GNU General Public License v2

%define  releasedate 20140916
%define  relnumber   9000

Summary:        P2P Search Engine, Web-Crawler and Proxy
License:        GPL-2.0
Group:          Productivity/Networking/Web/Utilities
Name:           yacy
Version:        1.80
Release:        0
Source:         yacy_v%{version}_%{releasedate}_%{relnumber}.tar.bz2
Url:            http://yacy.net/release/yacy_v%{version}_%{releasedate}_%{relnumber}.tar.gz
#####
PreReq:         sudo
PreReq:         coreutils
PreReq:         grep
PreReq:         sed
%if 0%{?suse_version}
PreReq:         pwdutils
%endif
%if 0%{?fedora_version}
Requires(post): fedora-usermgmt
%endif
%if 0%{?suse_version}
PreReq:         diffutils
PreReq:         %fillup_prereq
%endif
%if 0%{?fedora_version}
Requires(post):  chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
%endif
%if 0%{?mandriva_version}
Requires(pre):  rpm-helper
%endif
#####
Requires:       wget
%if 0%{?suse_version}
Requires:       java >= 1.6.0
%endif
%if 0%{?mandriva_version}
Requires:       java-1.6.0-sun
%endif
%if 0%{?fedora_version}
Requires:       java >= 1.5.0
%endif

BuildRequires:  ant
BuildRequires:  ant-apache-regexp
BuildRequires:  ant-nodeps
BuildRequires:  fdupes
BuildRequires:  m4
%if 0%{?suse_version}
BuildRequires:  java >= 1.6.0
BuildRequires:  java-devel >= 1.6.0
%endif
%if 0%{?mandriva_version}
BuildRequires:  geronimo-jaf-1.0.2-api
BuildRequires:  java-devel >= 1.5.0
%endif
%if 0%{?fedora_version}
BuildRequires:  java-1.6.0-openjdk-devel
%endif
BuildArch:      noarch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
YaCy is a Java-based peer-2-peer search engine.

It provides a personal websearch engine, which is free and decentral. The
search index is distributed over a peer2peer network. It contains a crawler,
an indexer and its own database engine. In robinson-modus, yacy can be
used for a topic-oriented search portal or to index an intranet.

Also included in YaCy is a Wiki, a P2P-message-system, a Blog and a bookmark
management system.

%prep
%setup -q -n yacy
sed -i 's/\r//' readme.txt
# Fix FSF address
sed -i 's/59 Temple Place, Suite 330, Boston, MA  02111-1307  USA/51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA/' COPYRIGHT
pushd htroot
JFILES=$(find . -name '*.java' -print)
for file in $JFILES ; do
    sed -i 's/59 Temple Place, Suite 330, Boston, MA  02111-1307  USA/51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA/' $file
done
popd

%build
# ant clean all
%if 0%{?suse_version}
m4 -DopenSUSE addon/yacyInit.m4 | sed -e '12 d' >yacy.init
%endif
%if 0%{?fedora_version}
m4 -DFedora addon/yacyInit.m4 >yacy.init
%endif
%if 0%{?mandriva_version}
m4 -DMandriva addon/yacyInit.m4 >yacy.init
%endif

%install
%ant installonlinux -DDESTDIR=%{buildroot}
mkdir -p %{buildroot}/usr/share/java/yacy/
cp lib/*.jar %{buildroot}/usr/share/java/yacy/
#__install -m 644 defaults/yacy.logging {buildroot}/usr/share/yacy/

# Do not install these binary scripts
rm -rf %{buildroot}/usr/share/yacy/bin

# location for init-script
%if 0%{?fedora_version} || 0%{?mandriva_version}
mkdir -p %{buildroot}/etc/rc.d/init.d/
install -m 755 yacy.init %{buildroot}/etc/rc.d/init.d/yacy
%else
mkdir -p %{buildroot}/etc/init.d/
install -m 755 yacy.init %{buildroot}/etc/init.d/yacy
%endif
%{__install} -d -m 0755 %{buildroot}%{_sbindir}
%{__ln_s} -f %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%fdupes -s %{buildroot}/

# create dummy directories
mkdir -p %{buildroot}/var/log/yacy
mkdir -p %{buildroot}/usr/share/yacy/DATA
mkdir -p %{buildroot}/etc/yacy

%pre
# check whether group 'yacy' already exists, if not it will be created
if ! getent group yacy >> /dev/null; then
    echo "adding group yacy"
    groupadd -r yacy
fi
# check whether user 'yacy' already exists, if not it will be created
if ! getent passwd yacy > /dev/null; then
    echo "adding user yacy"
    useradd yacy -r -g yacy -d /usr/share/yacy
fi

%post
chown yacy -R /var/lib/yacy
%if 0%{?suse_version}
%{fillup_only}
%endif
%if 0%{?fedora_version}
# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add yacy
%endif
%if 0%{?mandriva_version}
%_post_service yacy
%endif

%preun
%if 0%{?suse_version}
%stop_on_removal yacy
%endif
%if 0%{?fedora_version} || 0%{?mandriva_version}
if [ $1 = 0 ] ; then
    /sbin/service yacy stop >/dev/null 2>&1
    /sbin/chkconfig --del yacy
fi
%endif
%if 0%{?mandriva_version}
%_preun_service yacy
%endif

%postun
%if 0%{?suse_version}
%restart_on_update yacy
%insserv_cleanup
%endif
%if 0%{?fedora_version} || 0%{?mandriva_version}
if [ "$1" -ge "1" ] ; then
    /sbin/service yacy restart >/dev/null 2>&1 || :
fi
%endif
# Leave user on the system...
#if [ `getent passwd yacy` ]; then userdel yacy &> /dev/null; fi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(644,root,root,755)
%dir /var/lib/yacy/
%ghost %config %dir /var/lib/yacy/SETTINGS
%if 0%{?fedora_version} || 0%{?mandriva_version}
%config %attr (755,root,root) /etc/rc.d/init.d/yacy
%else
%attr (755,root,root) %{_sysconfdir}/init.d/yacy
%endif
%dir /usr/share/yacy
/usr/share/java/yacy
/usr/share/yacy/defaults
/usr/share/yacy/htroot
/usr/share/yacy/langstats/
/usr/share/yacy/locales
#/usr/share/yacy/ranking
/usr/share/yacy/skins
/usr/share/yacy/yacy.badwords.example
#/usr/share/yacy/yacy.logging
/usr/share/yacy/yacy.stopwords
/usr/share/yacy/yacy.yellow
%doc /usr/share/doc/yacy
%{_sbindir}/rc%{name}
# soft links
/etc/yacy
/var/log/yacy
/usr/share/yacy/DATA

%changelog
openSUSE Build Service is sponsored by