Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > by-pkgid > aad1da95eb9f1cc2251e6a7e384b203c > files > 11

bacula-1.38.11-3mdv2007.0.src.rpm

# compatability macros
%{?!mkrel:%define mkrel(c:) %{-c:0.%{-c*}.}%{!?_with_unstable:%(perl -e '$_="%{1}";m/(.\*)(\\d+)$/;$rel=${2}-1;re;print "$1$rel";').%{?subrel:%subrel}%{!?subrel:1}.%{?distversion:%distversion}%{?!distversion:%(echo $[%{mdkversion}/10])}}%{?_with_unstable:%{1}}%{?distsuffix:%distsuffix}%{?!distsuffix:mdk}}

%{?!_with_unstable: %{error:%(echo -e "\n\n\nYou are building package for a stable release, please see \nhttp://qa.mandrakesoft.com/twiki/bin/view/Main/DistroSpecificReleaseTag\nif you think this is incorrect\n\n\n ")}%(sleep 2)}

%define name bacula
%define version 1.38.11
%define _rescuever 1.8.3
%define _guiver 1.38.10
%define release %mkrel 3

%define MYSQL 0
%define PGSQL 0
%define GNOME 1
%define WXWINDOWS 1
%define TCPW 0
%define GUI 1
%define RESCUE 0

%{?_with_mysql: %{expand: %%global MYSQL 1}}
%{?_without_mysql: %{expand: %%global MYSQL 0}}
%{?_with_pgsql: %{expand: %%global PGSQL 1}}
%{?_without_pgsql: %{expand: %%global PGSQL 0}}
%{?_with_gnome: %{expand: %%global GNOME 1}}
%{?_without_gnome: %{expand: %%global GNOME 0}}
%{?_with_wx: %{expand: %%global WXWINDOWS 1}}
%{?_without_wx: %{expand: %%global WXWINDOWS 0}}
%{?_with_wrap: %{expand: %%global TCPW 1}}
%{?_without_wrap: %{expand: %%global TCPW 0}}
%{?_with_gui: %{expand: %%global GUI 1}}
%{?_without_gui: %{expand: %%global GUI 0}}
%{?_with_rescue: %{expand: %%global RESCUE 1}}
%{?_without_rescue: %{expand: %%global RESCUE 0}}

%if %{MYSQL}
  %if %{PGSQL}
  %{error: You must specify only one database database support.}
  exit 1
  %endif
  %define db_type mysql
%else
  %if %{PGSQL}
  %define db_type postgresql
  %else
  %define db_type sqlite
  %endif
%endif

%define blurb Bacula - It comes by night and sucks the vital essence from your computers.

# fixes passwords in configuration files
# removing "SubSys Directory" is needed if upgrading from 1.30a or lower
%define post_fix_config() umask 0037; if [ -s %{_sysconfdir}/%{name}/.pw.sed ]; then for i in %{_sysconfdir}/%{name}/%{1}.conf %{_sysconfdir}/%{name}/%{1}.conf.rpmnew; do if [ -s $i ]; then sed -f %{_sysconfdir}/%{name}/.pw.sed $i > $i.tmp; sed -e '/SubSys[[:space:]]*Directory/I d' $i.tmp > $i; rm -f $i.tmp; fi; done; fi;

Summary:	Bacula - The Network Backup Solution
Name:		%{name}
Version:	%{version}
Release:	%{release}
Epoch:		1
Group:		Archiving/Backup
License:	GPL
URL:		http://www.bacula.org/
Source0:	http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}.tar.bz2
Source1:	%{name}-icons.tar.bz2
Source2:	%{name}-manpages.tar.bz2
#Source3:	http://prdownloads.sourceforge.net/%{name}/%{name}-rescue-%{_rescuever}.tar.bz2
Source5:	http://prdownloads.sourceforge.net/%{name}/%{name}-gui-%{_guiver}.tar.bz2
Source6:	bacula.pam-0.77.bz2
Source7:	bacula.pam.bz2
Patch0:		bacula-1.38.5-config.diff
Patch2:		bacula-1.36.1-pidfile.diff
Patch3:		bacula-1.34-updatedb.diff
Patch5:		bacula-gui-1.38.5-php_header.diff
BuildRequires: 	perl-base
BuildRequires:	zlib-devel
BuildRequires: 	python-devel
BuildRequires:	tetex-latex
BuildRequires: 	latex2html
%if %{TCPW}
BuildRequires:	tcp_wrappers-devel
Requires:	tcp_wrappers
%endif
BuildRoot:	%{_tmppath}/%{name}-%{version}-buildroot

