File bareos-webui.spec of Package bareos-webui

#
# spec file for package bareos-webui
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2013-2016 Bareos GmbH & Co KG
#
# 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}
#BuildRequires: mod_php%{php_major_version}
#define _apache_conf_dir #(/usr/sbin/apxs2 -q SYSCONFDIR)
%define _apache_conf_dir %{_sysconfdir}/apache2/conf.d/
%define daemon_user  wwwrun
%define daemon_group www
BuildRequires:  apache2
# /usr/sbin/apxs2
BuildRequires:  apache2-devel
Requires:       apache
Requires:       mod_php_any
%else
%define _apache_conf_dir %{_sysconfdir}/httpd/conf.d/
%define daemon_user  apache
%define daemon_group apache
#if 0#{?fedora} || 0#{?rhel_version} || 0#{?centos_version}
BuildRequires:  httpd
# apxs2
BuildRequires:  httpd-devel
Requires:       httpd
Requires:       mod_php
%endif
Name:           bareos-webui
Version:        16.2.7
Release:        0
Summary:        Bareos Web User Interface
License:        AGPL-3.0+
Group:          Productivity/Archiving/Backup
URL:            http://www.bareos-webui.org/
Source:         https://github.com/bareos/bareos-webui/archive/Release/%{version}.tar.gz
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bareos-common
BuildRequires:  php
#define        php_major_version       %(php -r "echo PHP_MAJOR_VERSION;")
# ZendFramework 2.4 says it required php >= 5.3.23.
# However, it works on SLES 11 with php 5.3.17
# while it does not work with php 5.3.3 (RHEL6).
Requires:       php >= 5.3.17
Requires:       php-bz2
Requires:       php-ctype
Requires:       php-curl
Requires:       php-date
Requires:       php-dom
Requires:       php-fileinfo
Requires:       php-filter
Requires:       php-gd
Requires:       php-gettext
Requires:       php-hash
Requires:       php-iconv
Requires:       php-intl
Requires:       php-json
Requires:       php-mbstring
#Requires: php-mysql
Requires:       php-openssl
Requires:       php-pcre
#Requires: php-pdo
#Requires: php-pecl
#Requires: php-pgsql
Requires:       php-reflection
Requires:       php-session
Requires:       php-simplexml
Requires:       php-spl
Requires:       php-xml
Requires:       php-xmlreader
Requires:       php-xmlwriter
Requires:       php-zip
BuildArch:      noarch
%if 0%{?suse_version}
%else
Requires:       php-libxml
%endif
#define serverroot #(/usr/sbin/apxs2 -q datadir 2>/dev/null || /usr/sbin/apxs2 -q PREFIX)/htdocs/

%description
Bareos - Backup Archiving Recovery Open Sourced. \
Bareos is a set of computer programs that permit you (or the system \
administrator) to manage backup, recovery, and verification of computer \
data across a network of computers of different kinds. In technical terms, \
it is a network client/server based backup program. Bareos is relatively \
easy to use and efficient, while offering many advanced storage management \
features that make it easy to find and recover lost or damaged files. \
Bareos source code has been released under the AGPL version 3 license.

This package contains the webui (Bareos Web User Interface).

%prep
%setup -q -n %{name}-Release-%{version}
find . -name .gitignore -exec rm {} \;
find . -name .coveralls.yml -exec rm {} \;

%build
#autoreconf -fvi
%configure
make %{?_smp_mflags}

%install
# makeinstall macro does not work on RedHat
#makeinstall
%make_install

# write version to version file
echo %{version} | grep -o  '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' > %{buildroot}/%{_datadir}/%{name}/version.txt

# With the introduction of config subdirectories (bareos-16.2)
# some config files have been renamed (or even splitted into multiple files).
# However, bareos is still able to work with the old config files,
# but rpm renames them to *.rpmsave.
# To keep the bareos working after updating to bareos-16.2,
# we implement a workaroung:
#   * post: if the old config exists, make a copy of it.
#   * (rpm exchanges files on disk)
#   * posttrans:
#       if the old config file don't exists but we have created a backup before,
#       restore the old config file.
#       Remove our backup, if it exists.
# This update helper should be removed wih bareos-17.x.

%define post_backup_file() \
if [ -f  %{1} ]; then \
      cp -a %{1} %{1}.rpmupdate.%{version}.keep; \
fi; \
%{nil}

%define posttrans_restore_file() \
if [ ! -e %{1} -a -e %{1}.rpmupdate.%{version}.keep ]; then \
   mv %{1}.rpmupdate.%{version}.keep %{1}; \
fi; \
if [ -e %{1}.rpmupdate.%{version}.keep ]; then \
   rm %{1}.rpmupdate.%{version}.keep; \
fi; \
%{nil}

%post
%post_backup_file %{_sysconfdir}/bareos/bareos-dir.d/webui-consoles.conf
%post_backup_file %{_sysconfdir}/bareos/bareos-dir.d/webui-profiles.conf
a2enmod setenv &> /dev/null || true
a2enmod rewrite &> /dev/null || true

%posttrans
%posttrans_restore_file %{_sysconfdir}/bareos/bareos-dir.d/webui-consoles.conf
%posttrans_restore_file %{_sysconfdir}/bareos/bareos-dir.d/webui-profiles.conf

%if 0%{?suse_version} >= 1315
# 1315:
#   SLES12 (PHP 7)
#   openSUSE Leap 42.1 (PHP 5)
if php -v | grep -q "PHP 7"; then
  a2enmod php7 &> /dev/null || true
else
  a2enmod php5 &> /dev/null || true
fi
%else
a2enmod php5 &> /dev/null || true
%endif

%files
%doc README.md LICENSE AGPL-3.0.txt AUTHORS
%doc doc/README-TRANSLATION.md
%doc tests/selenium
%{_datadir}/%{name}/
#attr(-, #daemon_user, #daemon_group) #{_datadir}/#{name}/data
%dir %{_sysconfdir}/bareos-webui
%config(noreplace) %{_sysconfdir}/bareos-webui/directors.ini
%config(noreplace) %{_sysconfdir}/bareos-webui/configuration.ini
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/bareos/bareos-dir.d/console/admin.conf.example
%config(noreplace) %attr(644,root,root) %{_sysconfdir}/bareos/bareos-dir.d/profile/webui-admin.conf
%config(noreplace) %{_apache_conf_dir}/bareos-webui.conf

%changelog
openSUSE Build Service is sponsored by