bacula.spec 11 KB

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