%description
%{blurb}
Bacula is a set of computer programs that permit you (or the system
administrator) to manage backup, recovery, and verification of computer
data across a network of computers of different kinds. In technical terms,
it is a network client/server based backup program. Bacula is relatively
easy to use and efficient, while offering many advanced storage management
features that make it easy to find and recover lost or damaged files.

%package common
Summary:	Common files for bacula package
Group:		Archiving/Backup
Requires(post): rpm-helper
Requires(preun): rpm-helper
Conflicts:	bacula-dir < %{epoch}:%{version}-%{release}
Conflicts:	bacula-fd < %{epoch}:%{version}-%{release}
Conflicts:	bacula-sd < %{epoch}:%{version}-%{release}
Conflicts:	bacula-console < %{epoch}:%{version}-%{release}
Conflicts:	bacula-console-gnome < %{epoch}:%{version}-%{release}

%description common
%{blurb}
Bacula is a set of computer programs that permit you (or the system
administrator) to manage backup, recovery, and verification of computer
data across a network of computers of different kinds. In technical terms,
it is a network client/server based backup program. Bacula is relatively
easy to use and efficient, while offering many advanced storage management
features that make it easy to find and recover lost or damaged files.

%package dir
Summary:	Bacula Director and Catalog services
Group:		Archiving/Backup
Requires(post): rpm-helper perl-base sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun): rpm-helper perl-base sed bacula-common = %{epoch}:%{version}-%{release}
%if %{MYSQL}
Requires:	MySQL-client
BuildRequires:	MySQL-devel >= 3.23
%else
%if %{PGSQL}
Requires:	postgresql
BuildRequires:	postgresql-devel
%else
Requires:	sqlite-tools
BuildRequires:	sqlite-devel
%endif
%endif

%description dir
%{blurb}
Bacula Director is the program that supervises all the backup, restore, verify
and archive operations. The system administrator uses the Bacula Director to
schedule backups and to recover files.
Catalog services are comprised of the software programs responsible for
maintaining the file indexes and volume databases for all files backed up.
The Catalog services permit the System Administrator or user to quickly locate
and restore any desired file, since it maintains a record of all Volumes used,
all Jobs run, and all Files saved.
%if %{MYSQL}
This build requires MySQL to be installed separately as the catalog database.
%else
%if %{PGSQL}
This build requires Postgres to be installed separately as the catalog database.
%else
This build uses an embedded sqlite catalog database.
%endif
%endif

%package console
Summary:	Bacula Console
Group:		Archiving/Backup
Requires(post): sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun): sed bacula-common = %{epoch}:%{version}-%{release}
BuildRequires:	termcap-devel
Requires:	usermode-consoleonly

%description console
%{blurb}
Bacula Console is the program that allows the administrator or user to
communicate with the Bacula Director.
This is the text only console interface.

%if %{GNOME}
%package console-gnome
Summary:	Bacula Gnome Console
Group:		Archiving/Backup
BuildRequires: libgnomeui2-devel
Requires(post): sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun): sed bacula-common = %{epoch}:%{version}-%{release}
Requires:	usermode, usermode-consoleonly

%description console-gnome
%{blurb}
Bacula Console is the program that allows the administrator or user to
communicate with the Bacula Director.
This is the GNOME GUI interface.
%endif

%if %{WXWINDOWS}
%package console-wx
Summary:	Bacula wxWindows Console
Group:		Archiving/Backup
%if %{mdkversion} >= 1020
BuildRequires:	wxGTK2.6-devel
%else
BuildRequires:	wxGTK2.4-devel
%endif
Requires(post): sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun): sed bacula-common = %{epoch}:%{version}-%{release}
Requires:	usermode, usermode-consoleonly

%description console-wx
%{blurb}
Bacula Console is the program that allows the administrator or user to
communicate with the Bacula Director.
This is the wxWindows GUI interface.
%endif

%package fd
Summary:	Bacula File services (Client)
Group:		Archiving/Backup
Requires(post): rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun):rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}

