bacula.spec 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. ##
  2. ## bacula.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2005 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ## Copyright (c) 2000-2005 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. # FIXME: rse: "odoc" support still not in final shape
  25. # package component versions
  26. %define V_bacula 1.37.40
  27. %define V_doc 20050823
  28. # package information
  29. Name: bacula
  30. Summary: Network Backup Tool
  31. URL: http://www.bacula.org/
  32. Vendor: Kern Sibbald
  33. Packager: OpenPKG
  34. Distribution: OpenPKG
  35. Class: EVAL
  36. Group: System
  37. License: GPL
  38. Version: %{V_bacula}
  39. Release: 20051001
  40. # package options
  41. %option with_server yes
  42. %option with_user %{l_rusr}
  43. %option with_group %{l_rgrp}
  44. %option with_ssl yes
  45. %option with_wrap no
  46. %option with_dvd no
  47. %option with_mtx no
  48. %option with_python no
  49. %option with_wxconsole no
  50. %option with_traymonitor no
  51. %option with_db_sqlite no
  52. %option with_db_pgsql no
  53. %option with_db_mysql no
  54. # package option sanity check
  55. %if "%{with_db_sqlite}" == "no" && "%{with_db_mysql}" == "no" && "%{with_db_pgsql}" == "no"
  56. %undefine with_db_sqlite
  57. %define with_db_sqlite yes
  58. %endif
  59. # list of sources
  60. Source0: http://osdn.dl.sourceforge.net/bacula/bacula-%{version}.tar.gz
  61. Source1: ftp://ftp.openpkg.org/sources/CPY/VERSIONED/bacula/bacula-doc-%{V_doc}.tar.gz
  62. Source2: rc.bacula
  63. Source3: bexec.sh
  64. Patch0: bacula.patch
  65. # build information
  66. Prefix: %{l_prefix}
  67. BuildRoot: %{l_buildroot}
  68. BuildPreReq: OpenPKG, openpkg >= 20040712, gcc, odoc
  69. PreReq: OpenPKG, openpkg >= 20040712
  70. BuildPreReq: readline, zlib
  71. PreReq: readline, zlib
  72. %if "%{with_ssl}" == "yes"
  73. BuildPreReq: openssl >= 0.9.8
  74. PreReq: openssl >= 0.9.8
  75. %endif
  76. %if "%{with_wrap}" == "yes"
  77. BuildPreReq: tcpwrappers
  78. PreReq: tcpwrappers
  79. %endif
  80. %if "%{with_db_sqlite}" == "yes"
  81. BuildPreReq: sqlite
  82. PreReq: sqlite
  83. %endif
  84. %if "%{with_db_mysql}" == "yes"
  85. BuildPreReq: mysql
  86. PreReq: mysql
  87. %endif
  88. %if "%{with_db_pgsql}" == "yes"
  89. BuildPreReq: postgresql
  90. PreReq: postgresql
  91. %endif
  92. %if "%{with_dvd}" == "yes"
  93. BuildPreReq: dvdrw-tools
  94. PreReq: dvdrw-tools
  95. %endif
  96. %if "%{with_mtx}" == "yes"
  97. BuildPreReq: mtx
  98. PreReq: mtx
  99. %endif
  100. %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
  101. BuildPreReq: python
  102. PreReq: python
  103. %endif
  104. %if "%{with_wxconsole}" == "yes"
  105. BuildPreReq: wx
  106. PreReq: wx
  107. %endif
  108. %if "%{with_traymonitor}" == "yes"
  109. BuildPreReq: gtk2
  110. PreReq: gtk2
  111. %endif
  112. AutoReq: no
  113. AutoReqProv: no
  114. %description
  115. Bacula is a set of computer programs that permit you (or the system
  116. administrator) to manage backup, recovery, and verification of computer
  117. data across a network of computers of different kinds. In technical
  118. terms, it is a network client/server based backup program. Bacula is
  119. relatively easy to use and efficient, while offering many advanced
  120. storage management features that make it easy to find and recover
  121. lost or damaged files.
  122. %track
  123. prog bacula = {
  124. version = %{version}
  125. url = http://prdownloads.sourceforge.net/bacula/
  126. regex = bacula-(__VER__)\.tar\.gz
  127. }
  128. %prep
  129. %setup -q
  130. %setup -q -D -T -b 1
  131. %patch -p0
  132. rm src/lib/tcpd.h
  133. %build
  134. # delay generation of default passwords until installation, else
  135. # the config files change on every install leading _always_ to
  136. # the generation of .rpmnew files which prevent rc start/stop/restart
  137. for pwd in dir_password fd_password sd_password \
  138. mon_dir_password mon_fd_password mon_sd_password; do
  139. %{l_shtool} subst \
  140. -e "s;^s,@$pwd@,;s,@-$pwd-@,;" \
  141. configure
  142. done
  143. # for the same reason remove version informations from config files
  144. %{l_shtool} subst \
  145. -e "s;For Bacula release @VERSION@ .*;;" \
  146. `find . -name "*.conf.in"`
  147. # use localhost as default host
  148. %{l_shtool} subst \
  149. -e 's/s,@hostname@,$hostname,/s,@hostname@,localhost,/' \
  150. configure
  151. # configure
  152. CC="%{l_cc}" \
  153. CFLAGS="%{l_cflags -O}" \
  154. CPPFLAGS="%{l_cppflags}" \
  155. LDFLAGS="%{l_ldflags}" \
  156. ./configure \
  157. --prefix=%{l_prefix} \
  158. --with-dir-user=%{with_user} \
  159. --with-dir-group=%{with_group} \
  160. --with-sd-user=%{with_user} \
  161. --with-sd-group=%{with_group} \
  162. --with-fd-user=%{l_susr} \
  163. --with-fd-group=%{l_sgrp} \
  164. --disable-conio \
  165. --enable-readline \
  166. --with-readline=%{l_prefix} \
  167. %if "%{with_server}" == "no"
  168. --enable-client-only
  169. %endif
  170. %if "%{with_ssl}" == "yes"
  171. --with-openssl=%{l_prefix} \
  172. %endif
  173. %if "%{with_wrap}" == "yes"
  174. --with-tcp-wrappers=yes \
  175. %endif
  176. %if "%{with_db_sqlite}" == "yes"
  177. --with-sqlite=%{l_prefix} \
  178. %endif
  179. %if "%{with_db_mysql}" == "yes"
  180. --with-mysql=%{l_prefix} \
  181. %endif
  182. %if "%{with_db_pgsql}" == "yes"
  183. --with-postgresql=%{l_prefix} \
  184. %endif
  185. %if "%{with_python}" == "yes" || "%{with_dvd}" == "yes"
  186. --with-python=%{l_prefix} \
  187. %endif
  188. %if "%{with_wxconsole}" == "yes"
  189. --enable-wx-console=yes \
  190. %endif
  191. --sysconfdir=%{l_prefix}/etc/bacula \
  192. --mandir=%{l_prefix}/man \
  193. --with-scriptdir=%{l_prefix}/libexec/bacula \
  194. --with-working-dir=%{l_prefix}/var/bacula \
  195. --with-pid-dir=%{l_prefix}/var/bacula/run \
  196. --with-subsys-dir=%{l_prefix}/var/bacula/run/subsys \
  197. --disable-nls
  198. # build
  199. %{l_make} %{l_mflags -O}
  200. %install
  201. rm -rf $RPM_BUILD_ROOT
  202. # create installation hierarchy
  203. %{l_shtool} mkdir -f -p -m 755 \
  204. $RPM_BUILD_ROOT%{l_prefix}/bin \
  205. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  206. $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula \
  207. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula \
  208. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/clients \
  209. $RPM_BUILD_ROOT%{l_prefix}/etc/bacula/scripts \
  210. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  211. $RPM_BUILD_ROOT%{l_prefix}/var/bacula \
  212. $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run \
  213. $RPM_BUILD_ROOT%{l_prefix}/var/bacula/run/subsys \
  214. $RPM_BUILD_ROOT%{l_prefix}/man/man8 \
  215. $RPM_BUILD_ROOT%{l_prefix}/share/bacula/docs \
  216. $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples \
  217. $RPM_BUILD_ROOT%{l_prefix}/share/bacula/examples/default-config \
  218. $RPM_BUILD_ROOT%{l_docdir}/bacula
  219. # install
  220. %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
  221. # strip down installation
  222. # do not strip binaries, to make it easier to diagnose problems
  223. # strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* 2>/dev/null || true
  224. ( cd $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula &&
  225. for unwanted in bconsole startmysql stopmysql; do
  226. rm -f $unwanted
  227. done
  228. ) || exit $?
  229. rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/bacula.8.gz
  230. # install additional files
  231. %{l_shtool} install -c -m 754 %{l_value -s -a} \
  232. %{SOURCE bexec.sh} $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec
  233. # wrap binaries to avoid to specify "-c" for each run
  234. ( cd $RPM_BUILD_ROOT%{l_prefix}/sbin
  235. for bin in bacula-dir bacula-fd bacula-sd \
  236. bconsole bcopy bextract bls bscan dbcheck \
  237. tray-monitor wx-console; do
  238. if [ -x $bin ]; then
  239. mv $bin $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula
  240. ln $RPM_BUILD_ROOT%{l_prefix}/libexec/bacula/bexec ./$bin
  241. fi
  242. done
  243. ) || exit $?
  244. # install run-command script
  245. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  246. -e 's,@with_server@,%{with_server},g' \
  247. %{SOURCE rc.bacula} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  248. # install documentation/examples
  249. %{l_shtool} install -c -m 644 \
  250. -e 's,/usr/share/doc/bacula-<version>,%{l_prefix}/doc/bacula,' \
  251. scripts/bacula.man $RPM_BUILD_ROOT%{l_prefix}/man/man8/bacula.8
  252. if %{l_odoc} -F; then
  253. echo "WARNING: will not package auxiliary documentation" 1>&2
  254. else
  255. mv ../bacula-doc-%{V_doc}/* $RPM_BUILD_ROOT%{l_docdir}/bacula/
  256. %{l_odoc} -ame %{_specdir}/bacula.spec
  257. fi
  258. # determine installation files
  259. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  260. %{l_files_std} \
  261. '%attr(700,%{with_user},%{with_group}) %{l_prefix}/var/bacula' \
  262. '%attr(700,%{with_user},%{with_group}) %{l_prefix}/var/bacula/run' \
  263. '%attr(700,%{with_user},%{with_group}) %{l_prefix}/var/bacula/run/subsys' \
  264. '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/dvd-freespace' \
  265. '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/dvd-writepart' \
  266. '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/mtx-changer' \
  267. '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/make_catalog_backup' \
  268. '%attr(-,-,%{with_group}) %{l_prefix}/libexec/bacula/delete_catalog_backup'\
  269. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-sd.conf' \
  270. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-fd.conf' \
  271. '%config(noreplace) %{l_prefix}/etc/bacula/bacula-dir.conf' \
  272. '%config(noreplace) %{l_prefix}/etc/bacula/bconsole.conf' \
  273. '%attr(640,-,%{with_group}) %{l_prefix}/etc/bacula/bacula-sd.conf' \
  274. '%attr(640,-,-) %{l_prefix}/etc/bacula/bacula-fd.conf' \
  275. '%attr(640,-,%{with_group}) %{l_prefix}/etc/bacula/bacula-dir.conf' \
  276. '%attr(640,-,-) %{l_prefix}/etc/bacula/bconsole.conf' \
  277. %if "%{with_wxconsole}" == "yes"
  278. '%config(noreplace) %{l_prefix}/etc/bacula/wx-console.conf' \
  279. '%attr(640,-,-) %{l_prefix}/etc/bacula/wx-console.conf' \
  280. %endif
  281. %if "%{with_traymonitor}" == "yes"
  282. '%config(noreplace) %{l_prefix}/etc/bacula/tray-monitor.conf' \
  283. '%attr(640,-,-) %{l_prefix}/etc/bacula/tray-monitor.conf'
  284. %endif
  285. %files -f files
  286. %docdir %{l_docdir}
  287. %clean
  288. rm -rf $RPM_BUILD_ROOT
  289. %post
  290. # create initial database
  291. if [ ! -f $RPM_INSTALL_PREFIX/var/bacula/bacula.db ]; then
  292. $RPM_INSTALL_PREFIX/libexec/bacula/make_bacula_tables
  293. chmod 600 $RPM_INSTALL_PREFIX/var/bacula/bacula.db
  294. chown %{with_user}:%{with_group} $RPM_INSTALL_PREFIX/var/bacula/bacula.db
  295. fi
  296. # generate default passwords
  297. for pwd in dir_password fd_password sd_password \
  298. mon_dir_password mon_fd_password mon_sd_password; do
  299. %{l_shtool} subst \
  300. -e "s;@$pwd@;`openssl rand -base64 33`;" \
  301. $RPM_INSTALL_PREFIX/etc/bacula/*.conf \
  302. $RPM_INSTALL_PREFIX/etc/bacula/*.conf.rpmnew 2>/dev/null
  303. done
  304. # after upgrade, restart service
  305. [ $1 -eq 2 ] || exit 0
  306. eval `%{l_rc} bacula status 2>/dev/null`
  307. [ ".$bacula_active" = .yes ] && %{l_rc} bacula restart
  308. exit 0
  309. %preun
  310. # before erase, stop service and remove working files
  311. [ $1 -eq 0 ] || exit 0
  312. %{l_rc} bacula stop 2>/dev/null
  313. rm -rf $RPM_INSTALL_PREFIX/var/bacula/*
  314. exit 0