## ## bacula.spec -- OpenPKG RPM Package Specification ## Copyright (c) 2000-2005 OpenPKG Foundation e.V. ## Copyright (c) 2000-2005 Ralf S. Engelschall ## ## 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. ## # FIXME: rse: "odoc" support still not in final shape # package component versions %define V_bacula 1.37.36 %define V_doc 20050823 # package information Name: bacula Summary: Network Backup Tool URL: http://www.bacula.org/ Vendor: Kern Sibbald Packager: OpenPKG Distribution: OpenPKG Class: EVAL Group: System License: GPL Version: %{V_bacula} Release: 20050824 # package options %option with_server yes %option with_user %{l_rusr} %option with_group %{l_rgrp} %option with_ssl yes %option with_wrap no %option with_db sqlite %option with_dvd no %option with_mtx no %option with_python no %option with_wxconsole no %option with_traymonitor no # list of sources Source0: http://prdownloads.sourceforge.net/bacula/bacula-%{version}.tar.gz Source1: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/bacula/bacula-doc-%{V_doc}.tar.gz Source2: rc.bacula Source3: bexec.sh Patch0: bacula.patch # build information Prefix: %{l_prefix} BuildRoot: %{l_buildroot} BuildPreReq: OpenPKG, openpkg >= 20040712, gcc, odoc PreReq: OpenPKG, openpkg >= 20040712 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" BuildPreReq: sqlite PreReq: sqlite %endif %if "%{with_db}" == "mysql" BuildPreReq: mysql PreReq: mysql %endif %if "%{with_db}" == "postgres" 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 %if "%{with_wxconsole}" == "yes" BuildPreReq: wx PreReq: wx %endif %if "%{with_traymonitor}" == "yes" BuildPreReq: gtk2 PreReq: gtk2 %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-(__VER__)\.tar\.gz } %prep %setup -q %setup -q -D -T -b 1 %patch -p0 rm 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 # use localhost as default host %{l_shtool} subst \ -e 's/s,@hostname@,$hostname,/s,@hostname@,localhost,/' \ configure # configure case "%{with_db}" in sqlite ) cfg_db="--with-sqlite=%{l_prefix}" ;; mysql ) cfg_db="--with-mysql=%{l_prefix}" ;; pgsql ) cfg_db="--with-postgresql=%{l_prefix}" ;; * ) echo "with_db must be in (sqlite|mysql|pgsql)" 1>&2; exit 1 ;; esac CC="%{l_cc}" \ CFLAGS="%{l_cflags -O}" \ CPPFLAGS="%{l_cppflags}" \ LDFLAGS="%{l_ldflags}" \ ./configure \ --prefix=%{l_prefix} \ --with-dir-user=%{with_user} \ --with-dir-group=%{with_group} \ --with-sd-user=%{with_user} \ --with-sd-group=%{with_group} \ --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 $cfg_db \ %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes" --with-python=%{l_prefix} \ %endif %if "%{with_wxconsole}" == "yes" --enable-wx-console=yes \ %endif --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/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/man8 \ $RPM_BUILD_ROOT%{l_prefix}/share/bacula/docs \ $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \ $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config \ $RPM_BUILD_ROOT%{l_docdir}/bacula # 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 $? rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/bacula.8.gz # 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/ # install documentation/examples %{l_shtool} install -c -m 644 \ -e 's,/usr/share/doc/bacula-,%{l_prefix}/doc/bacula,' \ scripts/bacula.man $RPM_BUILD_ROOT%{l_prefix}/man/man8/bacula.8 if %{l_odoc} -F; then echo "WARNING: will not package auxiliary documentation" 1>&2 else mv ../bacula-doc-%{V_doc}/* $RPM_BUILD_ROOT%{l_docdir}/bacula/ %{l_odoc} -ame %{_specdir}/bacula.spec fi # determine installation files %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ %{l_files_std} \ '%attr(750,%{with_user},%{with_group}) %{l_prefix}/var/bacula' \ '%attr(750,%{with_user},%{with_group}) %{l_prefix}/var/bacula/run' \ '%attr(750,%{with_user},%{with_group}) %{l_prefix}/var/bacula/run/subsys' \ '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/dvd-freespace' \ '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/dvd-writepart' \ '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/mtx-changer' \ '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/make_catalog_backup' \ '%attr(-,-,%{with_group}) %{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' \ %if "%{with_wxconsole}" == "yes" '%config(noreplace) %{l_prefix}/etc/bacula/wx-console.conf' \ %endif %if "%{with_traymonitor}" == "yes" '%config(noreplace) %{l_prefix}/etc/bacula/tray-monitor.conf' \ %endif '%config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' %files -f files %docdir %{l_docdir} %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 %{with_user}:%{with_group} $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