%description fd
%{blurb}
Bacula File services (or Client program) is the software program that is
installed on the machine to be backed up. It is specific to the operating
system on which it runs and is responsible for providing the file attributes
and data when requested by the Director. The File services are also responsible
for the file system dependent part of restoring the file attributes and data
during a recovery operation.
This program runs as a daemon on the machine to be backed up, and in some of
the documentation, the File daemon is referred to as the Client (for example in
Bacula configuration file). 

%package sd
Summary:	Bacula Storage services
Group:		Archiving/Backup
Requires(post): rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun):rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}

%description sd
%{blurb}
Bacula Storage services consist of the software programs that perform the
storage and recovery of the file attributes and data to the physical backup
media or volumes. In other words, the Storage daemon is responsible for reading
and writing your tapes (or other storage media, e.g. files).
The Storage services runs as a daemon on the machine that has the backup
device (usually a tape drive).

%if %{GUI}
%package gui-web
Summary:	Bacula Web GUI
Group:		Archiving/Backup
Requires(post): rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun):rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires:	webserver
Requires:	php-pear
Requires:	php-gd
#Requires:	mysqlserver
Requires:	phplot
Requires:	php-smarty

%description gui-web
%{blurb}
Bacula is a set of computer programs that permit you (or the system
administrator) to manage backup, recovery, and verification of computer
data across a network of computers of different kinds. In technical terms,
it is a network client/server based backup program. Bacula is relatively
easy to use and efficient, while offering many advanced storage management
features that make it easy to find and recover lost or damaged files.

Contains the web gui

%package gui-bimagemgr
Summary:	Bacula Image Manager
Group:		Archiving/Backup
Requires(post): rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires(preun):rpm-helper sed bacula-common = %{epoch}:%{version}-%{release}
Requires:	webserver
Requires: 	perl-DBI
Requires:	perl-DBD-mysql
#Requires:	mysqlserver

%description gui-bimagemgr
%{blurb}
Bacula is a set of computer programs that permit you (or the system
administrator) to manage backup, recovery, and verification of computer
data across a network of computers of different kinds. In technical terms,
it is a network client/server based backup program. Bacula is relatively
easy to use and efficient, while offering many advanced storage management
features that make it easy to find and recover lost or damaged files.

Contains the bacula image manager cgi-bin
%endif

%prep

%setup -q
%setup -q -D -T -a 5
mv %{name}-gui-%{_guiver} gui
%patch0 -p1 -b .config
%patch2 -p1 -b .pidfile
%patch3 -p1 -b .updatedb
%patch5 -p1

# fix conditional pam config file
%if %{mdkversion} < 200610
bzcat %{SOURCE6} > bacula.pam
%else
bzcat %{SOURCE7} > bacula.pam
%endif

%build
%serverbuild
%configure \
	--enable-smartalloc \
	--with-%{db_type} \
%if %{GNOME}
	--enable-gnome \
%endif
%if %{WXWINDOWS}
	--enable-wx-console \
%endif
%if %{TCPW}
	--with-tcp-wrappers \
%endif
	--with-python \
	--sysconfdir=%{_sysconfdir}/%{name} \
	--with-scriptdir=%{_libexecdir}/%{name} \
	--with-working-dir=%{_localstatedir}/%{name} \
	--with-subsys-dir=/var/lock/subsys \
	--with-dir-password="#FAKE#DIR#PASSWORD#" \
	--with-fd-password="#FAKE#FD#PASSWORD#" \
	--with-sd-password="#FAKE#SD#PASSWORD#" \
	--with-mon-dir-password="#FAKE#MON#DIR#PASSWORD#" \
  	--with-mon-fd-password="#FAKE#MON#FD#PASSWORD#" \
	--with-mon-sd-password="#FAKE#MON#SD#PASSWORD#"

%make

%if %{GUI}
# Now we build the gui
( 
  cd gui
  %configure --with-bacula="${PWD%/*}"
  %make 
)
%endif

%install
rm -rf %{buildroot}

%makeinstall sysconfdir=%{buildroot}%{_sysconfdir}/%{name} scriptdir=%{buildroot}%{_libexecdir}/%{name} working_dir=%{buildroot}%{_localstatedir}/%{name}

