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