1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit qmake-utils desktop systemd user libtool
11 DESCRIPTION="Featureful client/server network backup suite"
12 HOMEPAGE="https://www.bacula.org/"
13 SRC_URI="mirror://sourceforge/bacula/${MY_P}.tar.gz"
17 KEYWORDS="amd64 ppc ~sparc x86"
18 IUSE="acl bacula-clientonly bacula-nodir bacula-nosd examples ipv6 libressl logwatch mysql postgres qt5 readline +sqlite ssl static tcpd vim-syntax X"
23 postgres? ( dev-db/postgresql:=[threads] )
24 mysql? ( dev-db/mysql-connector-c:= )
25 sqlite? ( dev-db/sqlite:3 )
26 !bacula-nodir? ( virtual/mta )
35 logwatch? ( sys-apps/logwatch )
36 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
37 readline? ( sys-libs/readline:0 )
39 acl? ( virtual/acl[static-libs] )
40 sys-libs/zlib[static-libs]
41 dev-libs/lzo[static-libs]
42 sys-libs/ncurses:=[static-libs]
44 !libressl? ( dev-libs/openssl:0=[static-libs] )
45 libressl? ( dev-libs/libressl:0=[static-libs] )
54 !libressl? ( dev-libs/openssl:0= )
55 libressl? ( dev-libs/libressl:0= )
65 vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
67 REQUIRED_USE="!bacula-clientonly? ( ^^ ( mysql postgres sqlite ) )
68 static? ( bacula-clientonly )"
73 #XOR and !bacula-clientonly controlled by REQUIRED_USE
74 use mysql && export mydbtype="mysql"
75 use postgres && export mydbtype="postgresql"
76 use sqlite && export mydbtype="sqlite3"
78 # create the daemon group and user
79 if [ -z "$(egetent group bacula 2>/dev/null)" ]; then
82 einfo "The group 'bacula' has been created. Any users you add to this"
83 einfo "group have access to files created by the daemons."
87 if use bacula-clientonly && use static && use qt5; then
89 ewarn "Building statically linked 'bat' is not supported. Ignorig 'qt5' useflag."
93 if ! use bacula-clientonly; then
94 if [ -z "$(egetent passwd bacula 2>/dev/null)" ]; then
95 enewuser bacula -1 -1 /var/lib/bacula bacula,disk,tape,cdrom,cdrw
97 einfo "The user 'bacula' has been created. Please see the bacula manual"
98 einfo "for information about running bacula as a non-root user."
105 # adjusts default configuration files for several binaries
106 # to /etc/bacula/<config> instead of ./<config>
107 pushd src >&/dev/null || die
108 for f in console/console.c dird/dird.c filed/filed.c \
109 stored/bcopy.c stored/bextract.c stored/bls.c \
110 stored/bscan.c stored/btape.c stored/stored.c \
111 qt-console/main.cpp; do
112 sed -i -e 's|^\(#define CONFIG_FILE "\)|\1/etc/bacula/|g' "${f}" \
113 || die "sed on ${f} failed"
115 popd >&/dev/null || die
117 # bug 466688 drop deprecated categories from Desktop file
118 sed -i -e 's/Application;//' scripts/bat.desktop.in || die
120 # bug 466690 Use CXXFLAGS instead of CFLAGS
121 sed -i -e 's/@CFLAGS@/@CXXFLAGS@/' autoconf/Make.common.in || die
123 # drop automatic install of unneeded documentation (for bug 356499)
124 eapply -p0 "${FILESDIR}"/7.2.0/${PN}-7.2.0-doc.patch
127 eapply "${FILESDIR}"/5.2.3/${PN}-5.2.3-as-needed.patch
130 eapply -p0 "${FILESDIR}"/9.0.2/${PN}-9.0.2-lib-search-path.patch
132 # bat needs to respect LDFLAGS and CFLAGS
133 eapply -p0 "${FILESDIR}"/9.0.6/${PN}-9.0.6-bat-pro.patch
136 eapply -p0 "${FILESDIR}"/5.2.3/${PN}-5.2.3-openssl-1.patch
138 eapply -p0 "${FILESDIR}"/9.0.8/${PN}-9.0.8-fix-static.patch
140 # fix soname in libbaccat.so bug #602952
141 eapply -p0 "${FILESDIR}/bacula-fix-sonames.patch"
143 # do not strip binaries
144 sed -i -e "s/strip /# strip /" src/filed/Makefile.in || die
145 sed -i -e "s/strip /# strip /" src/console/Makefile.in || die
147 # fix file not found error during make depend
148 eapply -p0 "${FILESDIR}"/7.0.2/${PN}-7.0.2-depend.patch
152 # Fix systemd unit files:
154 sed -i -e '/Requires/d' platforms/systemd/*.service.in || die
155 sed -i -e '/StandardOutput/d' platforms/systemd/*.service.in || die
157 sed -i -e '/Alias=bacula-dir/d' platforms/systemd/bacula-dir.service.in || die
158 # bug 584442 and 504368
159 sed -i -e 's/@dir_user@/root/g' platforms/systemd/bacula-dir.service.in || die
161 # build 'bat' for Qt5
162 export QMAKE="$(qt5_get_bindir)"/qmake
164 # adapt to >=Qt-5.9 (see bug #644566)
165 # qmake needs an existing target file to generate install instructions
166 sed -i -e 's#bins.files = bat#bins.files = .libs/bat#g' \
167 src/qt-console/bat.pro.in || die
168 mkdir src/qt-console/.libs || die
169 touch src/qt-console/.libs/bat || die
170 chmod 755 src/qt-console/.libs/bat || die
172 # fix wrong handling of libressl version
173 # needs separate handling for <libressl-2.7 and >=libressl2.7
175 if has_version "<dev-libs/libressl-2.7"; then
176 eapply -p0 "${FILESDIR}"/9.0.6/${PN}-9.0.6-libressl26.patch
178 eapply -p0 "${FILESDIR}"/9.0.6/${PN}-9.0.6-libressl27.patch
181 # fix bundled libtool (bug 466696)
182 # But first move directory with M4 macros out of the way.
183 # It is only needed by autoconf and gives errors during elibtoolize.
184 mv autoconf/libtool autoconf/libtool1 || die
191 if use bacula-clientonly; then
193 $(use_enable bacula-clientonly client-only) \
194 $(use_enable !static libtool) \
195 $(use_enable static static-cons) \
196 $(use_enable static static-fd)"
199 $(use_enable !bacula-nodir build-dird) \
200 $(use_enable !bacula-nosd build-stored)"
202 # database support needed by dir-only *and* sd-only
203 # build as well (for building bscan, btape, etc.)
208 --disable-batch-insert"
211 --enable-batch-insert"
215 # do not build bat if 'static' clientonly
216 if ! use bacula-clientonly || ! use static; then
218 $(use_enable qt5 bat)"
223 $(use_enable !readline conio) \
224 $(use_enable readline) \
225 $(use_with readline readline /usr) \
226 $(use_with ssl openssl) \
229 $(use_with tcpd tcp-wrappers)"
232 --libdir=/usr/$(get_libdir) \
233 --docdir=/usr/share/doc/${PF} \
234 --htmldir=/usr/share/doc/${PF}/html \
235 --with-pid-dir=/var/run \
236 --sysconfdir=/etc/bacula \
237 --with-subsys-dir=/var/lock/subsys \
238 --with-working-dir=/var/lib/bacula \
239 --with-logdir=/var/lib/bacula \
240 --with-scriptdir=/usr/libexec/bacula \
241 --with-systemd=$(systemd_get_systemunitdir) \
242 --with-dir-user=bacula \
243 --with-dir-group=bacula \
244 --with-sd-user=root \
245 --with-sd-group=bacula \
246 --with-fd-user=root \
247 --with-fd-group=bacula \
248 --enable-smartalloc \
255 # Make build log verbose (bug #447806)
260 emake DESTDIR="${D}" install
261 doicon scripts/bacula.png
263 # install bat icon and desktop file when enabled
264 # (for some reason ./configure doesn't pick this up)
265 if use qt5 && ! use static ; then
266 doicon src/qt-console/images/bat_icon.png
267 domenu scripts/bat.desktop
270 # remove some scripts we don't need at all
271 rm -f "${D}"/usr/libexec/bacula/{bacula,bacula-ctl-dir,bacula-ctl-fd,bacula-ctl-sd,startmysql,stopmysql}
273 # rename statically linked apps
274 if use bacula-clientonly && use static ; then
275 pushd "${D}"/usr/sbin || die
276 mv static-bacula-fd bacula-fd || die
277 mv static-bconsole bconsole || die
281 # extra files which 'make install' doesn't cover
282 if ! use bacula-clientonly; then
283 # the database update scripts
285 insinto /usr/libexec/bacula/updatedb
287 doins "${S}"/updatedb/*
288 fperms 0640 /usr/libexec/bacula/updatedb/README
290 # the logrotate configuration
291 # (now unconditional wrt bug #258187)
293 insinto /etc/logrotate.d
295 newins "${S}"/scripts/logrotate bacula
297 # the logwatch scripts
298 if use logwatch; then
300 dodir /usr/share/logwatch/scripts/services
301 dodir /usr/share/logwatch/scripts/shared
302 dodir /etc/logwatch/conf/logfiles
303 dodir /etc/logwatch/conf/services
304 pushd "${S}"/scripts/logwatch >&/dev/null || die
305 emake DESTDIR="${D}" install
306 popd >&/dev/null || die
311 rm -vf "${D}"/usr/share/man/man1/bat.1*
313 rm -vf "${D}"/usr/share/man/man1/bacula-tray-monitor.1*
314 if use bacula-clientonly || use bacula-nodir; then
315 rm -vf "${D}"/usr/share/man/man8/bacula-dir.8*
316 rm -vf "${D}"/usr/share/man/man8/dbcheck.8*
317 rm -vf "${D}"/usr/share/man/man1/bsmtp.1*
318 rm -vf "${D}"/usr/libexec/bacula/create_*_database
319 rm -vf "${D}"/usr/libexec/bacula/drop_*_database
320 rm -vf "${D}"/usr/libexec/bacula/make_*_tables
321 rm -vf "${D}"/usr/libexec/bacula/update_*_tables
322 rm -vf "${D}"/usr/libexec/bacula/drop_*_tables
323 rm -vf "${D}"/usr/libexec/bacula/grant_*_privileges
324 rm -vf "${D}"/usr/libexec/bacula/*_catalog_backup
326 if use bacula-clientonly || use bacula-nosd; then
327 rm -vf "${D}"/usr/share/man/man8/bacula-sd.8*
328 rm -vf "${D}"/usr/share/man/man8/bcopy.8*
329 rm -vf "${D}"/usr/share/man/man8/bextract.8*
330 rm -vf "${D}"/usr/share/man/man8/bls.8*
331 rm -vf "${D}"/usr/share/man/man8/bscan.8*
332 rm -vf "${D}"/usr/share/man/man8/btape.8*
333 rm -vf "${D}"/usr/libexec/bacula/disk-changer
334 rm -vf "${D}"/usr/libexec/bacula/mtx-changer
335 rm -vf "${D}"/usr/libexec/bacula/dvd-handler
339 dodoc ChangeLog ReleaseNotes SUPPORT
341 # install examples (bug #457504)
342 if use examples; then
348 if use vim-syntax; then
349 insinto /usr/share/vim/vimfiles/syntax
350 doins scripts/bacula.vim
351 insinto /usr/share/vim/vimfiles/ftdetect
352 newins scripts/filetype.vim bacula_ft.vim
356 myscripts="bacula-fd"
357 if ! use bacula-clientonly; then
358 if ! use bacula-nodir; then
359 myscripts="${myscripts} bacula-dir"
361 if ! use bacula-nosd; then
362 myscripts="${myscripts} bacula-sd"
365 for script in ${myscripts}; do
366 # copy over init script and config to a temporary location
367 # so we can modify them as needed
368 cp "${FILESDIR}/${script}".confd "${T}/${script}".confd || die "failed to copy ${script}.confd"
369 cp "${FILESDIR}/newscripts/${script}".initd "${T}/${script}".initd || die "failed to copy ${script}.initd"
371 # now set the database dependancy for the director init script
374 case "${mydbtype}" in
376 # sqlite databases don't have a daemon
377 sed -i -e 's/need "%database%"/:/g' "${T}/${script}".initd || die
380 # all other databases have daemons
381 sed -i -e "s:%database%:${mydbtype}:" "${T}/${script}".initd || die
389 # install init script and config
390 newinitd "${T}/${script}".initd "${script}"
391 newconfd "${T}/${script}".confd "${script}"
394 systemd_dounit "${S}"/platforms/systemd/bacula-{dir,fd,sd}.service
396 # make sure the working directory exists
398 keepdir /var/lib/bacula
400 # make sure bacula group can execute bacula libexec scripts
401 fowners -R root:bacula /usr/libexec/bacula
405 if use bacula-clientonly; then
406 fowners root:bacula /var/lib/bacula
408 fowners bacula:bacula /var/lib/bacula
411 if ! use bacula-clientonly && ! use bacula-nodir; then
413 einfo "If this is a new install, you must create the ${mydbtype} databases with:"
414 einfo " /usr/libexec/bacula/create_${mydbtype}_database"
415 einfo " /usr/libexec/bacula/make_${mydbtype}_tables"
416 einfo " /usr/libexec/bacula/grant_${mydbtype}_privileges"
420 ewarn "The format of the database may have changed."
421 ewarn "If you just upgraded from a version below 9.0.0 you must run"
422 ewarn "'update_bacula_tables' now."
423 ewarn "Make sure to have a backup of your catalog before."
429 einfo "Be aware that Bacula does not officially support SQLite database anymore."
430 einfo "Best use it only for a client-only installation. See Bug #445540."
434 einfo "Please note that 'bconsole' will always be installed. To compile 'bat'"
435 einfo "you have to enable 'USE=qt5'."