# install the upgrade scripts
install -m 755 updatedb/update_%{db_type}_tables_?_to_? %{buildroot}%{_libexecdir}/%{name}

# install the init scripts
mkdir -p %{buildroot}%{_initrddir}
install -m 755 platforms/mandrake/bacula-dir %{buildroot}%{_initrddir}/bacula-dir
install -m 755 platforms/mandrake/bacula-fd %{buildroot}%{_initrddir}/bacula-fd
install -m 755 platforms/mandrake/bacula-sd %{buildroot}%{_initrddir}/bacula-sd

# install the logrotate file
mkdir -p %{buildroot}%{_sysconfdir}/logrotate.d
cp scripts/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/bacula-dir

mkdir -p %{buildroot}%{_localstatedir}/%{name}

mkdir -p %{buildroot}%{_sysconfdir}/security/console.apps
mkdir -p %{buildroot}%{_sysconfdir}/pam.d
mkdir -p %{buildroot}%{_bindir}

cat << EOF > %{buildroot}%{_sysconfdir}/security/console.apps/bconsole
USER=root
PROGRAM=%{_sbindir}/bconsole
SESSION=true
EOF

install -m0644 bacula.pam %{buildroot}%{_sysconfdir}/pam.d/bconsole
ln -s consolehelper %{buildroot}%{_bindir}/bconsole

# install the man pages
#mkdir -p %{buildroot}%{_mandir}
tar jxvf %{SOURCE2} -C %{buildroot}%{_mandir}

# install the menu stuff
%if %{GNOME} || %{WXWINDOWS}
mkdir -p %{buildroot}%{_menudir}
mkdir -p %{buildroot}%{_iconsdir}
tar jxvf %{SOURCE1} -C %{buildroot}%{_iconsdir}
%endif
%if %{GNOME}
cat << EOF > %{buildroot}%{_menudir}/%{name}-console-gnome
?package(%{name}-console-gnome): command="%{_bindir}/gnome-console" icon="%{name}.png" needs="x11" title="Bacula Console (gnome)" longtitle="Bacula Director Console" section="System/Archiving/Backup"
EOF
cat << EOF > %{buildroot}%{_sysconfdir}/security/console.apps/gnome-console
USER=root
PROGRAM=%{_sbindir}/gnome-console
SESSION=true
EOF
install -m0644 bacula.pam %{buildroot}%{_sysconfdir}/pam.d/gnome-console
ln -s consolehelper %{buildroot}%{_bindir}/gnome-console
%endif
%if %{WXWINDOWS}
cat << EOF > %{buildroot}%{_menudir}/%{name}-console-wx
?package(%{name}-console-wx): command="%{_bindir}/wx-console" icon="%{name}.png" needs="x11" title="Bacula Console (wxWindows)" longtitle="Bacula Director Console" section="System/Archiving/Backup"
EOF
cat << EOF > %{buildroot}%{_sysconfdir}/security/console.apps/wx-console
USER=root
PROGRAM=%{_sbindir}/wx-console
SESSION=true
EOF
install -m0644 bacula.pam %{buildroot}%{_sysconfdir}/pam.d/wx-console
ln -s consolehelper %{buildroot}%{_bindir}/wx-console
# we need to install the program files as well
#install -m 755 src/wx-console/wx-console %{buildroot}%{_sbindir}
#cp -p src/console/bconsole.conf %{buildroot}%{_sysconfdir}/%{name}/wx-console.conf
%endif

# Remove some left-over in the compil process to the correct path
%__rm -f %{buildroot}/%{_libdir}/%{name}/{start,stop}mysql 
%__rm -f %{buildroot}/%{_libdir}/%{name}/gconsole

