File bweb.spec of Package bacula-bweb

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

%define serverroot %(/usr/sbin/apxs2 -q datadir 2>/dev/null || /usr/sbin/apxs2 -q PREFIX)/htdocs/


Name:           bweb
Version:	5.0.3
Release:	1
Summary:	Bweb - A Bacula web interface
Group:		Productivity/Archiving/Backup
License: 	AGPL-3.0-only
Url:		http://www.bacula.org
#PreReq:		
Provides:	bweb-%{version}
#BuildRequires:	
Source:		bacula-gui-%{version}.tar.gz
Patch:		norootcheck.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
AutoReqProv:    on
#BuildArch:	noarch

%if 0%{?suse_version}
BuildRequires:  apache2-devel libapr-util1-devel
%endif
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
BuildRequires: httpd-devel apr-devel
%endif
BuildRequires:  make perl-DBI perl-GDTextUtil perl-GDGraph perl-GD perl-HTML-Template perl-CGI-Simple perl-Expect perl-Date-Calc perl-Time-modules

Requires: 	perl-DBI perl-DBD-Pg perl-GDTextUtil perl-GDGraph perl-GD perl-HTML-Template perl-CGI-Simple perl-Expect perl-Date-Calc perl-Time-modules
Requires:       perl = %{perl_version}
Requires:       /usr/sbin/bconsole

%if 0%{?suse_version} < 1120 
BuildRequires: perl-macros 
%endif

BuildRequires:  fdupes

%description
   Bweb - A Bacula web interface
   Bacula® - The Network Backup Solution

   Copyright (C) 2000-2010 Free Software Foundation Europe e.V.

   The main author of Bweb is Eric Bollengier.
   The main author of Bacula is Kern Sibbald, with contributions from
   many others, a complete list can be found in the file AUTHORS.
   This program is Free Software; you can redistribute it and/or
   modify it under the terms of version three of the GNU Affero General Public
   License as published by the Free Software Foundation and included
   in the file LICENSE.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
   02110-1301, USA.

   Bacula® is a registered trademark of Kern Sibbald.
   The licensor of Bacula is the Free Software Foundation Europe
   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
   Switzerland, email:ftf@fsfeurope.org.

   nrsTable Copyright 2005 New Roads School (GPL)
   kaiska css Copyright Willy Morin (BWL)


%prep
%setup -n bacula-gui-%{version}
%patch -p 1

%build

