bacula.spec 9.9 KB

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