perl -spi -e 's/"#FAKE#(\w+)#PASSWORD#"/#YOU MUST SET THE $1 PASSWORD#/' %{buildroot}%{_sysconfdir}/%{name}/*.conf
perl -spi -e 's/"#FAKE#MON#(\w+)#PASSWORD#"/#YOU MUST SET THE MONITOR $1 PASSWORD#/' %{buildroot}%{_sysconfdir}/%{name}/*.conf
touch %{buildroot}%{_sysconfdir}/%{name}/.pw.sed

mv %{buildroot}/%{_mandir}/bacula.8* %{buildroot}%{_mandir}/man8/

%if %{GUI}
# install of bimagemgr
install -d -m 0755 %{buildroot}/%{_var}/www/html/bimagemgr
install -d -m 0755 %{buildroot}/%{_var}/www/cgi-bin
install -d -m 0755 %{buildroot}/%{_sysconfdir}
cp gui/bimagemgr/bimagemgr.pl %{buildroot}/%{_var}/www/cgi-bin
cp gui/bimagemgr/create_cdimage_table.pl %{buildroot}/%{_sysconfdir}
cp gui/bimagemgr/*.{html,gif} %{buildroot}/%{_var}/www/html/bimagemgr

# install of bacula-web
install -d -m 0755 %{buildroot}/%{_var}/www/html/bacula
cp -rf gui/bacula-web %{buildroot}/%{_var}/www/html/bacula
rm -rf %{buildroot}/%{_var}/www/html/bacula/external_packages/{smarty,phplot}
%endif

%clean
rm -rf %{buildroot}

%files common
%defattr(644, root, root, 755)
%dir %{_sysconfdir}/%{name}
%attr(755, root, root) %{_sbindir}/btraceback
%attr(755, root, root) %{_sbindir}/bsmtp
%attr(755, root, root) %{_sbindir}/bregex
%attr(755, root, root) %{_sbindir}/bwild
%dir %{_libexecdir}/%{name}
%{_libexecdir}/%{name}/btraceback.gdb
%{_libexecdir}/%{name}/btraceback.dbx
# i think this should go into bacula-sd
%attr(755, root, root) %{_libexecdir}/%{name}/dvd-handler
%attr(770, bacula, bacula) %dir %{_localstatedir}/%{name}
%{_mandir}/man8/bacula.8*
%exclude %{_libexecdir}/%{name}/bacula

%pre common
%_pre_useradd bacula %{_localstatedir}/%{name} /bin/false
#__pre_groupadd TAPE_GROUP bacula

%postun common
%_postun_userdel bacula

%files dir
%defattr(644, root, root, 755)
%doc ChangeLog CheckList ReleaseNotes kernstodo
# FIXME : Merge baculs-docs and use it
#%doc doc/*.pdf doc/manual examples
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-dir.conf
%ghost %{_sysconfdir}/%{name}/.pw.sed
%config(noreplace) %{_sysconfdir}/logrotate.d/bacula-dir
%{_mandir}/man8/bacula-dir.8*
%{_mandir}/man1/dbcheck.1*
%defattr (755, root, root)
%attr(0755,root,root) %{_initrddir}/bacula-dir
%{_sbindir}/bacula-dir
%{_sbindir}/dbcheck
%{_libexecdir}/%{name}/create_%{db_type}_database
%{_libexecdir}/%{name}/drop_%{db_type}_database
%{_libexecdir}/%{name}/drop_%{db_type}_tables
%{_libexecdir}/%{name}/grant_%{db_type}_privileges
%{_libexecdir}/%{name}/make_%{db_type}_tables
%{_libexecdir}/%{name}/update_%{db_type}_tables*
%{_libexecdir}/%{name}/create_bacula_database
%{_libexecdir}/%{name}/drop_bacula_database
%{_libexecdir}/%{name}/drop_bacula_tables
%{_libexecdir}/%{name}/grant_bacula_privileges
%{_libexecdir}/%{name}/make_bacula_tables
%{_libexecdir}/%{name}/update_bacula_tables
%{_libexecdir}/%{name}/make_catalog_backup
%{_libexecdir}/%{name}/delete_catalog_backup
%attr(644, root, root) %{_libexecdir}/%{name}/query.sql
%if ! %{GNOME}
%exclude %{_mandir}/man1/gnome-console.1*
%endif
%if ! %{WXWINDOWS}
%exclude %{_mandir}/man1/wx-console.1*
%endif
%exclude %{_libexecdir}/%{name}/bacula-ctl-dir


%pre dir
/usr/bin/perl -e '
$confdir="%{_sysconfdir}/%{name}";
$conffile="$confdir/.pw.sed";
if ( -f "$conffile") {
	open(IN, "<$conffile") or die "$!";
	while (<IN>) {
		/#YOU MUST SET THE (.*) PASSWORD#/ && $already{$1}++;
	}
	close(IN);
}
mkdir("$confdir");
umask(0077);
open(IN, "/dev/random") or die "$!";
open(OUT, ">>$conffile") or die "$!";
foreach $c ("DIR","SD","FD","MONITOR DIR","MONITOR SD","MONITOR FD") {
next if ($already{$c});
read(IN, $buf, 32);
my $res = pack("u", $buf);
$res =~ s/^.//mg;
$res =~ s/\n//g;
$res =~ tr|` -_|AA-Za-z0-9+/|;
	print OUT "s!#YOU MUST SET THE $c PASSWORD#!\"$res\"!\n";
}
close (IN);
close (OUT);
'

%post dir
umask 077
%if %{MYSQL}
# NOTE: IF THIS FAILS DUE TO MYSQL/PGSQL NEEDING A PASSWORD YOU ARE ON YOUR OWN
DB_VER=`mysql bacula -e 'select * from Version;' | tail -n 1 2>/dev/null`
%else
%if %{PGSQL}
DB_VER=`psql bacula -c 'select * from Version;' | tail -n 1 2>/dev/null`
%else
[ -s %{_localstatedir}/%{name}/bacula.db ] && \
	DB_VER=`echo "select * from Version;" | \
		sqlite %{_localstatedir}/%{name}/bacula.db | tail -n 1 2>/dev/null`
%endif
%endif
if [ -z "$DB_VER" ]; then
# grant privileges and create tables
	%{_libexecdir}/%{name}/grant_bacula_privileges > dev/null
	%{_libexecdir}/%{name}/create_bacula_database > dev/null
	%{_libexecdir}/%{name}/make_bacula_tables > dev/null
elif [ "$DB_VER" -lt "9" ]; then
	echo "Backing up bacula tables"
%if %{MYSQL}
	mysqldump -f --opt bacula | bzip2 > %{_localstatedir}/%{name}/bacula_backup.sql.bz2
%else
%if %{PGSQL}
	pg_dump bacula | bzip2 > %{_localstatedir}/%{name}/bacula_backup.sql.bz2
%else
	echo ".dump" | sqlite %{_localstatedir}/%{name}/bacula.db | bzip2 > %{_localstatedir}/%{name}/bacula_backup.sql.bz2
%endif
%endif
	echo "Upgrading bacula tables"
	if [ "$DB_VER" -lt "4" ]; then
		echo "your bacula database version is too old to be upgraded automatically"
	elif [ "$DB_VER" -lt "8" ]; then
		if [ "$DB_VER" -lt "7" ]; then
			if [ "$DB_VER" -lt "6" ]; then
				if [ "$DB_VER" -lt "5" ]; then
					%{_libexecdir}/%{name}/update_%{db_type}_tables_4_to_5
				fi
				%{_libexecdir}/%{name}/update_%{db_type}_tables_5_to_6
			fi
			%{_libexecdir}/%{name}/update_%{db_type}_tables_6_to_7
		fi
		%{_libexecdir}/%{name}/update_%{db_type}_tables_7_to_8
	fi
	%{_libexecdir}/%{name}/update_bacula_tables
	echo "If bacula works correctly you can remove the backup file %{_localstatedir}/%{name}/bacula_backup.sql.bz2"
fi
chown -R bacula:bacula %{_localstatedir}/%{name}
chmod -R u+rX,go-rwx %{_localstatedir}/%{name}
%post_fix_config *
%_post_service bacula-dir

%preun dir
%_preun_service bacula-dir

%files fd
%defattr(755, root, root)
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-fd.conf
%attr(0755,root,root) %{_initrddir}/bacula-fd
%{_sbindir}/bacula-fd
%attr(644, root, root) %{_mandir}/man8/bacula-fd.8*
%exclude %{_libexecdir}/%{name}/bacula-ctl-fd

%post fd
%post_fix_config bacula-fd
%_post_service bacula-fd

%preun fd
%_preun_service bacula-fd

%files sd
%defattr(755, root, root)
%dir %{_sysconfdir}/%{name}
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bacula-sd.conf
%attr(0755,root,root) %{_initrddir}/bacula-sd
%{_sbindir}/bacula-sd
%{_sbindir}/bcopy
%{_sbindir}/bextract
%{_sbindir}/bls
%{_sbindir}/bscan
%{_sbindir}/btape
%{_libexecdir}/%{name}/mtx-changer
%{_libexecdir}/%{name}/disk-changer
%defattr(644, root,root, 755)
%{_mandir}/man8/bacula-sd.8*
%{_mandir}/man1/bcopy.1*
%{_mandir}/man1/bextract.1*
%{_mandir}/man1/bls.1*
%{_mandir}/man1/bscan.1*
%{_mandir}/man1/btape.1*
%exclude %{_libexecdir}/%{name}/bacula-ctl-sd

%post sd
%post_fix_config bacula-sd
%_post_service bacula-sd

%preun sd
%_preun_service bacula-sd

%files console
%defattr(644, root, root, 755)
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/bconsole.conf
%attr(755, root, root) %{_sbindir}/bconsole
%config(noreplace) %{_sysconfdir}/security/console.apps/bconsole
%config(noreplace) %{_sysconfdir}/pam.d/bconsole
%verify(link) %{_bindir}/bconsole
%{_mandir}/man1/bconsole.1*
%attr(755, root, root) %{_libdir}/%{name}/bconsole

%pre console
if [ -e %{_sysconfdir}/%{name}/console.conf -a ! -e %{_sysconfdir}/%{name}/bconsole.conf ]; then
	mv %{_sysconfdir}/%{name}/console.conf %{_sysconfdir}/%{name}/bconsole.conf
fi

%post console
%post_fix_config bconsole

%if %{GNOME}
%files console-gnome
%defattr(644, root, root, 755)
%{_iconsdir}/%{name}.png
%{_miconsdir}/%{name}.png
%{_liconsdir}/%{name}.png
%{_menudir}/bacula-console-gnome
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/gnome-console.conf
%attr(755, root, root) %{_sbindir}/gnome-console
%config(noreplace) %{_sysconfdir}/security/console.apps/gnome-console
%config(noreplace) %{_sysconfdir}/pam.d/gnome-console
%verify(link) %{_bindir}/gnome-console
%{_mandir}/man1/gnome-console.1*

%post console-gnome
%post_fix_config gnome-console
%update_menus
		
%postun console-gnome
%clean_menus

%endif

%if %{WXWINDOWS}
%files console-wx
%defattr(644, root, root, 755)
%{_iconsdir}/%{name}.png
%{_miconsdir}/%{name}.png
%{_liconsdir}/%{name}.png
%{_menudir}/bacula-console-wx
%attr(600, root, root) %config(noreplace) %{_sysconfdir}/%{name}/wx-console.conf
%attr(755, root, root) %{_sbindir}/wx-console
%config(noreplace) %{_sysconfdir}/security/console.apps/wx-console
%config(noreplace) %{_sysconfdir}/pam.d/wx-console
%verify(link) %{_bindir}/wx-console
%{_mandir}/man1/wx-console.1*

%post console-wx
%post_fix_config wx-console
%update_menus
		
%postun console-wx
%clean_menus

%endif

%if %{GUI}
%files gui-web
%{_var}/www/html/bacula/*

%files gui-bimagemgr
%{_var}/www/html/bimagemgr/*.gif
%{_var}/www/html/bimagemgr/*.html
%{_var}/www/cgi-bin/bimagemgr.pl
%{_sysconfdir}/create_cdimage_table.pl
%endif

%changelog
* Fri Jul 07 2006 Oden Eriksson <oeriksson@mandriva.com> 1:1.38.11-3mdv2007.0
- broke out the docs

* Sun Jul 02 2006 Luca Berra <bluca@vodka.it> 1:1.38.11-2mdv2007.0
- upgrade bacula database to version 9 on install
- also create random monitor passwords on install or upgrade
- simplify db related macros in spec

* Sat Jul 01 2006 Oden Eriksson <oeriksson@mandriva.com> 1:1.38.11-1mdv2007.0
- 1.38.11 (Major bugfixes)

* Tue Jun 13 2006 Oden Eriksson <oeriksson@mandriva.com> 1:1.38.10-1mdv2007.0
- 1.38.10
- misc spec file fixes
- use wxGTK2.6
- make it backportable for older pam (S6,S7)

* Mon Apr 17 2006 Luca Berra <bluca@vodka.it> 1.38.8-1mdk
- 1.38.8
- allow rescue, gui and docs to be different version than bacula
- do not requiere mysqlserver for the gui (could well be on a different host)
- fix description for postgres builds
- conditional build of gui and docs

* Wed Mar 02 2006 Nicolas Chipaux <chipaux@mandriva.com> 1.38.5-2mdk
- split docs
- merge bacula-gui
- merge bacula-bimagemgr
- add missing BuildRequires
- disable tcpwrapper in default build

* Wed Mar 01 2006 Nicolas Chipaux <chipaux@mandriva.com> 1.38.5-1mdk
- 1.38.5
- merge bacula-doc

* Fri Mar 18 2005 Luca Berra <bluca@vodka.it> 1.36.2-1mdk
- 1.36.2

* Sat Jan 15 2005 Luca Berra <bluca@vodka.it> 1.36.1-1mdk 
- 1.36.1
- use distro specific release tags
- rediff p0, p1
- fix non existent macro %%elsf (Pascal Cavy)
- do not require MySQL server but MySQL-client (Pascal Cavy)
- require postgresql
- use wxGTK2.5

* Sun Jun 27 2004 Luca Berra <bluca@vodka.it> 1.34.5-1mdk 
- 1.34.5
- added manpages (stolen from debian package)

* Mon Jun 21 2004 Luca Berra <bluca@vodka.it> 1.34.4-1mdk 
- 1.34.4
- switched back to wxWindows-2.4

* Fri Jun 04 2004 Luca Berra <bluca@vodka.it> 1.34.3-0.cvs.20040604mdk 
- 1.34.2 cvs

* Tue Apr 27 2004 Luca Berra <bluca@vodka.it> 1.34.2-1mdk 
- 1.34.2 release
- dropped p4, p5

* Sat Apr 24 2004 Luca Berra <bluca@vodka.it> 1.34.1-1 
- 1.34.1 release
- bscan fix from cvs

* Sun Apr 18 2004 Luca Berra <bluca@vodka.it> 1.34.1-0.cvs.20040418mdk 
- update to 1.34.1 from cvs
- rediffed p0, p2 added p3
- readline is not used anymore, so remove p1
- termcap-devel BuildRequires for console
- console binary was renamed to bconsole
- tools can be run with usermode consolehelper
- reworked db update logic
- added wxWindows gui

* Thu Feb 26 2004 Luca Berra <bluca@vodka.it> 1.32f-2mdk 
- added patches 1 to 4 from upstream
- split bacula-common package to ease upgrades
- some cleanups
- use epochs in requires

* Thu Jan 01 2004 Luca Berra <bluca@vodka.it> 1.32f-1mdk
- 1.32f
- revert .rpmnew change (it was not working anyway)
- DIRM: include directory %%{_sysconfig}/%%{name}
- use a macro to change passwords in config files in %%post
- removed subdir creation in %%setup
- added prereq sed to dir package
- changed default user for dir and sd daemons
- changed name of pid files, so killproc finds them
- more conflicts

* Tue Nov 04 2003 Luca Berra <bluca@vodka.it> 1.32d-1mdk
- 1.32d
- use gnome2 for console
- use tcp_wrappers
- try not to create unneeded .rpmnew in configuration

* Fri Aug 12 2003 Luca Berra <bluca@vodka.it> 1.31a-1mdk
- 1.31a
- modified %%post script to upgrade database if needed and do not try to create if it already exists.
- %%post_service should be last in %%post script
- changed sql upgrade script to remove multiple Version rows introduced by %%post
- trying to create the tables multiple times in previous releases.
- smtp is required by btraceback which is required by every daemon.
- added conflicts for lower version

* Wed Aug  6 2003 Luca Berra <bluca@vodka.it> 1.30a-3mdk
- changed sqlite requires to match package in contrib
- set passwords for single components to produce an error until user changes them
- try to change passwords automatically if dir package is installed

* Sun Aug  3 2003 Luca Berra <bluca@vodka.it> 1.30a-2mdk
- many spec changes
- almost please rpmlint
- fixed readline eats last message bug in console

* Fri Aug  1 2003 Luca Berra <bluca@vodka.it> 1.30a-1mdk
- Initial spec file from spec by D. Scott Barninger <barninger at fairfieldcomputers.com>