%install
%{__install} -m 755 -d $RPM_BUILD_ROOT%{serverroot}%{name}
%{__cp} -dR %{name}/* $RPM_BUILD_ROOT%{serverroot}%{name}

OLDDIR=`pwd`

cd $RPM_BUILD_ROOT%{serverroot}%{name}
#$RPM_BUILD_ROOT%{serverroot}%{name}/install_bweb

# Configuration directory for bweb
#CONF_DIR=/etc/bacula
CONF_DIR=$RPM_BUILD_ROOT/etc/bacula
#
# Root directory of web files       
#
#WEB_DIR=/srv/www/htdocs
WEB_DIR=$RPM_BUILD_ROOT%{serverroot}
#
# share directory for programs
#
SHARE_DIR=$RPM_BUILD_ROOT/usr/share
#
# cgi_bin location for web server
#
#CGI_BIN=/srv/www/cgi-bin
CGI_BIN=$RPM_BUILD_ROOT%{serverroot}../cgi-bin

#
# Userid the web server is running under
#
HTTP_USER=wwwrun
HTTP_GROUP=www

# Bacula database name and password
DB=bacula
DB_PW=""
EMAIL_ADDR="xxx@localhost"
MTX="/sbin/mtx"

#if [ `whoami` != "root" ] ; then
#  echo "You must be root to run this script."
#  exit 1
#fi
#
#
# Normally you should not need to change the following
#
# first, copy the bweb perl library into your PERL5 INC path
#sed -i "s!/etc/bacula!${CONF_DIR}!" lib/Bweb.pm




perl Makefile.PL OPTIMIZE="$RPM_OPT_FLAGS -Wall"
%perl_make_install 


# copy the bweb perl program to your cgi location
if [ ! -d ${CGI_BIN}/bweb ] ; then
   mkdir -p -m 755 ${CGI_BIN}/bweb
fi

#install -m 755 -o root -g root  cgi/*.pl ${CGI_BIN}/bweb
install -m 755  cgi/*.pl ${CGI_BIN}/bweb
rm  cgi/*.pl

# get a config file
if [ ! -d ${CONF_DIR} ] ; then
   mkdir -p -m 755 ${CONF_DIR}
   #chown root:bacula ${CONF_DIR}
fi

# Setup a default ${CONF_DIR}/bweb.conf
if [ ! -e ${CONF_DIR}/bweb.conf ] ; then
cat > ${CONF_DIR}/bweb.conf <<END_OF_DATA
\$VAR1 = bless( {
  'graph_font' => '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
  'name' => undef,
  'config_file' => '/etc/bacula/bweb.conf',
  'bconsole' => '/usr/sbin/bconsole -n -c /etc/bacula/bconsole.conf',
  'ach_list' => {
     'S1_L80' => bless( {
         'info' => {
                     'drive' => 0,
                     'io' => 0,
                     'slot' => 0
                   },
         'name' => 'S1_L80',
         'bweb' => undef,
         'device' => '/dev/changer',
         'drive' => [],
         'debug' => 0,
         'label' => {},
         'precmd' => 'sudo',
         'io' => [],
         'mtxcmd' => '${MTX}',
         'drive_name' => [
                           'S1_L80_SDLT0',
                           'S1_L80_SDLT1'
                         ],
         'slot' => []
       }, 'Bweb::Autochanger' )
   },
  'password' => '${DB_PW}',
  'template_dir' => '/usr/share/bweb/tpl',
  'lang' => 'en',
  'dbi' => 'DBI:Pg:database=bacula',
  'error' => '',
  'debug' => 0,
  'user' => '${DB}',
  'email_media' => '${EMAIL_ADDR}'
}, 'Bweb::Config' );
END_OF_DATA
fi

#chown ${HTTP_USER} ${CONF_DIR}/bweb.conf

# copy the bweb template file
if [ ! -d ${SHARE_DIR}/bweb/tpl/en ] ; then
   mkdir -p ${SHARE_DIR}/bweb/tpl/{en,fr,es}
fi
install -m 644  lang/en/tpl/*.tpl ${SHARE_DIR}/bweb/tpl/en
install -m 644  lang/es/tpl/*.tpl ${SHARE_DIR}/bweb/tpl/es
install -m 644  lang/fr/tpl/*.tpl ${SHARE_DIR}/bweb/tpl/fr

# copy the bweb graphics elements (bweb elements must reside in /bweb)
if [ ! -d ${WEB_DIR}/bweb ] ; then
   mkdir -p ${WEB_DIR}/bweb
fi
install -m 644  html/*.{js,png,css,gif,ico,html} ${WEB_DIR}/bweb


%perl_process_packlist

%perl_gen_filelist
mv $RPM_BUILD_ROOT/%{serverroot}/%{name}/%{name}.files  /tmp

%fdupes $RPM_BUILD_ROOT/%{serverroot}

%clean
rm -rf $RPM_BUILD_ROOT

%post
echo " "
echo "Please edit ${CONF_DIR}/bweb.conf and ensure that all the paths to"
echo "  the various programs and files such as bconsole, bconsole.conf"
echo "  are correct, and that the DBI driver is correct (default mysql)"
echo "  and has the right password for your DB"
echo " "
echo "You have to load sql scripts (in bweb/script) to your database with"
echo "  something like :"
echo "   root# mysql bacula < script/bweb-mysql.sql"
echo "  or"
echo "   postgres# echo 'CREATE PROCEDURAL LANGUAGE plpgsql;' | psql bacula"
echo "   postgres# psql -U bacula bacula < script/bweb/bweb-postgresql.sql"
echo " "

#%postun


%files -f /tmp/%{name}.files
%defattr(-, root, root, -)
%{serverroot}/%{name}
%{serverroot}/../cgi-bin/%{name}
%config /etc/bacula/bweb.conf
/usr/share/bweb
/etc/bacula
#/usr/share/bweb/tpl
#/usr/share/bweb/tpl/*

#%doc Changes README COPYING

%changelog
openSUSE Build Service is sponsored by