]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/rpms/suse/bacula-bat.spec.in
33d5308e1f43bf07bbcddd84d1836ecec8dca097
[bacula/bacula] / bacula / platforms / rpms / suse / 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 %if 0%{?suse_version} > 1210
133 Requires: libstdc++.6
134 %else
135 Requires: libstdc++
136 %endif
137 Requires: zlib
138 Requires: %{base_package_name}-libs
139
140 %if %{suse}
141 Requires: freetype2
142 BuildRequires: freetype2-devel
143 %else
144 Requires: usermode
145 Requires: freetype
146 BuildRequires: freetype-devel
147 %endif
148
149 # Source directory locations
150 %define depkgs_qt ../depkgs-qt
151
152 # define the basic package description
153 %define blurb Bacula - The Network Backup Solution.
154 %define blurb2 Bacula is a set of computer programs that permit you (or the system
155 %define blurb3 administrator) to manage backup, recovery, and verification of computer
156 %define blurb4 data across a network of computers of different kinds. In technical terms,
157 %define blurb5 it is a network client/server based backup program. Bacula is relatively
158 %define blurb6 easy to use and efficient, while offering many advanced storage management
159 %define blurb7 features that make it easy to find and recover lost or damaged files.
160
161 %define group_file /etc/group
162 %define groupadd /usr/sbin/groupadd
163
164 Summary: Bacula - The Network Backup Solution
165 Group: System Environment/Daemons
166
167 %description
168 %{blurb}
169
170 %{blurb2}
171 %{blurb3}
172 %{blurb4}
173 %{blurb5}
174 %{blurb6}
175 %{blurb7}
176
177 This is the Bacula Administration Tool (bat) graphical user interface package.
178 It is an add-on to the client or server packages.
179
180 # Don't strip symbols
181 %define debug_package %{nil} 
182
183 # Must explicitly enable debug pkg on SuSE
184 # but not in opensuse_bs
185 #%if %{suse} && ! 0%{?opensuse_bs}
186 #%debug_package
187 #%endif
188
189 %prep
190 %setup -T -n %{product}-%{_version} -b 0
191 %setup -T -D -n %{product}-%{_version} -b 1
192
193 %build
194
195
196 cwd=${PWD}
197 %if ! %{staticqt}
198 export QTDIR=$(pkg-config --variable=prefix QtCore)
199 export QTINC=$(pkg-config --variable=includedir QtCore)
200 export QTLIB=$(pkg-config --variable=libdir QtCore)
201 export PATH=${QTDIR}/bin/:${PATH}
202 %else
203 # You can use a cache for depkgs-qt
204 # tar xfz depkgs-qt*gz -C ~/
205 # cd ~/depkgs-qt
206 # echo yes | make qt4
207 # touch %{depkgs_qt_version}       # depkgs version
208 if [ -f $HOME/depkgs-qt/%{depkgs_qt_version} ]; then
209    rm -rf %{depkgs_qt}
210    ln -s $HOME/depkgs-qt %{depkgs_qt}
211    cd %{depkgs_qt}
212 else
213    cd %{depkgs_qt}
214    make qt4 <<EOF
215 yes
216 EOF
217 fi
218
219 source ./qt4-paths
220 rm -f ${QTLIB}/QtCore.so* ${QTLIB}/QtGUI.so*
221 cd ${cwd}
222
223 %endif
224
225 # hostname is the build hostname, so use XXX_HOSTNAME_XXX for Address parameter
226 sed -i s/hostname/basename/ src/console/bconsole.conf.in src/dird/bacula-dir.conf.in src/qt-console/bat.conf.in
227
228 # Main Bacula configuration with bat
229 %configure \
230         --prefix=%{_prefix} \
231         --sbindir=%{_sbindir} \
232         --sysconfdir=%{sysconf_dir} \
233         --mandir=%{_mandir} \
234         --docdir=%{docs_dir} \
235         --with-archivedir=%{archive_dir} \
236         --with-scriptdir=%{script_dir} \
237         --with-working-dir=%{working_dir} \
238         --with-plugindir=%{script_dir} \
239         --with-pid-dir=%{pid_dir} \
240         --with-subsys-dir=%{_subsysdir} \
241         --enable-smartalloc \
242         --enable-bat \
243         --enable-client-only \
244         --with-dir-user=%{director_daemon_user} \
245         --with-dir-group=%{daemon_group} \
246         --with-sd-user=%{storage_daemon_user} \
247         --with-sd-group=%{storage_daemon_group} \
248         --with-fd-user=%{file_daemon_user} \
249         --with-fd-group=%{daemon_group} \
250         --with-basename="XXX_HOSTNAME_XXX" \
251         --with-hostname="XXX_HOSTNAME_XXX" \
252         --with-dir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
253         --with-fd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
254         --with-sd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
255         --with-mon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
256         --with-mon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
257         --with-mon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
258         --with-openssl
259
260 make
261
262 %install
263 mkdir -p $RPM_BUILD_ROOT/usr/share/applications
264 mkdir -p $RPM_BUILD_ROOT/usr/share/pixmaps
265 %if ! %{suse}
266 mkdir -p $RPM_BUILD_ROOT/etc/pam.d
267 mkdir -p $RPM_BUILD_ROOT/etc/security/console.apps
268 mkdir -p $RPM_BUILD_ROOT%{_sbindir}
269 mkdir -p $RPM_BUILD_ROOT/usr/bin
270 %endif
271
272 cd src/qt-console
273 make DESTDIR=$RPM_BUILD_ROOT install
274 cd ../..
275
276 rm -rf $RPM_BUILD_ROOT%{_prefix}/share/doc/bacula
277
278 %if %{suse}
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.xsu $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
281 touch $RPM_BUILD_ROOT%{sysconf_dir}/bat.kdesu
282 %else
283 cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
284 cp -p scripts/bat.desktop.consolehelper $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
285 cp -p scripts/bat.console_apps $RPM_BUILD_ROOT/etc/security/console.apps/bat
286 cp -p scripts/bat.pamd $RPM_BUILD_ROOT/etc/pam.d/bat
287 ln -sf consolehelper $RPM_BUILD_ROOT/usr/bin/bat
288 %endif
289
290 %files
291 %defattr(-,root,root)
292 %attr(-, root, %{daemon_group}) %{_sbindir}/bat
293 %attr(770, root, %{daemon_group}) %dir %{sysconf_dir}
294 %attr(-, root, %{daemon_group}) %config(noreplace) %{sysconf_dir}/bat.conf
295 %attr(-, root, %{daemon_group}) %{docs_dir}/*.html
296 %attr(-, root, %{daemon_group}) %{docs_dir}/*.png
297 /usr/share/pixmaps/bat_icon.png
298 /usr/share/applications/bat.desktop
299
300 # if user is a member of daemon_group then kdesu will run bat as user
301 %if %{suse}
302 %attr(0660, root, %{daemon_group}) %{sysconf_dir}/bat.kdesu
303 %endif
304
305 %if ! %{suse}
306 # add the console helper files
307 %config(noreplace,missingok) /etc/pam.d/bat
308 %config(noreplace,missingok) /etc/security/console.apps/bat
309 /usr/bin/bat
310 %endif
311
312
313
314 %pre
315 # create the daemon group
316 HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
317 if [ -z "$HAVE_BACULA" ]; then
318     %{groupadd} -r %{daemon_group} > /dev/null 2>&1
319     echo "The group %{daemon_group} has been added to %{group_file}."
320     echo "See the manual chapter \"Running Bacula\" for details."
321 fi
322
323
324 %post
325 if [ -d %{sysconf_dir} ]; then
326    cd %{sysconf_dir}
327    if [ ! -f .rpm.sed ]; then
328        (umask 0177
329         echo "# This file is used to ensure that all passwords will" > .rpm.sed
330         echo "# match between configuration files"                  >> .rpm.sed
331        )
332        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
333            pass=`openssl rand -base64 33`
334            echo "s@${string}@${pass}@g" >> .rpm.sed
335        done
336    fi
337    host=`hostname -s`
338    for file in *.conf; do
339       sed -f .rpm.sed $file > $file.new
340       sed "s@XXX_HOSTNAME_XXX@${host}@g" $file.new > $file
341       rm -f $file.new
342    done
343 fi
344 /sbin/ldconfig
345
346 %clean
347 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
348 rm -rf $RPM_BUILD_DIR/depkgs-qt
349
350 %changelog
351 * Sat Aug 1 2009 Kern Sibbald <kern@sibbald.com>
352 - Split bat into separate bacula-bat.spec