bacula.spec 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. ##
  2. ## bacula.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2007 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2007 Ralf S. Engelschall <http://engelschall.com/>
  5. ##
  6. ## Permission to use, copy, modify, and distribute this software for
  7. ## any purpose with or without fee is hereby granted, provided that
  8. ## the above copyright notice and this permission notice appear in all
  9. ## copies.
  10. ##
  11. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  12. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  14. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  15. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  17. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  18. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  19. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  20. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  21. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  22. ## SUCH DAMAGE.
  23. ##
  24. # package information
  25. Name: bacula
  26. Summary: Network Backup Tool
  27. URL: http://www.bacula.org/
  28. Vendor: Kern Sibbald
  29. Packager: OpenPKG Foundation e.V.
  30. Distribution: OpenPKG Community
  31. Class: PLUS
  32. Group: System
  33. License: GPL
  34. Version: 2.1.26
  35. Release: 20070712
  36. # package options
  37. %option with_server yes
  38. %option with_ssl yes
  39. %option with_wrap no
  40. %option with_dvd no
  41. %option with_mtx no
  42. %option with_python no
  43. %option with_db_sqlite no
  44. %option with_db_pgsql no
  45. %option with_db_mysql no
  46. # package option sanity check
  47. %if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
  48. %undefine with_db_sqlite
  49. %define with_db_sqlite yes
  50. %endif
  51. # list of sources
  52. Source0: http://switch.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
  53. Source1: rc.bacula
  54. Source2: bexec.sh
  55. Patch0: bacula.patch
  56. # build information
  57. Prefix: %{l_prefix}
  58. BuildRoot: %{l_buildroot}
  59. BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, gcc::with_cxx = yes
  60. PreReq: OpenPKG, openpkg >= 20060823
  61. BuildPreReq: readline, zlib
  62. PreReq: readline, zlib
  63. %if "%{with_ssl}" == "yes"
  64. BuildPreReq: openssl >= 0.9.8
  65. PreReq: openssl >= 0.9.8
  66. %endif
  67. %if "%{with_wrap}" == "yes"
  68. BuildPreReq: tcpwrappers
  69. PreReq: tcpwrappers
  70. %endif
  71. %if "%{with_db_sqlite}" == "yes"
  72. BuildPreReq: sqlite
  73. PreReq: sqlite
  74. %endif
  75. %if "%{with_db_mysql}" == "yes"
  76. BuildPreReq: mysql
  77. PreReq: mysql
  78. %endif
  79. %if "%{with_db_pgsql}" == "yes"
  80. BuildPreReq: postgresql
  81. PreReq: postgresql
  82. %endif
  83. %if "%{with_dvd}" == "yes"
  84. BuildPreReq: dvdrw-tools
  85. PreReq: dvdrw-tools
  86. %endif
  87. %if "%{with_mtx}" == "yes"
  88. BuildPreReq: mtx
  89. PreReq: mtx
  90. %endif
  91. %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
  92. BuildPreReq: python
  93. PreReq: python
  94. %endif
  95. AutoReq: no
  96. AutoReqProv: no
  97. %description
  98. Bacula is a set of computer programs that permit you (or the system
  99. administrator) to manage backup, recovery, and verification of
  100. computer data across a network of computers of different kinds. In
  101. technical terms, it is a network client/server based backup program.
  102. Bacula is relatively easy to use and efficient, while offering many
  103. advanced storage management features that make it easy to find and
  104. recover lost or damaged files.
  105. %track
  106. prog bacula = {
  107. version = %{version}
  108. url = http://prdownloads.sourceforge.net/bacula/
  109. regex = bacula-(\d+\.\d+\.\d+)\.tar\.gz
  110. }
  111. %prep
  112. %setup -q
  113. %patch -p0
  114. rm -f src/lib/tcpd.h
  115. %build
  116. # generate a random director password
  117. password="`openssl rand -base64 33`"
  118. # for the same reason remove version informations from config files
  119. %{l_shtool} subst \
  120. -e "s;For Bacula release @VERSION@ .*;;" \
  121. `find . -name "*.conf.in"`
  122. # use localhost as default host
  123. %{l_shtool} subst \
  124. -e 's;hostname=.*;hostname=localhost;g' \
  125. configure
  126. # configure
  127. LIBS=
  128. case "%{l_platform -t}" in
  129. *-linux*) LIBS="-L/usr/lib/termcap";;
  130. esac
  131. CC="%{l_cc}" \
  132. CFLAGS="%{l_cflags -O}" \
  133. CPPFLAGS="%{l_cppflags}" \
  134. LDFLAGS="%{l_ldflags} $LIBS" \
  135. ./configure \
  136. --prefix=%{l_prefix} \
  137. --with-dir-user=%{l_rusr} \
  138. --with-dir-group=%{l_rgrp} \
  139. --with-sd-user=%{l_rusr} \
  140. --with-sd-group=%{l_rgrp} \
  141. --with-fd-user=%{l_susr} \
  142. --with-fd-group=%{l_sgrp} \
  143. --with-dir-password="$password" \
  144. --with-fd-password="$password" \
  145. --with-sd-password="$password" \
  146. --with-mon-dir-password="$password" \
  147. --with-mon-fd-password="$password" \
  148. --with-mon-sd-password="$password" \
  149. --disable-conio \
  150. --enable-readline \
  151. --with-readline=%{l_prefix} \
  152. %if "%{with_server}" != "yes"
  153. --enable-client-only \
  154. %endif
  155. %if "%{with_ssl}" == "yes"
  156. --with-openssl=%{l_prefix} \
  157. %endif
  158. %if "%{with_wrap}" == "yes"
  159. --with-tcp-wrappers=yes \
  160. %endif
  161. %if "%{with_db_sqlite}" == "yes"
  162. --with-sqlite3=%{l_prefix} \
  163. %endif
  164. %if "%{with_db_mysql}" == "yes"
  165. --with-mysql=%{l_prefix} \
  166. %endif
  167. %if "%{with_db_pgsql}" == "yes"
  168. --with-postgresql=%{l_prefix} \
  169. %endif
  170. %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
  171. --with-python=%{l_prefix} \
  172. %endif
  173. --enable-wx-console=no \
  174. --sysconfdir=%{l_prefix}/etc/bacula \
  175. --mandir=%{l_prefix}/man \
  176. --with-scriptdir=%{l_prefix}/libexec/bacula \
  177. --with-working-dir=%{l_prefix}/var/bacula \
  178. --with-pid-dir=%{l_prefix}/var/bacula/run \
  179. --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
  180. --disable-nls
  181. # build
  182. %{l_make} %{l_mflags -O}
  183. %install
  184. rm -rf $RPM_BUILD_ROOT
  185. # create installation hierarchy
  186. %{l_shtool} mkdir -f -p -m 755 \
  187. $RPM_BUILD_ROOT%{l_prefix}/bin \
  188. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  189. $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
  190. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
  191. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
  192. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
  193. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  194. $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
  195. $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
  196. $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
  197. $RPM_BUILD_ROOT%{l_prefix}/man/man1 \
  198. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  199. $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \
  200. $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config
  201. # install
  202. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  203. # strip down installation
  204. # do not strip binaries, to make it easier to diagnose problems
  205. # strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
  206. ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
  207. for unwanted in bconsole startmysql stopmysql; do
  208. rm -f $unwanted
  209. done
  210. ) || exit $?
  211. # install additional files
  212. %{l_shtool} install -c -m 754 %{l_value -s -a} \
  213. %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
  214. # wrap binaries to avoid to specify "-c" for each run
  215. ( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
  216. for bin in bacula-dir bacula-fd bacula-sd \
  217. bconsole bcopy bextract bls bscan dbcheck \
  218. tray-monitor wx-console; do
  219. if [ -x $bin ]; then
  220. mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
  221. ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
  222. fi
  223. done
  224. ) || exit $?
  225. # install run-command script
  226. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  227. -e 's,@with_server@,%{with_server},g' \
  228. %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  229. # determine installation files
  230. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  231. %{l_files_std} \
  232. '%attr(640,%{l_musr},%{l_mgrp}) %config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \
  233. '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula' \
  234. '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run' \
  235. '%attr(700,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/bacula/run/subsys' \
  236. '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/dvd-handler' \
  237. '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/mtx-changer' \
  238. %if "%{with_server}" == "yes"
  239. '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
  240. '%attr(-,%{l_musr},%{l_rgrp}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\
  241. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
  242. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
  243. %endif
  244. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \
  245. %if "%{with_server}" == "yes"
  246. '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-dir.conf' \
  247. '%attr(640,%{l_musr},%{l_rgrp}) %{l_prefix}/etc/bacula/bacula-sd.conf' \
  248. %endif
  249. '%attr(640,%{l_musr},%{l_mgrp}) %{l_prefix}/etc/bacula/bacula-fd.conf'
  250. %files -f files
  251. %clean
  252. rm -rf $RPM_BUILD_ROOT
  253. %post
  254. # create initial database
  255. if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
  256. $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
  257. chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
  258. chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
  259. fi
  260. # after upgrade, restart service
  261. [ $1 -eq 2 ] || exit 0
  262. eval `%{l_rc} bacula status 2>/dev/null`
  263. [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
  264. exit 0
  265. %preun
  266. # before erase, stop service and remove working files
  267. [ $1 -eq 0 ] || exit 0
  268. %{l_rc} bacula stop 2>/dev/null
  269. rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
  270. exit 0