bacula/bacula.spec

changeset 20
8adc5213fd55
child 21
5ba5c2911c12
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/bacula/bacula.spec	Wed Jan 07 00:25:41 2009 +0100
     1.3 @@ -0,0 +1,296 @@
     1.4 +##
     1.5 +##  bacula.spec -- OpenPKG RPM Package Specification
     1.6 +##  Copyright (c) 2000-2008 OpenPKG Foundation e.V. <http://openpkg.net/>
     1.7 +##
     1.8 +##  Permission to use, copy, modify, and distribute this software for
     1.9 +##  any purpose with or without fee is hereby granted, provided that
    1.10 +##  the above copyright notice and this permission notice appear in all
    1.11 +##  copies.
    1.12 +##
    1.13 +##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    1.14 +##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    1.15 +##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    1.16 +##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    1.17 +##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.18 +##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    1.19 +##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    1.20 +##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    1.21 +##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    1.22 +##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    1.23 +##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.24 +##  SUCH DAMAGE.
    1.25 +##
    1.26 +
    1.27 +#   package information
    1.28 +Name:         bacula
    1.29 +Summary:      Network Backup Tool
    1.30 +URL:          http://www.bacula.org/
    1.31 +Vendor:       Kern Sibbald
    1.32 +Packager:     OpenPKG Foundation e.V.
    1.33 +Distribution: OpenPKG Community
    1.34 +Class:        PLUS
    1.35 +Group:        System
    1.36 +License:      GPL
    1.37 +Version:      2.4.3
    1.38 +Release:      20081013
    1.39 +
    1.40 +#   package options
    1.41 +%option       with_server       yes
    1.42 +%option       with_ssl          yes
    1.43 +%option       with_wrap         no
    1.44 +%option       with_dvd          no
    1.45 +%option       with_mtx          no
    1.46 +%option       with_python       no
    1.47 +%option       with_db_sqlite    no
    1.48 +%option       with_db_pgsql     no
    1.49 +%option       with_db_mysql     no
    1.50 +
    1.51 +#   package option sanity check
    1.52 +%if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
    1.53 +%undefine     with_db_sqlite
    1.54 +%define       with_db_sqlite    yes
    1.55 +%endif
    1.56 +
    1.57 +#   list of sources
    1.58 +Source0:      http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
    1.59 +Source1:      rc.bacula
    1.60 +Source2:      bexec.sh
    1.61 +Patch0:       bacula.patch
    1.62 +
    1.63 +#   build information
    1.64 +Prefix:       %{l_prefix}
    1.65 +BuildRoot:    %{l_buildroot}
    1.66 +BuildPreReq:  OpenPKG, openpkg >= 20060823, make, gcc, gcc::with_cxx = yes
    1.67 +PreReq:       OpenPKG, openpkg >= 20060823
    1.68 +BuildPreReq:  readline, zlib
    1.69 +PreReq:       readline, zlib
    1.70 +%if "%{with_ssl}" == "yes"
    1.71 +BuildPreReq:  openssl >= 0.9.8
    1.72 +PreReq:       openssl >= 0.9.8
    1.73 +%endif
    1.74 +%if "%{with_wrap}" == "yes"
    1.75 +BuildPreReq:  tcpwrappers
    1.76 +PreReq:       tcpwrappers
    1.77 +%endif
    1.78 +%if "%{with_db_sqlite}" == "yes"
    1.79 +BuildPreReq:  sqlite
    1.80 +PreReq:       sqlite
    1.81 +%endif
    1.82 +%if "%{with_db_mysql}" == "yes"
    1.83 +BuildPreReq:  mysql
    1.84 +PreReq:       mysql
    1.85 +%endif
    1.86 +%if "%{with_db_pgsql}" == "yes"
    1.87 +BuildPreReq:  postgresql
    1.88 +PreReq:       postgresql
    1.89 +%endif
    1.90 +%if "%{with_dvd}" == "yes"
    1.91 +BuildPreReq:  dvdrw-tools
    1.92 +PreReq:       dvdrw-tools
    1.93 +%endif
    1.94 +%if "%{with_mtx}" == "yes"
    1.95 +BuildPreReq:  mtx
    1.96 +PreReq:       mtx
    1.97 +%endif
    1.98 +%if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
    1.99 +BuildPreReq:  python
   1.100 +PreReq:       python
   1.101 +%endif
   1.102 +AutoReq:      no
   1.103 +AutoReqProv:  no
   1.104 +
   1.105 +%description
   1.106 +    Bacula is a set of computer programs that permit you (or the system
   1.107 +    administrator) to manage backup, recovery, and verification of
   1.108 +    computer data across a network of computers of different kinds. In
   1.109 +    technical terms, it is a network client/server based backup program.
   1.110 +    Bacula is relatively easy to use and efficient, while offering many
   1.111 +    advanced storage management features that make it easy to find and
   1.112 +    recover lost or damaged files.
   1.113 +
   1.114 +%track
   1.115 +    prog bacula = {
   1.116 +        version   = %{version}
   1.117 +        url       = http://prdownloads.sourceforge.net/bacula/
   1.118 +        regex     = bacula-(\d+\.\d*[02468]\.\d+)\.tar\.gz
   1.119 +    }
   1.120 +
   1.121 +%prep
   1.122 +    %setup -q
   1.123 +    %patch -p0
   1.124 +    rm -f src/lib/tcpd.h
   1.125 +
   1.126 +%build
   1.127 +    #   generate a random director password
   1.128 +    password="`openssl rand -base64 33`"
   1.129 +
   1.130 +    #   for the same reason remove version informations from config files
   1.131 +    %{l_shtool} subst \
   1.132 +        -e "s;For Bacula release @VERSION@ .*;;" \
   1.133 +        `find . -name "*.conf.in"`
   1.134 +
   1.135 +    #   use localhost as default host
   1.136 +    %{l_shtool} subst \
   1.137 +        -e 's;hostname=.*;hostname=localhost;g' \
   1.138 +        configure
   1.139 +
   1.140 +    #   configure
   1.141 +    LIBS=
   1.142 +    case "%{l_platform -t}" in
   1.143 +        *-linux*) LIBS="-L/usr/lib/termcap";;
   1.144 +    esac
   1.145 +    CC="%{l_cc}" \
   1.146 +    CFLAGS="%{l_cflags -O}" \
   1.147 +    CPPFLAGS="%{l_cppflags}" \
   1.148 +    LDFLAGS="%{l_ldflags} $LIBS" \
   1.149 +    ./configure \
   1.150 +        --prefix=%{l_prefix} \
   1.151 +        --with-dir-user=%{l_rusr} \
   1.152 +        --with-dir-group=%{l_rgrp} \
   1.153 +        --with-sd-user=%{l_rusr} \
   1.154 +        --with-sd-group=%{l_rgrp} \
   1.155 +        --with-fd-user=%{l_susr} \
   1.156 +        --with-fd-group=%{l_sgrp} \
   1.157 +        --with-dir-password="$password" \
   1.158 +        --with-fd-password="$password" \
   1.159 +        --with-sd-password="$password" \
   1.160 +        --with-mon-dir-password="$password" \
   1.161 +        --with-mon-fd-password="$password" \
   1.162 +        --with-mon-sd-password="$password" \
   1.163 +        --disable-conio \
   1.164 +        --enable-readline \
   1.165 +        --with-readline=%{l_prefix} \
   1.166 +%if "%{with_server}" != "yes"
   1.167 +        --enable-client-only \
   1.168 +%endif
   1.169 +%if "%{with_ssl}" == "yes"
   1.170 +        --with-openssl=%{l_prefix} \
   1.171 +%endif
   1.172 +%if "%{with_wrap}" == "yes"
   1.173 +        --with-tcp-wrappers=yes \
   1.174 +%endif
   1.175 +%if "%{with_db_sqlite}" == "yes"
   1.176 +        --with-sqlite3=%{l_prefix} \
   1.177 +%endif
   1.178 +%if "%{with_db_mysql}" == "yes"
   1.179 +        --with-mysql=%{l_prefix} \
   1.180 +%endif
   1.181 +%if "%{with_db_pgsql}" == "yes"
   1.182 +        --with-postgresql=%{l_prefix} \
   1.183 +%endif
   1.184 +%if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
   1.185 +        --with-python=%{l_prefix} \
   1.186 +%endif
   1.187 +        --enable-wx-console=no \
   1.188 +        --sysconfdir=%{l_prefix}/etc/bacula \
   1.189 +        --mandir=%{l_prefix}/man \
   1.190 +        --with-scriptdir=%{l_prefix}/libexec/bacula \
   1.191 +        --with-working-dir=%{l_prefix}/var/bacula \
   1.192 +        --with-pid-dir=%{l_prefix}/var/bacula/run \
   1.193 +        --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
   1.194 +        --disable-nls
   1.195 +
   1.196 +    #   build
   1.197 +    %{l_make} %{l_mflags -O}
   1.198 +
   1.199 +%install
   1.200 +    rm -rf $RPM_BUILD_ROOT
   1.201 +
   1.202 +    #   create installation hierarchy
   1.203 +    %{l_shtool} mkdir -f -p -m 755 \
   1.204 +        $RPM_BUILD_ROOT%{l_prefix}/bin \
   1.205 +        $RPM_BUILD_ROOT%{l_prefix}/sbin \
   1.206 +        $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
   1.207 +        $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
   1.208 +        $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
   1.209 +        $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
   1.210 +        $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
   1.211 +        $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
   1.212 +        $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
   1.213 +        $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
   1.214 +        $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
   1.215 +        $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
   1.216 +        $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \
   1.217 +        $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config
   1.218 +
   1.219 +    #   install
   1.220 +    %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
   1.221 +
   1.222 +    #   strip down installation
   1.223 +    #   do not strip binaries, to make it easier to diagnose problems
   1.224 +    #   strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
   1.225 +    ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
   1.226 +      for unwanted in bconsole startmysql stopmysql; do
   1.227 +          rm -f $unwanted
   1.228 +      done
   1.229 +    ) || exit $?
   1.230 +
   1.231 +    #   install additional files
   1.232 +    %{l_shtool} install -c -m 754 %{l_value -s -a} \
   1.233 +        %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
   1.234 +
   1.235 +    #   wrap binaries to avoid to specify "-c" for each run
   1.236 +    ( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
   1.237 +      for bin in bacula-dir bacula-fd bacula-sd \
   1.238 +                 bconsole bcopy bextract bls bscan dbcheck \
   1.239 +                 tray-monitor wx-console; do
   1.240 +          if [ -x $bin ]; then
   1.241 +              mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
   1.242 +              ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
   1.243 +          fi
   1.244 +      done
   1.245 +    ) || exit $?
   1.246 +
   1.247 +    #   install run-command script
   1.248 +    %{l_shtool} install -c -m 755 %{l_value -s -a} \
   1.249 +        -e 's,@with_server@,%{with_server},g' \
   1.250 +        %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
   1.251 +
   1.252 +    #   determine installation files
   1.253 +    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
   1.254 +        %{l_files_std} \
   1.255 +        '%attr(640,%{l_musr},%{l_mgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \
   1.256 +        '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula' \
   1.257 +        '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \
   1.258 +        '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \
   1.259 +        '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \
   1.260 +        '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \
   1.261 +%if "%{with_server}" == "yes"
   1.262 +        '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
   1.263 +        '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\
   1.264 +        '%config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
   1.265 +        '%config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
   1.266 +%endif
   1.267 +        '%config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \
   1.268 +%if "%{with_server}" == "yes"
   1.269 +        '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-dir.conf' \
   1.270 +        '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-sd.conf' \
   1.271 +%endif
   1.272 +        '%attr(640,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/bacula/bacula-fd.conf'
   1.273 +
   1.274 +%files -f files
   1.275 +
   1.276 +%clean
   1.277 +    rm -rf $RPM_BUILD_ROOT
   1.278 +
   1.279 +%post
   1.280 +    #   create initial database
   1.281 +    if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
   1.282 +        $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
   1.283 +        chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
   1.284 +        chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
   1.285 +    fi
   1.286 +
   1.287 +    #   after upgrade, restart service
   1.288 +    [ $1 -eq 2 ] || exit 0
   1.289 +    eval `%{l_rc} bacula status 2>/dev/null`
   1.290 +    [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
   1.291 +    exit 0
   1.292 +
   1.293 +%preun
   1.294 +    #   before erase, stop service and remove working files
   1.295 +    [ $1 -eq 0 ] || exit 0
   1.296 +    %{l_rc} bacula stop 2>/dev/null
   1.297 +    rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
   1.298 +    exit 0
   1.299 +

mercurial