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