1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 )
7 PYTHON_REQ_USE="threads"
9 inherit eutils multilib python-single-r1 systemd user
11 DESCRIPTION="Featureful client/server network backup suite"
12 HOMEPAGE="http://www.bareos.org/"
13 SRC_URI="https://github.com/${PN}/${PN}/archive/Release/${PV}.tar.gz -> ${P}.tar.gz"
18 KEYWORDS="~amd64 ~x86"
19 IUSE="X acl cephfs clientonly +director fastlz glusterfs gnutls ipv6 jansson lmdb libressl
20 logwatch mysql ndmp +postgres python rados rados-striper readline scsi-crypto
21 sql-pooling sqlite ssl static +storage-daemon tcpd vim-syntax"
22 REQUIRED_USE="!clientonly? ( || ( mysql postgres sqlite ) )"
26 cephfs? ( sys-cluster/ceph )
27 rados? ( sys-cluster/ceph )
28 rados-striper? ( >=sys-cluster/ceph-0.94.2 )
29 glusterfs? ( sys-cluster/glusterfs )
33 postgres? ( dev-db/postgresql:*[threads] )
34 mysql? ( dev-db/mysql-connector-c:0= )
35 sqlite? ( dev-db/sqlite:3 )
38 jansson? ( dev-libs/jansson )
41 fastlz? ( dev-libs/bareos-fastlzlib )
42 logwatch? ( sys-apps/logwatch )
43 tcpd? ( sys-apps/tcp-wrappers )
44 readline? ( sys-libs/readline:0 )
46 acl? ( virtual/acl[static-libs] )
47 sys-libs/zlib[static-libs]
48 dev-libs/lzo[static-libs]
49 sys-libs/ncurses:=[static-libs]
52 !libressl? ( dev-libs/openssl:0=[static-libs] )
53 libressl? ( dev-libs/libressl:0=[static-libs] )
55 gnutls? ( net-libs/gnutls[static-libs] )
63 !libressl? ( dev-libs/openssl:0= )
64 libressl? ( dev-libs/libressl:0= )
66 gnutls? ( net-libs/gnutls )
71 python? ( ${PYTHON_DEPS} )
80 vim-syntax? ( || ( app-editors/vim app-editors/gvim ) )"
82 REQUIRED_USE="static? ( clientonly )
83 python? ( ${PYTHON_REQUIRED_USE} )"
85 S=${WORKDIR}/${PN}-Release-${PV}
88 use mysql && export mydbtypes+="mysql"
89 use postgres && export mydbtypes+=" postgresql"
90 use sqlite && export mydbtypes+=" sqlite"
92 # create the daemon group and user
93 if [ -z "$(egetent group bareos 2>/dev/null)" ]; then
96 einfo "The group 'bareos' has been created. Any users you add to this"
97 einfo "group have access to files created by the daemons."
101 if ! use clientonly; then
102 if [ -z "$(egetent passwd bareos 2>/dev/null)" ]; then
103 enewuser bareos -1 -1 /var/lib/bareos bareos,disk,tape,cdrom,cdrw
105 einfo "The user 'bareos' has been created. Please see the bareos manual"
106 einfo "for information about running bareos as a non-root user."
111 use python && python-single-r1_pkg_setup
115 # adjusts default configuration files for several binaries
116 # to /etc/bareos/<config> instead of ./<config>
117 pushd src >&/dev/null || die
118 for f in console/console.c dird/dird.c filed/filed.c \
119 stored/bcopy.c stored/bextract.c stored/bls.c \
120 stored/bscan.c stored/btape.c stored/stored.c; do
121 sed -i -e 's|^\(#define CONFIG_FILE "\)|\1/etc/bareos/|g' "${f}" \
122 || die "sed on ${f} failed"
124 popd >&/dev/null || die
126 # enables default database driver in catalog
127 pushd src/defaultconfigs/bareos-dir.d/catalog >&/dev/null || die
128 sed -i -e 's/#dbdriver/dbdriver/' -e '/XXX_REPLACE/d' MyCatalog.conf.in \
129 || die "sed on MyCatalog.conf.in failed"
130 popd >&/dev/null || die
132 # bug 466690 Use CXXFLAGS instead of CFLAGS
133 sed -i -e 's/@CFLAGS@/@CXXFLAGS@/' autoconf/Make.common.in || die
135 # do not strip binaries
136 for d in filed console dird stored; do
137 sed -i -e "s/strip /# strip /" src/$d/Makefile.in || die
146 addpredict /var/lib/logrotate.status
148 if use clientonly; then
150 $(use_enable clientonly client-only) \
151 $(use_enable !static libtool) \
152 $(use_enable static static-cons) \
153 $(use_enable static static-fd)"
161 $(use_enable readline) \
162 $(use_enable !readline conio) \
163 $(use_enable scsi-crypto) \
164 $(use_enable sql-pooling) \
167 $(use_with postgres postgresql) \
169 $(use_with readline) \
170 $(use_with sqlite sqlite3) \
171 $(use sqlite || echo "--without-sqlite3") \
172 $(use_with ssl openssl) \
173 $(use_with tcpd tcp-wrappers) \
175 $(use_with glusterfs) \
177 $(use_with rados-striper) \
179 $(use_with jansson) \
183 --libdir=/usr/$(get_libdir) \
184 --docdir=/usr/share/doc/${PF} \
185 --htmldir=/usr/share/doc/${PF}/html \
186 --with-pid-dir=/run/bareos \
188 --with-subsys-dir=/run/lock/subsys \
189 --with-working-dir=/var/lib/bareos \
190 --with-logdir=/var/log/bareos \
191 --with-scriptdir=/usr/libexec/bareos \
192 --with-plugindir=/usr/$(get_libdir)/${PN}/plugin \
193 --with-backenddir=/usr/$(get_libdir)/${PN}/backend \
194 --with-dir-user=bareos \
195 --with-dir-group=bareos \
196 --with-sd-user=root \
197 --with-sd-group=bareos \
198 --with-fd-user=root \
199 --with-fd-group=bareos \
200 --with-sbin-perm=0755 \
202 --with-db-password=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1` \
203 --enable-dynamic-cats-backends \
204 --enable-dynamic-storage-backends \
205 --enable-batch-insert \
212 # Make build log verbose (bug #447806)
217 emake DESTDIR="${D}" install
218 newicon src/images/bareos_logo_shadow.png bareos.png
220 # remove some scripts we don't need at all
221 rm -f "${D}"/usr/libexec/bareos/{bareos,bareos-ctl-dir,bareos-ctl-fd,bareos-ctl-sd,startmysql,stopmysql}
222 rm -f "${D}"/usr/sbin/bareos
224 # remove upstream init scripts
225 rm -f "${D}"/etc/init.d/bareos-*
227 # rename statically linked apps
228 if use clientonly && use static ; then
229 pushd "${D}"/usr/sbin || die
230 mv static-bareos-fd bareos-fd || die
231 mv static-bconsole bconsole || die
235 # extra files which 'make install' doesn't cover
236 if ! use clientonly; then
237 # the logrotate configuration
238 # (now unconditional wrt bug #258187)
240 insinto /etc/logrotate.d
242 newins "${S}"/scripts/logrotate bareos
244 # the logwatch scripts
245 if use logwatch; then
247 dodir /etc/log.d/scripts/services
248 dodir /etc/log.d/scripts/shared
249 dodir /etc/log.d/conf/logfiles
250 dodir /etc/log.d/conf/services
251 pushd "${S}"/scripts/logwatch >&/dev/null || die
252 emake DESTDIR="${D}" install
253 popd >&/dev/null || die
257 rm -vf "${D}"/usr/share/man/man1/bareos-bwxconsole.1*
258 if use clientonly || ! use director; then
259 rm -vf "${D}"/usr/share/man/man8/bareos-dir.8*
260 rm -vf "${D}"/usr/share/man/man8/bareos-dbcheck.8*
261 rm -vf "${D}"/usr/share/man/man1/bsmtp.1*
262 rm -vf "${D}"/usr/share/man/man8/bwild.8*
263 rm -vf "${D}"/usr/share/man/man8/bregex.8*
264 rm -vf "${D}"/usr/share/man/man8/bpluginfo.8*
265 rm -vf "${D}"/usr/libexec/bareos/create_*_database
266 rm -vf "${D}"/usr/libexec/bareos/drop_*_database
267 rm -vf "${D}"/usr/libexec/bareos/make_*_tables
268 rm -vf "${D}"/usr/libexec/bareos/update_*_tables
269 rm -vf "${D}"/usr/libexec/bareos/drop_*_tables
270 rm -vf "${D}"/usr/libexec/bareos/grant_*_privileges
271 rm -vf "${D}"/usr/libexec/bareos/*_catalog_backup
273 if use clientonly || ! use storage-daemon; then
274 rm -vf "${D}"/usr/share/man/man8/bareos-sd.8*
275 rm -vf "${D}"/usr/share/man/man8/bcopy.8*
276 rm -vf "${D}"/usr/share/man/man8/bextract.8*
277 rm -vf "${D}"/usr/share/man/man8/bls.8*
278 rm -vf "${D}"/usr/share/man/man8/bscan.8*
279 rm -vf "${D}"/usr/share/man/man8/btape.8*
280 rm -vf "${D}"/usr/libexec/bareos/disk-changer
281 rm -vf "${D}"/usr/libexec/bareos/mtx-changer
282 rm -vf "${D}"/usr/libexec/bareos/dvd-handler
283 rm -vf "${D}"/etc/bareos/mtx-changer.conf
285 if ! use scsi-crypto; then
286 rm -vf "${D}"/usr/share/man/man8/bscrypto.8*
291 use ndmp && dodoc README.NDMP
292 use scsi-crypto && dodoc README.scsicrypto
295 if use vim-syntax; then
296 insinto /usr/share/vim/vimfiles/syntax
297 doins scripts/bareos.vim
298 insinto /usr/share/vim/vimfiles/ftdetect
299 newins scripts/filetype.vim bareos_ft.vim
303 myscripts="bareos-fd"
304 if ! use clientonly; then
305 if use director; then
306 myscripts="${myscripts} bareos-dir"
308 if use storage-daemon; then
309 myscripts="${myscripts} bareos-sd"
312 for script in ${myscripts}; do
313 # copy over init script and config to a temporary location
314 # so we can modify them as needed
315 cp "${FILESDIR}/${script}".confd-16 "${T}/${script}".confd || die "failed to copy ${script}.confd"
316 cp "${FILESDIR}/${script}".initd "${T}/${script}".initd || die "failed to copy ${script}.initd"
318 # now set the database dependency for the director init script
321 sed -i -e "s:%databasetypes%:${mydbtypes}:" "${T}/${script}".confd || die
327 # install init script and config
328 newinitd "${T}/${script}".initd "${script}"
329 newconfd "${T}/${script}".confd "${script}"
332 # install systemd unit files
333 use director && systemd_dounit "${FILESDIR}"/bareos-dir.service
334 use storage-daemon && systemd_dounit "${FILESDIR}"/bareos-sd.service
335 systemd_dounit "${FILESDIR}"/bareos-fd.service
337 # make sure the working directory exists
339 keepdir /var/lib/bareos
341 # make sure bareos group can execute bareos libexec scripts
342 fowners -R root:bareos /usr/libexec/bareos
346 if use clientonly; then
347 fowners root:bareos /var/lib/bareos
349 fowners bareos:bareos /var/lib/bareos
352 if ! use clientonly && use director; then
354 einfo "If this is a new install, you must create the database:"
355 if use postgres; then
357 einfo "For postgresql:"
358 einfo " su postgres -c '/usr/libexec/bareos/create_bareos_database postgresql'"
359 einfo " su postgres -c '/usr/libexec/bareos/make_bareos_tables postgresql'"
360 einfo " su postgres -c '/usr/libexec/bareos/grant_bareos_privileges postgresql'"
366 einfo " Make sure root has direct access to your mysql server. You may want to"
367 einfo " create a /root/.my.cnf file with"
370 einfo " password=YourPasswordForAccessingMysqlAsRoot"
371 einfo " before running:"
372 einfo " /usr/libexec/bareos/create_bareos_database mysql"
373 einfo " /usr/libexec/bareos/make_bareos_tables mysql"
374 einfo " /usr/libexec/bareos/grant_bareos_privileges mysql"
381 einfo "Be aware that Bareos does not officially support SQLite database."
382 einfo "Best use it only for a client-only installation. See Bug #445540."
384 einfo "It is strongly recommended to use either postgresql or mysql as"
385 einfo "catalog database backend."