]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/gentoo/bacula.ebuild
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / bacula / platforms / gentoo / bacula.ebuild
1 # Copyright 2004 D. Scott Barninger
2 # Copyright (C) 2000-2015 Kern Sibbald
3 # License: BSD 2-Clause; see file LICENSE-FOSS
4 #
5 #
6 # Modified from bacula-1.34.5.ebuild for 1.36.0 release
7 # 24 Oct 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
8 #
9 # added cdrom rescue for 1.36.1
10 # init script now comes from source package not ${FILES} dir
11 # 26 Nov 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
12 #
13 # fix symlink creation in rescue package in post script
14 # remove mask on x86 keyword
15 # fix post script so it doesn't talk about server config for client-only build
16 # bug #181 - unable to reproduce on 2.4 kernel system so add FEATURES="-sandbox"
17 # 04 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
18 #
19 # more  on bug #181 - another user has reported a sandbox violation trying to
20 # write to /dev/sg0 - still can't reproduce this behavior
21 # add an 'addpredict /dev/sg0'
22 # 08 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
23 #
24 # resolve bug #181 - problem is caused by configure calling cdrecord to scan
25 # the scsi bus. patch configure to remove this. add logrotate script.
26 # 06 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
27 #
28 # fix documentation bug
29 # 07 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
30 #
31 # new USE keywords bacula-clientonly bacula-split
32 # add new logwatch scripts
33 # 06 Mar 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
34 #
35 # 1.36.3 doc changes
36 # 17 Apr 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
37
38 DESCRIPTION="featureful client/server network backup suite"
39 HOMEPAGE="http://www.bacula.org/"
40 SRC_URI="mirror://sourceforge/bacula/${P}.tar.gz"
41
42 LICENSE="BSD 2-Clause"
43 SLOT="0"
44 KEYWORDS="x86 ~ppc ~sparc ~amd64"
45 IUSE="readline tcpd gnome mysql sqlite X static postgres wxwindows bacula-clientonly bacula-split"
46
47 inherit eutils
48
49 # there is a local sqlite use flag. use it -OR- mysql, not both.
50 # mysql is the recommended choice ...
51 # may need sys-libs/libtermcap-compat but try without first
52 DEPEND=">=sys-libs/zlib-1.1.4
53         readline? ( >=sys-libs/readline-4.1 )
54         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
55         gnome? ( gnome-base/libgnome )
56         gnome? ( app-admin/gnomesu )
57         !bacula-clientonly? (
58                 sqlite? ( =dev-db/sqlite-2* )
59                 mysql? ( >=dev-db/mysql-3.23 )
60                 postgres? ( >=dev-db/postgresql-7.4.0 )
61                 sys-apps/mtx
62         )
63         X? ( virtual/x11 )
64         wxwindows? ( >=x11-libs/wxGTK-2.4.2 )
65         virtual/mta
66         dev-libs/gmp
67         app-text/tetex
68         dev-tex/latex2html"
69 RDEPEND="${DEPEND}
70         !bacula-clientonly? (
71                 sys-apps/mtx
72                 app-arch/mt-st
73         )"
74
75 src_compile() {
76
77         # this resolves bug #181
78         epatch ${FILESDIR}/1.36.2-cdrecord-configure.patch
79
80         local myconf=""
81
82         myconf="
83                 `use_enable readline`
84                 `use_enable gnome`
85                 `use_enable tcpd tcp-wrappers`
86                 `use_enable X x`"
87
88         # define this to skip building the other daemons ...
89         if use bacula-clientonly
90         then
91                 myconf="${myconf} --enable-client-only"
92         fi
93
94         # select database support
95         if ! use bacula-clientonly
96         then
97                 # mysql is the recomended choice ...
98                 if use mysql
99                 then
100                         myconf="${myconf} --with-mysql=/usr"
101                 elif use postgres
102                 then
103                         myconf="${myconf} --with-postgresql=/usr"
104                 elif use sqlite
105                 then
106                         myconf="${myconf} --with-sqlite=/usr"
107                 elif  use sqlite && use mysql
108                 then
109                         myconf="${myconf/--with-sqlite/}"
110                 fi
111         fi
112
113         if use wxwindows
114         then
115            myconf="${myconf} --enable-wx-console"
116         fi
117
118         if use readline
119         then
120            myconf="${myconf} --enable-readline"
121         fi
122
123         if use gnome
124         then
125         myconf="${myconf} --enable-tray-monitor"
126         fi
127
128         ./configure \
129                 --enable-smartalloc \
130                 --prefix=/usr \
131                 --mandir=/usr/share/man \
132                 --with-pid-dir=/var/run \
133                 --sysconfdir=/etc/bacula \
134                 --infodir=/usr/share/info \
135                 --with-subsys-dir=/var/lock/subsys \
136                 --with-working-dir=/var/bacula \
137                 --with-scriptdir=/etc/bacula \
138                 --with-dir-user=root \
139                 --with-dir-group=bacula \
140                 --with-sd-user=root \
141                 --with-sd-group=bacula \
142                 --with-fd-user=root \
143                 --with-fd-group=bacula \
144                 --host=${CHOST} ${myconf} || die "bad ./configure"
145
146         emake || die "compile problem"
147
148         # for the rescue package regardless of use static
149         cd ${S}/src/filed
150         make static-bacula-fd
151         cd ${S}
152
153         # make the docs
154         cd ${S}/doc/latex
155         make
156         cd ${S}
157
158         if use static
159         then
160                 cd ${S}/src/console
161                 make static-console
162                 cd ${S}/src/dird
163                 make static-bacula-dir
164                 if use gnome
165                 then
166                   cd ${S}/src/gnome-console
167                   make static-gnome-console
168                 fi
169                 if use wxwindows
170                 then
171                   cd ${S}/src/wx-console
172                   make static-wx-console
173                 fi
174                 cd ${S}/src/stored
175                 make static-bacula-sd
176         fi
177 }
178
179 src_install() {
180         make DESTDIR=${D} install || die
181
182         if use static
183         then
184                 cd ${S}/src/filed
185                 cp static-bacula-fd ${D}/usr/sbin/bacula-fd
186                 cd ${S}/src/console
187                 cp static-console ${D}/usr/sbin/console
188                 cd ${S}/src/dird
189                 cp static-bacula-dir ${D}/usr/sbin/bacula-dir
190                 if use gnome
191                 then
192                         cd ${S}/src/gnome-console
193                         cp static-gnome-console ${D}/usr/sbin/gnome-console
194                 fi
195                 if use wxwindows
196                 then
197                         cd ${S}/src/wx-console
198                         cp static-wx-console ${D}/usr/sbin/wx-console
199                 fi
200                 cd ${S}/src/stored
201                 cp static-bacula-sd ${D}/usr/sbin/bacula-sd
202         fi
203
204         # the menu stuff
205         if use gnome
206         then
207         mkdir -p ${D}/usr/share/pixmaps
208         mkdir -p ${D}/usr/share/applications
209         cp ${S}/scripts/bacula.png ${D}/usr/share/pixmaps/bacula.png
210         cp ${S}/scripts/bacula.desktop.gnome2.xsu ${D}/usr/share/applications/bacula.desktop
211         cp ${S}/src/tray-monitor/generic.xpm ${D}/usr/share/pixmaps/bacula-tray-monitor.xpm
212         cp ${S}/scripts/bacula-tray-monitor.desktop \
213                 ${D}/usr/share/applications/bacula-tray-monitor.desktop
214         chmod 755 ${D}/usr/sbin/bacula-tray-monitor
215         chmod 644 ${D}/etc/bacula/tray-monitor.conf
216         fi
217
218         if ! use bacula-clientonly
219         then
220                 # the database update scripts
221                 mkdir -p ${D}/etc/bacula/updatedb
222                 cp ${S}/updatedb/* ${D}/etc/bacula/updatedb/
223                 chmod 754 ${D}/etc/bacula/updatedb/*
224
225                 # the logrotate configuration
226                 mkdir -p ${D}/etc/logrotate.d
227                 cp ${S}/scripts/logrotate ${D}/etc/logrotate.d/bacula
228                 chmod 644 ${D}/etc/logrotate.d/bacula
229
230                 # the logwatch scripts
231                 mkdir -p ${D}/etc/log.d/conf/logfiles
232                 mkdir -p ${D}/etc/log.d/conf/services
233                 mkdir -p ${D}/etc/log.d/scripts/services
234                 cp ${S}/scripts/logwatch/bacula ${D}/etc/log.d/scripts/services/bacula
235                 cp ${S}/scripts/logwatch/logfile.bacula.conf ${D}/etc/log.d/conf/logfiles/bacula.conf
236                 cp ${S}/scripts/logwatch/services.bacula.conf ${D}/etc/log.d/conf/services/bacula.conf
237                 chmod 755 ${D}/etc/log.d/scripts/services/bacula
238                 chmod 644 ${D}/etc/log.d/conf/logfiles/bacula.conf
239                 chmod 644 ${D}/etc/log.d/conf/services/bacula.conf
240
241         fi
242
243         # the cdrom rescue package
244         mkdir -p ${D}/etc/bacula/rescue/cdrom
245         cp -R ${S}/rescue/linux/cdrom/* ${D}/etc/bacula/rescue/cdrom/
246         mkdir ${D}/etc/bacula/rescue/cdrom/bin
247         cp ${S}/src/filed/static-bacula-fd ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
248         chmod 754 ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
249
250         # documentation
251         for a in ${S}/{ChangeLog,README,ReleaseNotes,kernstodo,LICENSE,doc/latex/bacula.pdf}
252         do
253                 dodoc $a
254         done
255
256         dohtml -r ${S}/doc/latex/bacula
257         
258         # clean up permissions left broken by install
259         chmod o-r ${D}/etc/bacula/query.sql
260
261         # remove the working dir so we can add it postinst with group
262         rmdir ${D}/var/bacula
263
264         # init scripts
265         exeinto /etc/init.d
266         if use bacula-clientonly
267         then
268                 newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
269         else
270                 if use bacula-split
271                 then
272                         newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
273                         newexe ${S}/platforms/gentoo/bacula-sd bacula-sd
274                         newexe ${S}/platforms/gentoo/bacula-dir bacula-dir
275                 else
276                         newexe ${S}/platforms/gentoo/bacula-init bacula
277                 fi
278         fi
279 }
280
281 pkg_postinst() {
282         # create the daemon group
283         HAVE_BACULA=`cat /etc/group | grep bacula 2>/dev/null`
284         if [ -z $HAVE_BACULA ]; then
285         enewgroup bacula
286         einfo
287         einfo "The group bacula has been created. Any users you add to"
288         einfo "this group have access to files created by the daemons."
289         fi
290
291         # the working directory
292         install -m0750 -o root -g bacula -d ${ROOT}/var/bacula
293
294         # link installed bacula-fd.conf into rescue directory
295         #ln -s /etc/bacula/bacula-fd.conf /etc/bacula/rescue/cdrom/bacula-fd.conf
296         # no longer necessary after 1.36.2
297
298         einfo
299         einfo "The CDRom rescue disk package has been installed into the"
300         einfo "/etc/bacula/rescue/cdrom/ directory. Please examine the manual"
301         einfo "for information on creating a rescue CD. CDR device detection"
302         einfo "during build has been disabled to prevent sandbox violations."
303         einfo "You need to examine /etc/bacula/rescue/cdrom/Makefile and adjust"
304         einfo "the device information for your CD recorder."
305         einfo
306
307         if ! use bacula-clientonly; then
308         einfo
309         einfo "Please note either/or nature of database USE flags for"
310         einfo "Bacula.  If mysql is set, it will be used, else postgres"
311         einfo "else finally SQLite.  If you wish to have multiple DBs on"
312         einfo "one system, you may wish to unset auxillary DBs for this"
313         einfo "build."
314         einfo
315
316         if use mysql
317         then
318         # test for an existing database
319         # note: this ASSUMES no password has been set for bacula database
320         DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
321                 if [ -z "$DB_VER" ]; then
322                 einfo "This appears to be a new install and you plan to use mysql"
323                 einfo "for your catalog database. You should now create it by doing"
324                 einfo "these commands:"
325                 einfo " sh /etc/bacula/grant_mysql_privileges"
326                 einfo " sh /etc/bacula/create_mysql_database"
327                 einfo " sh /etc/bacula/make_mysql_tables"
328                 elif [ "$DB_VER" -lt "8" ]; then
329                 elinfo "This release requires an upgrade to your bacula database"
330                 einfo "as the database format has changed.  Please read the"
331                 einfo "manual chapter for how to upgrade your database!!!"
332                 einfo
333                 einfo "Backup your database with the command:"
334                 einfo " mysqldump -f --opt bacula | bzip2 > /var/bacula/bacula_backup.sql.bz"
335                 einfo
336                 einfo "Then update your database using the scripts found in"
337                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
338                 einfo "version 8. Note that scripts must be run in order from your"
339                 einfo "version to the current version."
340                 fi
341         fi
342
343         if use postgres
344         then
345         # test for an existing database
346         # note: this ASSUMES no password has been set for bacula database
347         DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
348                 if [ -z "$DB_VER" ]; then
349                 einfo "This appears to be a new install and you plan to use postgresql"
350                 einfo "for your catalog database. You should now create it by doing"
351                 einfo "these commands:"
352                 einfo " sh /etc/bacula/create_postgresql_database"
353                 einfo " sh /etc/bacula/make_postgresql_tables"
354                 einfo " sh /etc/bacula/grant_postgresql_privileges"
355                 elif [ "$DB_VER" -lt "8" ]; then
356                 elinfo "This release requires an upgrade to your bacula database"
357                 einfo "as the database format has changed.  Please read the"
358                 einfo "manual chapter for how to upgrade your database!!!"
359                 einfo
360                 einfo "Backup your database with the command:"
361                 einfo " pg_dump bacula | bzip2 > /var/bacula/bacula_backup.sql.bz2"
362                 einfo
363                 einfo "Then update your database using the scripts found in"
364                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
365                 einfo "version 8. Note that scripts must be run in order from your"
366                 einfo "version to the current version."
367                 fi
368         fi
369
370         if use sqlite
371         then
372         # test for an existing database
373         # note: this ASSUMES no password has been set for bacula database
374         DB_VER=`echo "select * from Version;" | sqlite 2>/dev/null /var/bacula/bacula.db | tail -n 1`
375                 if [ -z "$DB_VER" ]; then
376                 einfo "This appears to be a new install and you plan to use sqlite"
377                 einfo "for your catalog database. You should now create it by doing"
378                 einfo "these commands:"
379                 einfo " sh /etc/bacula/grant_sqlite_privileges"
380                 einfo " sh /etc/bacula/create_sqlite_database"
381                 einfo " sh /etc/bacula/make_sqlite_tables"
382                 elif [ "$DB_VER" -lt "8" ]; then
383                 elinfo "This release requires an upgrade to your bacula database"
384                 einfo "as the database format has changed.  Please read the"
385                 einfo "manual chapter for how to upgrade your database!!!"
386                 einfo
387                 einfo "Backup your database with the command:"
388                 einfo " echo .dump | sqlite /var/bacula/bacula.db | bzip2 > \\"
389                 einfo "   /var/bacula/bacula_backup.sql.bz2"
390                 einfo
391                 einfo "Then update your database using the scripts found in"
392                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
393                 einfo "version 8. Note that scripts must be run in order from your"
394                 einfo "version to the current version."
395                 fi
396         fi
397         fi
398
399         einfo
400         einfo "Review your configuration files in /etc/bacula and"
401         einfo "start the daemons:"
402         if use bacula-clientonly; then
403                 einfo " /etc/init.d/bacula-fd start"
404         else
405                 if use bacula-split; then
406                 einfo " /etc/init.d/bacula-sd start"
407                 einfo " /etc/init.d/bacula-dir start"
408                 einfo " /etc/init.d/bacula-fd start"
409                 einfo " or /etc/bacula/bacula will start all three."
410                 else
411                 einfo " /etc/init.d/bacula start"
412                 fi
413         fi
414         einfo
415         einfo "You may also wish to:"
416         if use bacula-clientonly; then
417                 einfo " rc-update add bacula-fd default"
418         else
419                 if use bacula-split; then
420                         einfo " rc-update add bacula-sd default"
421                         einfo " rc-update add bacula-dir default"
422                         einfo " rc-update add bacula-fd default"
423                 else
424                         einfo " rc-update add bacula default"
425                 fi
426         fi
427         einfo
428 }