You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
308 lines
11 KiB
308 lines
11 KiB
## |
|
## bacula.spec -- OpenPKG RPM Package Specification |
|
## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/> |
|
## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/> |
|
## |
|
## Permission to use, copy, modify, and distribute this software for |
|
## any purpose with or without fee is hereby granted, provided that |
|
## the above copyright notice and this permission notice appear in all |
|
## copies. |
|
## |
|
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
## SUCH DAMAGE. |
|
## |
|
|
|
# package information |
|
Name: bacula |
|
Summary: Network Backup Tool |
|
URL: http://www.bacula.org/ |
|
Vendor: Kern Sibbald |
|
Packager: OpenPKG Foundation e.V. |
|
Distribution: OpenPKG Community |
|
Class: PLUS |
|
Group: System |
|
License: GPL |
|
Version: 1.39.34 |
|
Release: 20061229 |
|
|
|
# package options |
|
%option with_server yes |
|
%option with_ssl yes |
|
%option with_wrap no |
|
%option with_dvd no |
|
%option with_mtx no |
|
%option with_python no |
|
%option with_db_sqlite no |
|
%option with_db_pgsql no |
|
%option with_db_mysql no |
|
|
|
# package option sanity check |
|
%if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no" |
|
%undefine with_db_sqlite |
|
%define with_db_sqlite yes |
|
%endif |
|
|
|
# list of sources |
|
Source0: http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz |
|
Source1: rc.bacula |
|
Source2: bexec.sh |
|
Patch0: bacula.patch |
|
|
|
# build information |
|
Prefix: %{l_prefix} |
|
BuildRoot: %{l_buildroot} |
|
BuildPreReq: OpenPKG, openpkg >= 20060823, gcc, gzip |
|
PreReq: OpenPKG, openpkg >= 20060823 |
|
BuildPreReq: readline, zlib |
|
PreReq: readline, zlib |
|
%if "%{with_ssl}" == "yes" |
|
BuildPreReq: openssl >= 0.9.8 |
|
PreReq: openssl >= 0.9.8 |
|
%endif |
|
%if "%{with_wrap}" == "yes" |
|
BuildPreReq: tcpwrappers |
|
PreReq: tcpwrappers |
|
%endif |
|
%if "%{with_db_sqlite}" == "yes" |
|
BuildPreReq: sqlite, sqlite::with_v2 = yes |
|
PreReq: sqlite, sqlite::with_v2 = yes |
|
%endif |
|
%if "%{with_db_mysql}" == "yes" |
|
BuildPreReq: mysql |
|
PreReq: mysql |
|
%endif |
|
%if "%{with_db_pgsql}" == "yes" |
|
BuildPreReq: postgresql |
|
PreReq: postgresql |
|
%endif |
|
%if "%{with_dvd}" == "yes" |
|
BuildPreReq: dvdrw-tools |
|
PreReq: dvdrw-tools |
|
%endif |
|
%if "%{with_mtx}" == "yes" |
|
BuildPreReq: mtx |
|
PreReq: mtx |
|
%endif |
|
%if "%{with_python}" == "yes" || "%{with_dvd}" == "yes" |
|
BuildPreReq: python |
|
PreReq: python |
|
%endif |
|
AutoReq: no |
|
AutoReqProv: no |
|
|
|
%description |
|
Bacula 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. Bacula 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. |
|
|
|
%track |
|
prog bacula = { |
|
version = %{version} |
|
url = http://prdownloads.sourceforge.net/bacula/ |
|
regex = bacula-(\d+\.\d+\.\d+)\.tar\.gz |
|
} |
|
|
|
%prep |
|
%setup -q |
|
%patch -p0 |
|
rm -f src/lib/tcpd.h |
|
|
|
%build |
|
# delay generation of default passwords until installation, else |
|
# the config files change on every install leading _always_ to |
|
# the generation of .rpmnew files which prevent rc start/stop/restart |
|
for pwd in dir_password fd_password sd_password \ |
|
mon_dir_password mon_fd_password mon_sd_password; do |
|
%{l_shtool} subst \ |
|
-e "s;^s,@$pwd@,;s,@-$pwd-@,;" \ |
|
configure |
|
done |
|
|
|
# for the same reason remove version informations from config files |
|
%{l_shtool} subst \ |
|
-e "s;For Bacula release @VERSION@ .*;;" \ |
|
`find . -name "*.conf.in"` |
|
|
|
# use localhost as default host |
|
%{l_shtool} subst \ |
|
-e 's/s,@hostname@,$hostname,/s,@hostname@,localhost,/' \ |
|
configure |
|
|
|
# configure |
|
LIBS= |
|
case "%{l_platform -t}" in |
|
*-linux*) LIBS="-L/usr/lib/termcap";; |
|
esac |
|
CC="%{l_cc}" \ |
|
CFLAGS="%{l_cflags -O}" \ |
|
CPPFLAGS="%{l_cppflags}" \ |
|
LDFLAGS="%{l_ldflags} $LIBS" \ |
|
./configure \ |
|
--prefix=%{l_prefix} \ |
|
--with-dir-user=%{l_rusr} \ |
|
--with-dir-group=%{l_rgrp} \ |
|
--with-sd-user=%{l_rusr} \ |
|
--with-sd-group=%{l_rgrp} \ |
|
--with-fd-user=%{l_susr} \ |
|
--with-fd-group=%{l_sgrp} \ |
|
--disable-conio \ |
|
--enable-readline \ |
|
--with-readline=%{l_prefix} \ |
|
%if "%{with_server}" == "no" |
|
--enable-client-only |
|
%endif |
|
%if "%{with_ssl}" == "yes" |
|
--with-openssl=%{l_prefix} \ |
|
%endif |
|
%if "%{with_wrap}" == "yes" |
|
--with-tcp-wrappers=yes \ |
|
%endif |
|
%if "%{with_db_sqlite}" == "yes" |
|
--with-sqlite=%{l_prefix} \ |
|
%endif |
|
%if "%{with_db_mysql}" == "yes" |
|
--with-mysql=%{l_prefix} \ |
|
%endif |
|
%if "%{with_db_pgsql}" == "yes" |
|
--with-postgresql=%{l_prefix} \ |
|
%endif |
|
%if "%{with_python}" == "yes" || "%{with_dvd}" == "yes" |
|
--with-python=%{l_prefix} \ |
|
%endif |
|
--enable-wx-console=no \ |
|
--sysconfdir=%{l_prefix}/etc/bacula \ |
|
--mandir=%{l_prefix}/man \ |
|
--with-scriptdir=%{l_prefix}/libexec/bacula \ |
|
--with-working-dir=%{l_prefix}/var/bacula \ |
|
--with-pid-dir=%{l_prefix}/var/bacula/run \ |
|
--with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \ |
|
--disable-nls |
|
|
|
# build |
|
%{l_make} %{l_mflags -O} |
|
|
|
%install |
|
rm -rf $RPM_BUILD_ROOT |
|
|
|
# create installation hierarchy |
|
%{l_shtool} mkdir -f -p -m 755 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/bin \ |
|
$RPM_BUILD_ROOT%{l_prefix}/sbin \ |
|
$RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/bacula \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/bacula \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \ |
|
$RPM_BUILD_ROOT%{l_prefix}/man/man1 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/man/man8 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \ |
|
$RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config |
|
|
|
# install |
|
%{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT |
|
|
|
# strip down installation |
|
# do not strip binaries, to make it easier to diagnose problems |
|
# strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true |
|
( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula && |
|
for unwanted in bconsole startmysql stopmysql; do |
|
rm -f $unwanted |
|
done |
|
) || exit $? |
|
|
|
# install additional files |
|
%{l_shtool} install -c -m 754 %{l_value -s -a} \ |
|
%{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec |
|
|
|
# wrap binaries to avoid to specify "-c" for each run |
|
( cd $RPM_BUILD_ROOT%{l_prefix}/sbin |
|
for bin in bacula-dir bacula-fd bacula-sd \ |
|
bconsole bcopy bextract bls bscan dbcheck \ |
|
tray-monitor wx-console; do |
|
if [ -x $bin ]; then |
|
mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula |
|
ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin |
|
fi |
|
done |
|
) || exit $? |
|
|
|
# install run-command script |
|
%{l_shtool} install -c -m 644 %{l_value -s -a} \ |
|
-e 's,@with_server@,%{with_server},g' \ |
|
%{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
|
|
|
# unpack manual pages |
|
%{l_gzip} -d $RPM_BUILD_ROOT%{l_prefix}/man/man1/*.gz |
|
%{l_gzip} -d $RPM_BUILD_ROOT%{l_prefix}/man/man8/*.gz |
|
|
|
# determine installation files |
|
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
|
%{l_files_std} \ |
|
'%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula' \ |
|
'%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \ |
|
'%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \ |
|
'%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \ |
|
'%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \ |
|
'%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \ |
|
'%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\ |
|
'%config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \ |
|
'%config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \ |
|
'%config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \ |
|
'%config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \ |
|
'%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-sd.conf' \ |
|
'%attr(640,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/bacula/bacula-fd.conf' \ |
|
'%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-dir.conf' \ |
|
'%attr(640,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/bacula/bconsole.conf' |
|
|
|
%files -f files |
|
|
|
%clean |
|
rm -rf $RPM_BUILD_ROOT |
|
|
|
%post |
|
# create initial database |
|
if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then |
|
$RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables |
|
chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db |
|
chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db |
|
fi |
|
|
|
# generate default passwords |
|
for pwd in dir_password fd_password sd_password \ |
|
mon_dir_password mon_fd_password mon_sd_password; do |
|
%{l_shtool} subst \ |
|
-e "s;@$pwd@;`openssl rand -base64 33`;" \ |
|
$RPM_INSTALL_PREFIX/etc/bacula/*.conf \ |
|
$RPM_INSTALL_PREFIX/etc/bacula/*.conf.rpmnew 2>/dev/null |
|
done |
|
|
|
# after upgrade, restart service |
|
[ $1 -eq 2 ] || exit 0 |
|
eval `%{l_rc} bacula status 2>/dev/null` |
|
[ ".$bacula_active" = .yes ] && %{l_rc} bacula restart |
|
exit 0 |
|
|
|
%preun |
|
# before erase, stop service and remove working files |
|
[ $1 -eq 0 ] || exit 0 |
|
%{l_rc} bacula stop 2>/dev/null |
|
rm -rf $RPM_INSTALL_PREFIX/var/bacula/* |
|
exit 0 |
|
|
|
|