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