1#
2# Bacula RPM spec file
3#
4# Copyright (C) 2000-2020 Kern Sibbald
5# License: BSD 2-Clause; see file LICENSE-FOSS
6#
7
8# Platform Build Configuration
9
10# basic defines for every build
11%define _release           @RELEASE@
12%define _version           @VERSION@
13%define depkgs_qt_version  @DEPKGS_QT_VERSION@
14%define product            bacula
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.}
99exit 1
100%endif
101
102%define sqlite 0
103%{?build_sqlite:%define sqlite 1}
104
105%define base_package_name bacula
106
107Summary: Bacula - The Network Backup Solution
108Name: %{base_package_name}-bat
109Version: %{_version}
110Release: %{_release}
111Group: System Environment/Daemons
112License: AGPLv3
113BuildRoot: %{_tmppath}/%{name}-root
114URL: http://www.bacula.org/
115Vendor: The Bacula Team
116Packager: %{_packager}
117Prefix: %{_prefix}
118Distribution: %{_dist}
119
120Source0: http://www.prdownloads.sourceforge.net/bacula/%{product}-%{version}.tar.gz
121Source1: http://www.prdownloads.sourceforge.net/bacula/depkgs-qt-%{depkgs_qt_version}.tar.gz
122
123BuildRequires: gcc, gcc-c++, make, autoconf
124BuildRequires: libstdc++-devel, zlib-devel
125BuildRequires: openssl-devel, fontconfig-devel, libpng-devel, libstdc++-devel, zlib-devel
126
127Requires: openssl
128Requires: fontconfig
129Requires: libgcc
130Requires: libpng
131Requires: libstdc++
132Requires: zlib
133Requires: %{base_package_name}-libs
134
135%if %{suse}
136Requires: freetype2
137BuildRequires: freetype2-devel
138%else
139Requires: usermode
140Requires: freetype
141BuildRequires: freetype-devel
142%endif
143
144# Source directory locations
145%define depkgs_qt ../depkgs-qt
146
147# define the basic package description
148%define blurb Bacula - The Network Backup Solution.
149%define blurb2 Bacula is a set of computer programs that permit you (or the system
150%define blurb3 administrator) to manage backup, recovery, and verification of computer
151%define blurb4 data across a network of computers of different kinds. In technical terms,
152%define blurb5 it is a network client/server based backup program. Bacula is relatively
153%define blurb6 easy to use and efficient, while offering many advanced storage management
154%define blurb7 features that make it easy to find and recover lost or damaged files.
155
156%define group_file /etc/group
157%define groupadd /usr/sbin/groupadd
158
159Summary: Bacula - The Network Backup Solution
160Group: System Environment/Daemons
161
162%description
163%{blurb}
164
165%{blurb2}
166%{blurb3}
167%{blurb4}
168%{blurb5}
169%{blurb6}
170%{blurb7}
171
172This is the Bacula Administration Tool (bat) graphical user interface package.
173It 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
191cwd=${PWD}
192%if ! %{staticqt}
193export QTDIR=$(pkg-config --variable=prefix QtCore)
194export QTINC=$(pkg-config --variable=includedir QtCore)
195export QTLIB=$(pkg-config --variable=libdir QtCore)
196export 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
203if [ -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}
207else
208   cd %{depkgs_qt}
209   make qt4 <<EOF
210yes
211EOF
212fi
213
214source ./qt4-paths
215rm -f ${QTLIB}/QtCore.so* ${QTLIB}/QtGUI.so*
216cd ${cwd}
217
218%endif
219
220# hostname is the build hostname, so use XXX_HOSTNAME_XXX for Address parameter
221sed -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
255make
256
257%install
258mkdir -p $RPM_BUILD_ROOT/usr/share/applications
259mkdir -p $RPM_BUILD_ROOT/usr/share/pixmaps
260%if ! %{suse}
261mkdir -p $RPM_BUILD_ROOT/etc/pam.d
262mkdir -p $RPM_BUILD_ROOT/etc/security/console.apps
263mkdir -p $RPM_BUILD_ROOT%{_sbindir}
264mkdir -p $RPM_BUILD_ROOT/usr/bin
265%endif
266
267cd src/qt-console
268make DESTDIR=$RPM_BUILD_ROOT install
269cd ../..
270
271rm -rf $RPM_BUILD_ROOT%{_prefix}/share/doc/bacula
272
273%if %{suse}
274cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
275cp -p scripts/bat.desktop.xsu $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
276touch $RPM_BUILD_ROOT%{sysconf_dir}/bat.kdesu
277%else
278cp -p src/qt-console/images/bat_icon.png $RPM_BUILD_ROOT/usr/share/pixmaps/bat_icon.png
279cp -p scripts/bat.desktop.consolehelper $RPM_BUILD_ROOT/usr/share/applications/bat.desktop
280cp -p scripts/bat.console_apps $RPM_BUILD_ROOT/etc/security/console.apps/bat
281cp -p scripts/bat.pamd $RPM_BUILD_ROOT/etc/pam.d/bat
282ln -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(770, 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
311HAVE_BACULA=`grep %{daemon_group} %{group_file} 2>/dev/null`
312if [ -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."
316fi
317
318
319%post
320if [ -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
338fi
339/sbin/ldconfig
340
341%clean
342[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
343rm -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
348