File orientdb.spec of Package orientdb

#
# spec file for package orientdb
#
# 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/
#


%if 0%{?suse_version} > 1140 || 0%{?fedora_version} > 14
%define has_systemd 1
%else
%define has_systemd 0
%endif

Name:           orientdb
Version:        2.2.10
Release:        0
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

Source0:        %{name}-%{version}.tar.gz
Source1:        %{name}.service

Url:            http://www.orientdb.org

# https://github.com/orientechnologies/orientdb/tags
BuildRequires:  maven
BuildRequires:  java-devel
# this Requires imports the path we install stuff into
# there must be a better way to get that result.
Requires:       java

%if 0%{?suse_version}
# for groupadd and useradd
Requires(pre):      shadow
%endif

%if 0%{?has_systemd}
BuildRequires:  systemd
%{?systemd_requires}
%endif

Summary:        NoSQL Graph/Document datbase
License:        Apache-2.0
Group:          Productivity/Databases/Servers

%description
OrientDB is an Open Source NoSQL DBMS with the features of both Document
and Graph DBMSs. It's written in Java and it's amazingly fast: it can
store up to 150,000 records per second on common hardware. Even for a
Document based database the relationships are managed as in Graph
Databases with direct connections among records. You can traverse parts
of or entire trees and graphs of records in a few milliseconds. Supports
schema-less, schema-full and schema-mixed modes. Has a strong security
profiling system based on user and roles and supports SQL amongst the
query languages. Thanks to the SQL layer it's straightforward to use for
people skilled in the Relational world.

%package studio
Requires:       %{name}
Requires:       node.js
BuildRequires:  libcares-devel
Requires:       bower
Requires:       compass
Requires:       npm
Requires:       yo
Summary:        OrientDB Studio web application
Group:          Productivity/Databases/Tools

%description studio
OrientDB Studio is a client-side web application built using HTML, CSS
and jQuery. It executes commands against a OrientDB Server using the
OrientDB HTTP REST protocol and Ajax calls. 

%prep
%setup -q

%build
mvn clean install

%install
cd ../releases/%{name}-community-%{version}
mkdir -p $RPM_BUILD_ROOT%{_docdir}/%{name}
install -D -d benchmarks $RPM_BUILD_ROOT%{_docdir}/%{name}
install *.txt -m 644  $RPM_BUILD_ROOT%{_docdir}/%{name}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}/bin
cp bin/*.sh $RPM_BUILD_ROOT%{_datadir}/%{name}/bin
chmod 0755 $RPM_BUILD_ROOT%{_datadir}/%{name}/bin/*
cp -a config $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -a lib $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -a log $RPM_BUILD_ROOT%{_datadir}/%{name}
cp -a plugins $RPM_BUILD_ROOT%{_datadir}/%{name}
mkdir -p $RPM_BUILD_ROOT%{_bindir}
ln -s %{_datadir}/%{name}/bin/console.sh $RPM_BUILD_ROOT%{_bindir}/%{name}

%if 0%{?has_systemd}
install -D -m 644 %{S:1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
ln -sf %{_sbindir}/service $RPM_BUILD_ROOT%{_sbindir}/rc%{name}
%endif

# studio
cp -a www $RPM_BUILD_ROOT%{_datadir}/%{name}

%pre
# Start of preinstall
#           install   remove   upgrade  reinstall
# pre          1        -         2         2
#
if [ $1 -gt 0 ]; then
   #  Create the 'orientdb' user and group:
   /usr/sbin/groupadd orientdb > /dev/null 2>&1 || :;
   /usr/sbin/useradd -c "OrientDB graph/document database" \
        -g orientdb -s /sbin/nologin -r -d %{_datadir}/%{name} orientdb \
         > /dev/null 2>&1 || :;
fi

%if 0%{?has_systemd}
  %service_add_pre %{name}.service
%endif

%post
#           install   remove   upgrade  reinstall
# %post        1        -         2         2
if [ $1 -eq 1 ]; then
  chown -R orientdb.orientdb %{_datadir}/%{name}
  %if 0%{?has_systemd}
    %service_add_post %{name}.service
  %endif
elif [ $1 -gt 0 ]; then
  %if 0%{?has_systemd}
    /usr/bin/systemctl condrestart %{name}.service >/dev/null 2>&1 || :
  %endif
fi

%preun
# Start of section pegasus/rpm/tog-specfiles/tog-pegasus-preun.spec
#           install   remove   upgrade  reinstall
#  preun       -        0         1         -
if [ $1 -eq 0 ]; then
  %if 0%{?has_systemd}
    %service_del_preun %{name}.service
  %endif
fi

%postun
#           install   remove   upgrade  reinstall
#  postun      -        0         1         -
%if 0%{?has_systemd}
  %service_del_postun %{name}.service
%endif
if [ $1 -eq 0 ]; then
   /usr/sbin/userdel orientdb > /dev/null 2>&1 || :;
   /usr/sbin/groupdel orientdb > /dev/null 2>&1 || :;
fi;

%files
%defattr(-,root,root)
%{_bindir}/%{name}
%doc %{_docdir}/%{name}
%dir %{_datadir}/%{name}
%exclude %{_datadir}/%{name}/www
%{_datadir}/%{name}
%if 0%{?has_systemd}
%{_unitdir}/%{name}.service
%{_sbindir}/rc%{name}
%endif

%files studio
%defattr(-,root,root)
%dir %{_datadir}/%{name}/www
%{_datadir}/%{name}/www

%changelog
openSUSE Build Service is sponsored by