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