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