bareos-15.2.2.ebuild 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. PYTHON_COMPAT=( python2_7 )
  5. PYTHON_REQ_USE="threads"
  6. inherit eutils multilib python-single-r1 qt4-r2 user
  7. DESCRIPTION="Featureful client/server network backup suite"
  8. HOMEPAGE="http://www.bareos.org/"
  9. SRC_URI="https://github.com/${PN}/${PN}/archive/Release/${PV}.tar.gz -> ${P}.tar.gz"
  10. RESTRICT="mirror"
  11. LICENSE="AGPL-3"
  12. SLOT="0"
  13. KEYWORDS="~amd64 ~x86"
  14. IUSE="X acl cephfs clientonly +director fastlz glusterfs gnutls ipv6 jansson lmdb libressl
  15. logwatch mysql ndmp postgres python qt4 rados rados-striper readline scsi-crypto
  16. sql-pooling +sqlite ssl static +storage-daemon tcpd vim-syntax"
  17. REQUIRED_USE="!clientonly? ( || ( mysql postgres sqlite ) )"
  18. DEPEND="
  19. !app-backup/bacula
  20. cephfs? ( sys-cluster/ceph )
  21. rados? ( sys-cluster/ceph )
  22. rados-striper? ( >=sys-cluster/ceph-0.94.2 )
  23. glusterfs? ( sys-cluster/glusterfs )
  24. lmdb? ( dev-db/lmdb )
  25. dev-libs/gmp:0
  26. !clientonly? (
  27. postgres? ( dev-db/postgresql:*[threads] )
  28. mysql? ( virtual/mysql )
  29. sqlite? ( dev-db/sqlite:3 )
  30. director? (
  31. virtual/mta
  32. jansson? ( dev-libs/jansson )
  33. )
  34. )
  35. qt4? (
  36. dev-qt/qtsvg:4
  37. x11-libs/qwt:5
  38. )
  39. fastlz? ( dev-libs/bareos-fastlzlib )
  40. logwatch? ( sys-apps/logwatch )
  41. tcpd? ( sys-apps/tcp-wrappers )
  42. readline? ( sys-libs/readline:0 )
  43. static? (
  44. acl? ( virtual/acl[static-libs] )
  45. sys-libs/zlib[static-libs]
  46. dev-libs/lzo[static-libs]
  47. sys-libs/ncurses:=[static-libs]
  48. ssl? (
  49. !gnutls? (
  50. !libressl? ( dev-libs/openssl:0=[static-libs] )
  51. libressl? ( dev-libs/libressl:0=[static-libs] )
  52. )
  53. gnutls? ( net-libs/gnutls[static-libs] )
  54. )
  55. )
  56. !static? (
  57. acl? ( virtual/acl )
  58. dev-libs/lzo
  59. ssl? (
  60. !gnutls? (
  61. !libressl? ( dev-libs/openssl:0= )
  62. libressl? ( dev-libs/libressl:0= )
  63. )
  64. gnutls? ( net-libs/gnutls )
  65. )
  66. sys-libs/ncurses:=
  67. sys-libs/zlib
  68. )
  69. python? ( ${PYTHON_DEPS} )
  70. "
  71. RDEPEND="${DEPEND}
  72. !clientonly? (
  73. storage-daemon? (
  74. sys-block/mtx
  75. app-arch/mt-st
  76. )
  77. )
  78. vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
  79. REQUIRED_USE="static? ( clientonly )
  80. python? ( ${PYTHON_REQUIRED_USE} )"
  81. S=${WORKDIR}/${PN}-Release-${PV}
  82. pkg_setup() {
  83. use mysql && export mydbtypes+="mysql"
  84. use postgres && export mydbtypes+=" postgresql"
  85. use sqlite && export mydbtypes+=" sqlite"
  86. # create the daemon group and user
  87. if [ -z "$(egetent group bareos 2>/dev/null)" ]; then
  88. enewgroup bareos
  89. einfo
  90. einfo "The group 'bareos' has been created. Any users you add to this"
  91. einfo "group have access to files created by the daemons."
  92. einfo
  93. fi
  94. if use clientonly && use static && use qt4; then
  95. ewarn
  96. ewarn "Building statically linked 'bat' is not supported. Ignorig 'qt4' useflag."
  97. ewarn
  98. fi
  99. if ! use clientonly; then
  100. if [ -z "$(egetent passwd bareos 2>/dev/null)" ]; then
  101. enewuser bareos -1 -1 /var/lib/bareos bareos,disk,tape,cdrom,cdrw
  102. einfo
  103. einfo "The user 'bareos' has been created. Please see the bareos manual"
  104. einfo "for information about running bareos as a non-root user."
  105. einfo
  106. fi
  107. fi
  108. use python && python-single-r1_pkg_setup
  109. }
  110. src_prepare() {
  111. # adjusts default configuration files for several binaries
  112. # to /etc/bareos/<config> instead of ./<config>
  113. pushd src >&/dev/null || die
  114. for f in console/console.c dird/dird.c filed/filed.c \
  115. stored/bcopy.c stored/bextract.c stored/bls.c \
  116. stored/bscan.c stored/btape.c stored/stored.c \
  117. qt-console/main.cpp; do
  118. sed -i -e 's|^\(#define CONFIG_FILE "\)|\1/etc/bareos/|g' "${f}" \
  119. || die "sed on ${f} failed"
  120. done
  121. popd >&/dev/null || die
  122. # bug 466690 Use CXXFLAGS instead of CFLAGS
  123. sed -i -e 's/@CFLAGS@/@CXXFLAGS@/' autoconf/Make.common.in || die
  124. # stop build for errors in subdirs
  125. epatch "${FILESDIR}"/${PN}-12.4.5-Makefile.patch
  126. # bat needs to respect LDFLAGS
  127. epatch "${FILESDIR}"/${PN}-12.4.5-bat-ldflags.patch
  128. # do not strip binaries
  129. for d in filed console dird stored; do
  130. sed -i -e "s/strip /# strip /" src/$d/Makefile.in || die
  131. done
  132. }
  133. src_configure() {
  134. local myconf=''
  135. addpredict /var/lib/logrotate.status
  136. if use clientonly; then
  137. myconf="${myconf} \
  138. $(use_enable clientonly client-only) \
  139. $(use_enable !static libtool) \
  140. $(use_enable static static-cons) \
  141. $(use_enable static static-fd)"
  142. fi
  143. # do not build bat and traymonitor if 'static' clientonly
  144. if ! use clientonly || ! use static; then
  145. myconf="${myconf} \
  146. $(use_enable qt4 bat) \
  147. $(use_enable qt4 traymonitor)"
  148. fi
  149. myconf="${myconf} \
  150. $(use_with X x) \
  151. $(use_enable acl) \
  152. $(use_enable ipv6) \
  153. $(use_enable ndmp) \
  154. $(use_enable readline) \
  155. $(use_enable !readline conio) \
  156. $(use_enable scsi-crypto) \
  157. $(use_enable sql-pooling) \
  158. $(use_with fastlz) \
  159. $(use_with mysql) \
  160. $(use_with postgres postgresql) \
  161. $(use_with python) \
  162. $(use_with readline) \
  163. $(use_with sqlite sqlite3) \
  164. $(use sqlite || echo "--without-sqlite3") \
  165. $(use_with ssl openssl) \
  166. $(use_with tcpd tcp-wrappers) \
  167. $(use_enable lmdb) \
  168. $(use_with glusterfs) \
  169. $(use_with rados) \
  170. $(use_with rados-striper) \
  171. $(use_with cephfs) \
  172. $(use_with jansson) \
  173. "
  174. econf \
  175. --libdir=/usr/$(get_libdir) \
  176. --docdir=/usr/share/doc/${PF} \
  177. --htmldir=/usr/share/doc/${PF}/html \
  178. --with-pid-dir=/run/bareos \
  179. --sysconfdir=/etc \
  180. --with-subsys-dir=/run/lock/subsys \
  181. --with-working-dir=/var/lib/bareos \
  182. --with-logdir=/var/log/bareos \
  183. --with-scriptdir=/usr/libexec/bareos \
  184. --with-plugindir=/usr/$(get_libdir)/${PN}/plugin \
  185. --with-backenddir=/usr/$(get_libdir)/${PN}/backend \
  186. --with-dir-user=bareos \
  187. --with-dir-group=bareos \
  188. --with-sd-user=root \
  189. --with-sd-group=bareos \
  190. --with-fd-user=root \
  191. --with-fd-group=bareos \
  192. --with-sbin-perm=0755 \
  193. --with-systemd \
  194. --enable-dynamic-cats-backends \
  195. --enable-dynamic-storage-backends \
  196. --enable-batch-insert \
  197. --disable-afs \
  198. --host=${CHOST} \
  199. ${myconf}
  200. # correct configuration for QT based bat
  201. if use qt4 ; then
  202. pushd src/qt-console
  203. eqmake4
  204. popd
  205. pushd src/qt-tray-monitor
  206. eqmake4
  207. popd
  208. fi
  209. }
  210. src_compile() {
  211. # workaround for build failing with high -j values
  212. # if ndmp is enabled
  213. use ndmp && MAKEOPTS="$MAKEOPTS -j1"
  214. # Make build log verbose (bug #447806)
  215. emake NO_ECHO=""
  216. }
  217. src_install() {
  218. emake DESTDIR="${D}" install
  219. newicon src/images/bareos_logo_shadow.png bareos.png
  220. # install bat icon and desktop file when enabled
  221. # (for some reason ./configure doesn't pick this up)
  222. if use qt4 && ! use static ; then
  223. doicon src/images/bat.png
  224. domenu scripts/bat.desktop
  225. fi
  226. # remove some scripts we don't need at all
  227. rm -f "${D}"/usr/libexec/bareos/{bareos,bareos-ctl-dir,bareos-ctl-fd,bareos-ctl-sd,startmysql,stopmysql}
  228. rm -f "${D}"/usr/sbin/bareos
  229. # remove upstream init scripts
  230. rm -f "${D}"/etc/init.d/bareos-*
  231. # rename statically linked apps
  232. if use clientonly && use static ; then
  233. pushd "${D}"/usr/sbin || die
  234. mv static-bareos-fd bareos-fd || die
  235. mv static-bconsole bconsole || die
  236. popd || die
  237. fi
  238. # extra files which 'make install' doesn't cover
  239. if ! use clientonly; then
  240. # the logrotate configuration
  241. # (now unconditional wrt bug #258187)
  242. diropts -m0755
  243. insinto /etc/logrotate.d
  244. insopts -m0644
  245. newins "${S}"/scripts/logrotate bareos
  246. # the logwatch scripts
  247. if use logwatch; then
  248. diropts -m0750
  249. dodir /etc/log.d/scripts/services
  250. dodir /etc/log.d/scripts/shared
  251. dodir /etc/log.d/conf/logfiles
  252. dodir /etc/log.d/conf/services
  253. pushd "${S}"/scripts/logwatch >&/dev/null || die
  254. emake DESTDIR="${D}" install
  255. popd >&/dev/null || die
  256. fi
  257. fi
  258. rm -vf "${D}"/usr/share/man/man1/bareos-bwxconsole.1*
  259. if ! use qt4; then
  260. rm -vf "${D}"/usr/share/man/man1/bat.1*
  261. fi
  262. if use clientonly || ! use director; then
  263. rm -vf "${D}"/usr/share/man/man8/bareos-dir.8*
  264. rm -vf "${D}"/usr/share/man/man8/bareos-dbcheck.8*
  265. rm -vf "${D}"/usr/share/man/man1/bsmtp.1*
  266. rm -vf "${D}"/usr/share/man/man8/bwild.8*
  267. rm -vf "${D}"/usr/share/man/man8/bregex.8*
  268. rm -vf "${D}"/usr/share/man/man8/bpluginfo.8*
  269. rm -vf "${D}"/usr/libexec/bareos/create_*_database
  270. rm -vf "${D}"/usr/libexec/bareos/drop_*_database
  271. rm -vf "${D}"/usr/libexec/bareos/make_*_tables
  272. rm -vf "${D}"/usr/libexec/bareos/update_*_tables
  273. rm -vf "${D}"/usr/libexec/bareos/drop_*_tables
  274. rm -vf "${D}"/usr/libexec/bareos/grant_*_privileges
  275. rm -vf "${D}"/usr/libexec/bareos/*_catalog_backup
  276. fi
  277. if use clientonly || ! use storage-daemon; then
  278. rm -vf "${D}"/usr/share/man/man8/bareos-sd.8*
  279. rm -vf "${D}"/usr/share/man/man8/bcopy.8*
  280. rm -vf "${D}"/usr/share/man/man8/bextract.8*
  281. rm -vf "${D}"/usr/share/man/man8/bls.8*
  282. rm -vf "${D}"/usr/share/man/man8/bscan.8*
  283. rm -vf "${D}"/usr/share/man/man8/btape.8*
  284. rm -vf "${D}"/usr/libexec/bareos/disk-changer
  285. rm -vf "${D}"/usr/libexec/bareos/mtx-changer
  286. rm -vf "${D}"/usr/libexec/bareos/dvd-handler
  287. rm -vf "${D}"/etc/bareos/mtx-changer.conf
  288. fi
  289. if ! use scsi-crypto; then
  290. rm -vf "${D}"/usr/share/man/man8/bscrypto.8*
  291. fi
  292. if ! use qt4; then
  293. rm -vf "${D}"/usr/share/man/man1/bareos-tray-monitor.1*
  294. fi
  295. # documentation
  296. dodoc README.md
  297. use ndmp && dodoc README.NDMP
  298. use scsi-crypto && dodoc README.scsicrypto
  299. # vim-files
  300. if use vim-syntax; then
  301. insinto /usr/share/vim/vimfiles/syntax
  302. doins scripts/bareos.vim
  303. insinto /usr/share/vim/vimfiles/ftdetect
  304. newins scripts/filetype.vim bareos_ft.vim
  305. fi
  306. # setup init scripts
  307. myscripts="bareos-fd"
  308. if ! use clientonly; then
  309. if use director; then
  310. myscripts="${myscripts} bareos-dir"
  311. fi
  312. if use storage-daemon; then
  313. myscripts="${myscripts} bareos-sd"
  314. fi
  315. fi
  316. for script in ${myscripts}; do
  317. # copy over init script and config to a temporary location
  318. # so we can modify them as needed
  319. cp "${FILESDIR}/${script}".confd "${T}/${script}".confd || die "failed to copy ${script}.confd"
  320. cp "${FILESDIR}/${script}".initd "${T}/${script}".initd || die "failed to copy ${script}.initd"
  321. # now set the database dependency for the director init script
  322. case "${script}" in
  323. bareos-dir)
  324. sed -i -e "s:%databasetypes%:${mydbtypes}:" "${T}/${script}".confd || die
  325. ;;
  326. *)
  327. ;;
  328. esac
  329. # install init script and config
  330. newinitd "${T}/${script}".initd "${script}"
  331. newconfd "${T}/${script}".confd "${script}"
  332. done
  333. # make sure the working directory exists
  334. diropts -m0750
  335. keepdir /var/lib/bareos
  336. # make sure bareos group can execute bareos libexec scripts
  337. fowners -R root:bareos /usr/libexec/bareos
  338. }
  339. pkg_postinst() {
  340. if use clientonly; then
  341. fowners root:bareos /var/lib/bareos
  342. else
  343. fowners bareos:bareos /var/lib/bareos
  344. fi
  345. if ! use clientonly && use director; then
  346. einfo
  347. einfo "If this is a new install, you must create the databases with:"
  348. if use postgres; then
  349. einfo
  350. einfo "For postgresql:"
  351. einfo " su postgres -c '/usr/libexec/bareos/create_bareos_database postgresql'"
  352. einfo " su postgres -c '/usr/libexec/bareos/make_bareos_tables postgresql'"
  353. einfo " su postgres -c '/usr/libexec/bareos/grant_bareos_privileges postgresql'"
  354. fi
  355. if use mysql; then
  356. einfo
  357. einfo "For mysql:"
  358. einfo
  359. einfo " Make sure root has direct access to your mysql server. You may want to"
  360. einfo " create a /root/.my.cnf file with"
  361. einfo " [client]"
  362. einfo " user=root"
  363. einfo " password=YourPasswordForAccessingMysqlAsRoot"
  364. einfo " before running:"
  365. einfo " /usr/libexec/bareos/create_bareos_database mysql"
  366. einfo " /usr/libexec/bareos/make_bareos_tables mysql"
  367. einfo " /usr/libexec/bareos/grant_bareos_privileges mysql"
  368. fi
  369. einfo
  370. fi
  371. if use sqlite; then
  372. einfo
  373. einfo "Be aware that Bareos does not officially support SQLite database."
  374. einfo "Best use it only for a client-only installation. See Bug #445540."
  375. einfo
  376. einfo "It is strongly recommended to use either postgresql or mysql as"
  377. einfo "catalog database backend."
  378. einfo
  379. fi
  380. einfo "Please note that 'bconsole' will always be installed. To compile 'bat'"
  381. einfo "you have to enable 'USE=qt4'."
  382. einfo
  383. }