]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/rpms/redhat/bacula-bat.spec.in
Backport from Bacula Enterprise
[bacula/bacula] / bacula / platforms / rpms / redhat / bacula-bat.spec.in
1 #
2 # Bacula RPM spec file
3 #
4 #
5 # Copyright (C) 2000-2015 Kern Sibbald
6 # License: BSD 2-Clause; see file LICENSE-FOSS
7 #
8
9 # Platform Build Configuration
10
11 # basic defines for every build
12 %define _release           @RELEASE@
13 %define _version           @VERSION@
14 %define depkgs_qt_version  @DEPKGS_QT_VERSION@
15 %define product            bacula
16
17 # Don't strip binaries
18 %define __os_install_post %{nil}
19 %define __debug_install_post %{nil}
20 %define debug_package %{nil}
21
22 # this is the Qt version in depkgs_qt
23 %define qt4ver             @BQT_VERSION@
24
25 %define _packager Kern Sibbald <kern@sibbald.com>
26
27 %define manpage_ext gz
28
29 # Force single file build
30 %define single_dir 1
31 %{?single_dir_install:%define single_dir 1}
32
33 # Installation Directory locations
34 %if %{single_dir}
35 %define _prefix        /opt/bacula
36 %define _sbindir       /opt/bacula/bin
37 %define _bindir        /opt/bacula/bin
38 %define _subsysdir     /opt/bacula/working
39 %define sqlite_bindir  /opt/bacula/sqlite
40 %define _mandir        /usr/share/man
41 %define docs_dir       /opt/bacula/docs
42 %define archive_dir    /opt/bacula/archive
43 %define sysconf_dir    /opt/bacula/etc
44 %define script_dir     /opt/bacula/scripts
45 %define working_dir    /opt/bacula/working
46 %define pid_dir        /opt/bacula/working
47 %define plugin_dir     /opt/bacula/plugins
48 %define lib_dir        /opt/bacula/lib
49 %else
50 %define _prefix        /usr
51 %define _sbindir       %_prefix/sbin
52 %define _bindir        %_prefix/bin
53 %define _subsysdir     /var/lock/subsys
54 %define sqlite_bindir  %_libdir/bacula/sqlite
55 %define _mandir        %_prefix/share/man
56 %define sysconf_dir    /etc/bacula
57 %define script_dir     %_libdir/bacula
58 %define working_dir    /var/lib/bacula
59 %define pid_dir        /var/run
60 %define plugin_dir     %_libdir/bacula/plugins
61 %define lib_dir        %_libdir/bacula/lib
62 %endif
63
64 # Daemon user:group Don't change them unless you know what you are doing
65 %define director_daemon_user    bacula
66 %define daemon_group            bacula
67
68 #--------------------------------------------------------------------------
69 # it should not be necessary to change anything below here for a release
70 # except for patch macros in the setup section
71 #--------------------------------------------------------------------------
72
73 %{?contrib_packager:%define _packager %{contrib_packager}}
74
75 %{expand: %%define gccver %(rpm -q --queryformat %%{version} gcc)}
76 %{expand: %%define gccrel %(rpm -q --queryformat %%{release} gcc)}
77
78 %define staticqt 1
79 %{?nobuild_staticqt:%define staticqt 0}
80
81 # determine what platform we are building on
82 %define fedora 0
83 %define suse 0
84 %define mdk 0
85
86 %if %{_vendor} == redhat
87         %define fedora 1
88         %define _dist %(cat /etc/redhat-release)
89 %endif
90 %if %{_vendor} == suse
91         %define suse 1
92         %define _dist %(grep -i SuSE /etc/SuSE-release)
93 %endif
94 %if %{_vendor} == Mandriva
95         %define mdk 1
96         %define _dist %(grep Mand /etc/mandrake-release)
97 %endif
98 %if ! %{fedora} && ! %{suse} && ! %{mdk}
99 %{error: Unknown platform. Please examine the spec file.}
100 exit 1
101 %endif
102
103 %define sqlite 0
104 %{?build_sqlite:%define sqlite 1}
105
106 %define base_package_name bacula
107
108 Summary: Bacula - The Network Backup Solution
109 Name: %{base_package_name}-bat
110 Version: %{_version}
111 Release: %{_release}
112 Group: System Environment/Daemons
113 License: AGPLv3
114 BuildRoot: %{_tmppath}/%{name}-root
115 URL: http://www.bacula.org/
116 Vendor: The Bacula Team
117 Packager: %{_packager}
118 Prefix: %{_prefix}
119 Distribution: %{_dist}
120
121 Source0: http://www.prdownloads.sourceforge.net/bacula/%{product}-%{version}.tar.gz
122 Source1: http://www.prdownloads.sourceforge.net/bacula/depkgs-qt-%{depkgs_qt_version}.tar.gz
123
124 BuildRequires: gcc, gcc-c++, make, autoconf
125 BuildRequires: libstdc++-devel = %{gccver}-%{gccrel}, zlib-devel
126 BuildRequires: openssl-devel, fontconfig-devel, libpng-devel, libstdc++-devel, zlib-devel
127
128 Requires: openssl
129 Requires: fontconfig
130 Requires: libgcc
131 Requires: libpng
132 Requires: libstdc++
133 Requires: zlib
134 Requires: %{base_package_name}-libs
135
136 %if %{suse}
137 Requires: freetype2
138 BuildRequires: freetype2-devel
139 %else
140 Requires: usermode
141 Requires: freetype
142 BuildRequires: freetype-devel
143 %endif
144
145 # Source directory locations
146 %define depkgs_qt ../depkgs-qt
147
148 # define the basic package description
149 %define blurb Bacula - The Network Backup Solution.
150 %define blurb2 Bacula is a set of computer programs that permit you (or the system
151 %define blurb3 administrator) to manage backup, recovery, and verification of computer
152 %define blurb4 data across a network of computers of different kinds. In technical terms,
153 %define blurb5 it is a network client/server based backup program. Bacula is relatively
154 %define blurb6 easy to use and efficient, while offering many advanced storage management
155 %define blurb7 features that make it easy to find and recover lost or damaged files.
156
157 %define group_file /etc/group
158 %define groupadd /usr/sbin/groupadd
159
160 Summary: Bacula - The Network Backup Solution
161 Group: System Environment/Daemons
162
163 %description
164 %{blurb}
165
166 %{blurb2}
167 %{blurb3}
168 %{blurb4}
169 %{blurb5}
170 %{blurb6}
171 %{blurb7}
172
173 This is the Bacula Administration Tool (bat) graphical user interface package.
174 It is an add-on to the client or server packages.
175
176 # Don't strip symbols
177 %define debug_package %{nil} 
178
179 # Must explicitly enable debug pkg on SuSE
180 # but not in opensuse_bs
181 #%if %{suse} && ! 0%{?opensuse_bs}
182 #%debug_package
183 #%endif
184
185 %prep
186 %setup -T -n %{product}-%{_version} -b 0
187 %setup -T -D -n %{product}-%{_version} -b 1
188
189 %build
190
191
192 cwd=${PWD}
193 %if ! %{staticqt}
194 export QTDIR=$(pkg-config --variable=prefix QtCore)
195 export QTINC=$(pkg-config --variable=includedir QtCore)
196 export QTLIB=$(pkg-config --variable=libdir QtCore)
197 export PATH=${QTDIR}/bin/:${PATH}
198 %else
199 # You can use a cache for depkgs-qt
200 # tar xfz depkgs-qt*gz -C ~/
201 # cd ~/depkgs-qt
202 # echo yes | make qt4
203 # touch %{depkgs_qt_version}       # depkgs version
204 if [ -f $HOME/depkgs-qt/%{depkgs_qt_version} ]; then
205    rm -rf %{depkgs_qt}
206    ln -s $HOME/depkgs-qt %{depkgs_qt}
207    cd %{depkgs_qt}
208 else
209    cd %{depkgs_qt}
210    make qt4 <<EOF
211 yes
212 EOF
213 fi
214
215 source ./qt4-paths
216 rm -f ${QTLIB}/QtCore.so* ${QTLIB}/QtGUI.so*
217 cd ${cwd}
218
219 %endif
220
221 # hostname is the build hostname, so use XXX_HOSTNAME_XXX for Address parameter
222 sed -i s/hostname/basename/ src/console/bconsole.conf.in src/dird/bacula-dir.conf.in src/qt-console/bat.conf.in
223
224 # Main Bacula configuration with bat
225 %configure \
226         --prefix=%{_prefix} \
227         --sbindir=%{_sbindir} \
228         --sysconfdir=%{sysconf_dir} \
229         --mandir=%{_mandir} \
230         --docdir=%{docs_dir} \
231         --with-archivedir=%{archive_dir} \
232         --with-scriptdir=%{script_dir} \
233         --with-working-dir=%{working_dir} \
234         --with-plugindir=%{script_dir} \
235         --with-pid-dir=%{pid_dir} \
236         --with-subsys-dir=%{_subsysdir} \
237         --enable-smartalloc \
238         --enable-bat \
239         --enable-client-only \
240         --with-dir-user=%{director_daemon_user} \
241         --with-dir-group=%{daemon_group} \
242         --with-sd-user=%{storage_daemon_user} \
243         --with-sd-group=%{storage_daemon_group} \
244         --with-fd-user=%{file_daemon_user} \
245         --with-fd-group=%{daemon_group} \
246         --with-basename="XXX_HOSTNAME_XXX" \
247         --with-hostname="XXX_HOSTNAME_XXX" \
248         --with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
249         --with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
250         --with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
251         --with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
252         --with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
253         --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
254         --with-openssl
255
256 make
257
258 %install
259 mkdir -p $RPM_BUILD_ROOT/usr/share/applications
260 mkdir -p $RPM_BUILD_ROOT/usr/share/pixmaps
261 %if ! %{suse}
262 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
263 mkdir -p $RPM_BUILD_ROOT/etc/security/console.apps
264 mkdir -p $RPM_BUILD_ROOT%{_sbindir}
265 mkdir -p $RPM_BUILD_ROOT/usr/bin
266 %endif
267
268 cd src/qt-console
269 make DESTDIR=$RPM_BUILD_ROOT install
270 cd ../..
271
272 rm -rf $RPM_BUILD_ROOT%{_prefix}/share/doc/bacula
273
274 %if %{suse}
275 cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
276 cp -p scripts/bat.desktop.xsu $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
277 touch $RPM_BUILD_ROOT%{sysconf_dir}/bat.kdesu
278 %else
279 cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
280 cp -p scripts/bat.desktop.consolehelper $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
281 cp -p scripts/bat.console_apps $RPM_BUILD_ROOT/etc/security/console.apps/bat
282 cp -p scripts/bat.pamd $RPM_BUILD_ROOT/etc/pam.d/bat
283 ln -sf consolehelper $RPM_BUILD_ROOT/usr/bin/bat
284 %endif
285
286 %files
287 %defattr(-,root,root)
288 %attr(-, root, %{daemon_group}) %{_sbindir}/bat
289 %attr(770, root, %{daemon_group}) %dir %{sysconf_dir}
290 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bat.conf
291 %attr(-, root, %{daemon_group}) %{docs_dir}/*.html
292 %attr(-, root, %{daemon_group}) %{docs_dir}/*.png
293 /usr/share/pixmaps/bat_icon.png
294 /usr/share/applications/bat.desktop
295
296 # if user is a member of daemon_group then kdesu will run bat as user
297 %if %{suse}
298 %attr(0660, root, %{daemon_group}) %{sysconf_dir}/bat.kdesu
299 %endif
300
301 %if ! %{suse}
302 # add the console helper files
303 %config(noreplace,missingok) /etc/pam.d/bat
304 %config(noreplace,missingok) /etc/security/console.apps/bat
305 /usr/bin/bat
306 %endif
307
308
309
310 %pre
311 # create the daemon group
312 HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
313 if [ -z "$HAVE_BACULA" ]; then
314     %{groupadd} -r %{daemon_group} > /dev/null 2>&1
315     echo "The group %{daemon_group} has been added to %{group_file}."
316     echo "See the manual chapter \"Running Bacula\" for details."
317 fi
318
319
320 %post
321 if [ -d %{sysconf_dir} ]; then
322    cd %{sysconf_dir}
323    if [ ! -f .rpm.sed ]; then
324        (umask 0177
325         echo "# This file is used to ensure that all passwords will" > .rpm.sed
326         echo "# match between configuration files"                  >> .rpm.sed
327        )
328        for string in XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX; do
329            pass=`openssl rand -base64 33`
330            echo "s@${string}@${pass}@g" >> .rpm.sed
331        done
332    fi
333    host=`hostname -s`
334    for file in *.conf; do
335       sed -f .rpm.sed $file > $file.new
336       sed "s@XXX_HOSTNAME_XXX@${host}@g" $file.new > $file
337       rm -f $file.new
338    done
339 fi
340 /sbin/ldconfig
341
342 %clean
343 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
344 rm -rf $RPM_BUILD_DIR/depkgs-qt
345
346 %changelog
347 * Sat Aug 1 2009 Kern Sibbald <kern@sibbald.com>
348 - Split bat into separate bacula-bat.spec