]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/gentoo/bacula.ebuild
c8a62d44aa212b991a82b7ef57d30ba25ed308e3
[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 # 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 DESCRIPTION="featureful client/server network backup suite"
8 HOMEPAGE="http://www.bacula.org/"
9 SRC_URI="mirror://sourceforge/bacula/${P}.tar.gz"
10
11 LICENSE="GPL-2"
12 SLOT="0"
13 KEYWORDS="~x86 ~ppc ~sparc"
14 IUSE="readline tcpd gnome mysql sqlite X static postgres wxwindows"
15
16 inherit eutils
17
18 #theres a local sqlite use flag. use it -OR- mysql, not both.
19 #mysql is the reccomended choice ...
20 #may need sys-libs/libtermcap-compat but try without first
21 DEPEND=">=sys-libs/zlib-1.1.4
22         sys-apps/mtx
23         readline? ( >=sys-libs/readline-4.1 )
24         tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
25         gnome? ( gnome-base/libgnome )
26         gnome? ( app-admin/gnomesu )
27         sqlite? ( =dev-db/sqlite-2* )
28         mysql? ( >=dev-db/mysql-3.23 )
29         postgres? ( >=dev-db/postgresql-7.4.0 )
30         X? ( virtual/x11 )
31         wxwindows? ( >=x11-libs/wxGTK-2.4.2 )
32         virtual/mta
33         dev-libs/gmp"
34 RDEPEND="${DEPEND}
35         sys-apps/mtx
36         app-arch/mt-st"
37
38 src_compile() {
39
40         # patch configure for scripts/bacula-tray-monitor.desktop
41         patch ${S}/configure ${FILESDIR}/${P}-configure.diff
42
43         local myconf=""
44
45         #sed -i -e "s:$bindir/mysql:$bindir/mysql -p:g" grant_mysql_privileges.in
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         if use static
112         then
113                 cd ${S}/src/filed
114                 make static-baula-fd
115                 cd ${S}/src/console
116                 make static-console
117                 cd ${S}/src/dird
118                 make static-bacula-dir
119                 if use gnome
120                 then
121                   cd ${S}/src/gnome-console
122                   make static-gnome-console
123                 fi
124                 if use wxwindows
125                 then
126                   cd ${S}/src/wx-console
127                   make static-wx-console
128                 fi
129                 cd ${S}/src/stored
130                 make static-bacula-sd
131         fi
132 }
133
134 src_install() {
135         make DESTDIR=${D} install || die
136
137         if use static
138         then
139                 cd ${S}/src/filed
140                 cp static-bacula-fd ${D}/usr/sbin/bacula-fd
141                 cd ${S}/src/console
142                 cp static-console ${D}/usr/sbin/console
143                 cd ${S}/src/dird
144                 cp static-bacula-dir ${D}/usr/sbin/bacula-dir
145                 if use gnome
146                 then
147                         cd ${S}/src/gnome-console
148                         cp static-gnome-console ${D}/usr/sbin/gnome-console
149                 fi
150                 if use wxwindows
151                 then
152                         cd ${S}/src/wx-console
153                         cp static-wx-console ${D}/usr/sbin/wx-console
154                 fi
155                 cd ${S}/src/storge
156                 cp static-bacula-sd ${D}/usr/sbin/bacula-sd
157         fi
158
159         # the menu stuff
160         if use gnome
161         then
162         mkdir -p ${D}/usr/share/pixmaps
163         mkdir -p ${D}/usr/share/applications
164         cp ${S}/scripts/bacula.png ${D}/usr/share/pixmaps/bacula.png
165         cp ${S}/scripts/bacula.desktop.gnome2.xsu ${D}/usr/share/applications/bacula.desktop
166         cp ${S}/src/tray-monitor/generic.xpm ${D}/usr/share/pixmaps/bacula-tray-monitor.xpm
167         cp ${S}/scripts/bacula-tray-monitor.desktop \
168                 ${D}/usr/share/applications/bacula-tray-monitor.desktop
169         chmod 755 ${D}/usr/sbin/bacula-tray-monitor
170         chmod 644 ${D}/etc/bacula/tray-monitor.conf
171         fi
172
173         # the database update scripts
174         mkdir -p ${D}/etc/bacula/updatedb
175         cp ${S}/updatedb/* ${D}/etc/bacula/updatedb/
176         chmod 754 ${D}/etc/bacula/updatedb/*
177
178         # documentation
179         for a in ${S}/{Changelog,README,ReleaseNotes,kernstodo,LICENSE,doc/bacula.pdf}
180         do
181                 dodoc $a
182         done
183
184         dohtml -r ${S}/doc/html-manual doc/home-page
185         chown -R root:root ${D}/usr/share/doc/${PF}
186         chmod -R 644 ${D}/usr/share/doc/${PF}/*
187         
188         # clean up permissions left broken by install
189         chmod o-r ${D}/etc/bacula/query.sql
190
191         # remove the working dir so we can add it postinst with group
192         rmdir ${D}/var/bacula
193
194         exeinto /etc/init.d
195         newexe ${FILESDIR}/bacula-init bacula
196 }
197
198 pkg_postinst() {
199         # create the daemon group
200         HAVE_BACULA=`cat /etc/group | grep bacula 2>/dev/null`
201         if [ -z $HAVE_BACULA ]; then
202         enewgroup bacula
203         einfo
204         einfo "The group bacula has been created. Any users you add to"
205         einfo "this group have access to files created by the daemons."
206         fi
207
208         # the working directory
209         install -m0750 -o root -g bacula -d ${ROOT}/var/bacula
210
211         einfo
212         einfo "Please note either/or nature of database USE flags for"
213         einfo "Bacula.  If mysql is set, it will be used, else postgresql"
214         einfo "else finally SQLite.  If you wish to have multiple DBs on"
215         einfo "one system, you may wish to unset auxillary DBs for this"
216         einfo "build."
217         einfo
218
219         if use mysql
220         then
221         # test for an existing database
222         # note: this ASSUMES no password has been set for bacula database
223         DB_VER=`mysql bacula -e 'select * from Version;'|tail -n 1 2>/dev/null`
224                 if [ -z "$DB_VER" ]; then
225                 einfo "This appears to be a new install and you plan to use mysql"
226                 einfo "for your catalog database. You should now create it by doing"
227                 einfo "these commands:"
228                 einfo " sh /etc/bacula/grant_mysql_privileges"
229                 einfo " sh /etc/bacula/create_mysql_database"
230                 einfo " sh /etc/bacula/make_mysql_tables"
231                 elif [ "$DB_VER" -lt "8" ]; then
232                 elinfo "This release requires an upgrade to your bacula database"
233                 einfo "as the database format has changed.  Please read the"
234                 einfo "manual chapter for how to upgrade your database!!!"
235                 einfo
236                 einfo "Backup your database with the command:"
237                 einfo " mysqldump -f --opt bacula | bzip2 > /var/bacula/bacula_backup.sql.bz"
238                 einfo
239                 einfo "Then update your database using the scripts found in"
240                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
241                 einfo "version 8. Note that scripts must be run in order from your"
242                 einfo "version to the current version."
243                 fi
244         fi
245
246         if use postgresql
247         then
248         # test for an existing database
249         # note: this ASSUMES no password has been set for bacula database
250         DB_VER=`echo 'select * from Version;' | psql bacula | tail -3 | head -1 2>/dev/null`
251                 if [ -z "$DB_VER" ]; then
252                 einfo "This appears to be a new install and you plan to use postgresql"
253                 einfo "for your catalog database. You should now create it by doing"
254                 einfo "these commands:"
255                 einfo " sh /etc/bacula/grant_postgresql_privileges"
256                 einfo " sh /etc/bacula/create_postgresql_database"
257                 einfo " sh /etc/bacula/make_postgresql_tables"
258                 elif [ "$DB_VER" -lt "8" ]; then
259                 elinfo "This release requires an upgrade to your bacula database"
260                 einfo "as the database format has changed.  Please read the"
261                 einfo "manual chapter for how to upgrade your database!!!"
262                 einfo
263                 einfo "Backup your database with the command:"
264                 einfo " pg_dump bacula | bzip2 > /var/bacula/bacula_backup.sql.bz2"
265                 einfo
266                 einfo "Then update your database using the scripts found in"
267                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
268                 einfo "version 8. Note that scripts must be run in order from your"
269                 einfo "version to the current version."
270                 fi
271         fi
272
273         if use sqlite
274         then
275         # test for an existing database
276         # note: this ASSUMES no password has been set for bacula database
277         DB_VER=`echo "select * from Version;" | sqlite /var/bacula/bacula.db | tail -n 1 2>/dev/null`
278                 if [ -z "$DB_VER" ]; then
279                 einfo "This appears to be a new install and you plan to use sqlite"
280                 einfo "for your catalog database. You should now create it by doing"
281                 einfo "these commands:"
282                 einfo " sh /etc/bacula/grant_sqlite_privileges"
283                 einfo " sh /etc/bacula/create_sqlite_database"
284                 einfo " sh /etc/bacula/make_sqlite_tables"
285                 elif [ "$DB_VER" -lt "8" ]; then
286                 elinfo "This release requires an upgrade to your bacula database"
287                 einfo "as the database format has changed.  Please read the"
288                 einfo "manual chapter for how to upgrade your database!!!"
289                 einfo
290                 einfo "Backup your database with the command:"
291                 einfo " echo .dump | sqlite /var/bacula/bacula.db | bzip2 > \"
292                 einfo "   /var/bacula/bacula_backup.sql.bz2"
293                 einfo
294                 einfo "Then update your database using the scripts found in"
295                 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
296                 einfo "version 8. Note that scripts must be run in order from your"
297                 einfo "version to the current version."
298                 fi
299         fi
300
301         einfo
302         einfo "Then setup your configuration files in /etc/bacula and"
303         einfo "start the daemons:"
304         einfo " /etc/init.d/bacula start"
305         einfo
306         einfo "You may also wish to:"
307         einfo " rc-update add bacula default"
308         einfo
309 }