+
+%define BPCuser backuppc
+%define BPCgroup backuppc
%include /usr/lib/rpm/macros.perl
+
Summary: A high-performance, enterprise-grade system for backing up PCs
Summary(pl): Wysoko wydajny, profesjonalnej klasy system do kopii zapasowych z PC
Name: backuppc
-Version: 2.0.2
-Release: 2
+Version: 2.1.0
+Release: 0.5
License: GPL
Group: Networking/Utilities
Source0: http://dl.sourceforge.net/backuppc/BackupPC-%{version}.tar.gz
-# Source0-md5: d60aacbf46eb83a7e4ffbbe9e4f72c11
-Patch0: %{name}-debian.patch
+# Source0-md5: 4e201f00842c88cf241e0429643c6ec4
+Source1: %{name}_apache.conf
+Source2: %{name}_htaccess
+Patch0: %{name}-usernotexist.patch
URL: http://backuppc.sourceforge.net/
-BuildRequires: fakeroot
+#BuildRequires: fakeroot
+BuildRequires: perl-base
BuildRequires: perl-devel >= 1:5.6.0
BuildRequires: perl-Compress-Zlib
BuildRequires: perl-Digest-MD5
+Requires: samba-client
+# lets check if it's really needed
+#Requires: sperl
Requires: tar > 1.13
-Requires: samba-clients
-Requires: sperl
-Requires: webserver
+Requires: apache
Obsoletes: BackupPC
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
- Wiele wiêcej mo¿na odkryæ w manualu...
%prep
+
%setup -q -n BackupPC-%{version}
%patch0 -p1
+%build
+sed -i -e 's#!/bin/perl#!%{__perl}#' configure.pl
+sed -i -e 's#!/bin/perl#!%{__perl}#' {bin,cgi-bin,doc}/*
+sed -i -e 's#!/bin/perl#!%{__perl}#' */src/*
+sed -i -e 's#!/bin/perl#!%{__perl}#' */*/*/*.pm
+
+pod2man --section=8 --center="BackupPC manual" doc/BackupPC.pod backuppc.8
+perl -e "s/.IX Title.*/.SH NAME\nbackuppc \\- BackupPC manual/g" -p -i.tmp backuppc.8
+
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT/etc/{rc.d/init.d,backuppc,httpd/httpd.conf} \
- $RPM_BUILD_ROOT/var/lib/backuppc/pc/localhost
+install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/{rc.d/init.d,%{name},httpd/httpd.conf} \
+ $RPM_BUILD_ROOT%{_usr}/share/%{name}/www/html \
+ $RPM_BUILD_ROOT%{_var}/lib/%{name}/pc/localhost \
+ $RPM_BUILD_ROOT%{_datadir}/%{name}/conf
+
+# Does not work, yet... some voodoo-magic is needed
+%{__perl} configure.pl \
+ --batch \
+ --bin-path perl=%{__perl} \
+ --bin-path tar=/bin/tar \
+ --bin-path smbclient=%{_bindir}/smbclient \
+ --bin-path nmblookup=%{_bindir}/nmblookup \
+ --bin-path rsync=%{_bindir}/rsync \
+ --bin-path ping=/bin/ping \
+ --bin-path df=/bin/df \
+ --bin-path ssh=%{_bindir}/ssh \
+ --bin-path sendmail=%{_sbindir}/sendmail \
+ --bin-path hostname=/bin/hostname \
+ --bin-path split=%{_bindir}/split \
+ --bin-path cat=/bin/cat \
+ --bin-path gzip=/bin/gzip \
+ --bin-path bzip2=%{_bindir}/bzip2 \
+ --cgi-dir %{_datadir}/%{name}/cgi-bin \
+ --data-dir %{_var}/lib/%{name} \
+ --dest-dir $RPM_BUILD_ROOT \
+ --hostname localhost \
+ --html-dir %{_usr}/share/%{name}/www/html \
+ --html-dir-url /BackupPC \
+ --install-dir %{_usr} \
+ --uid-ignore
+
+# --config-path
+
+install init.d/linux-backuppc $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/backuppc
+install conf/BackupPC_stnd.css $RPM_BUILD_ROOT%{_var}/lib/%{name}/conf/BackupPC_stnd.css
+install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/httpd.conf/93_backuppc.conf
+install %{SOURCE2} $RPM_BUILD_ROOT%{_datadir}/%{name}/cgi-bin/.htaccess
+
+#mv -f $RPM_BUILD_ROOT/var/lib/backuppc/conf/* $RPM_BUILD_ROOT%{_sysconfdir}/backuppc
+#mv -f $RPM_BUILD_ROOT%{_datadir}/backuppc/cgi-bin/BackupPC_Admin $RPM_BUILD_ROOT%{_datadir}/backuppc/cgi-bin/index.cgi
+
+# Cleanups:
+rm -f $RPM_BUILD_ROOT%{_datadir}/%{name}/www/html/CVS
+
+%pre
+# Add the "backuppc" user and group
+if [ -n "`/usr/bin/getgid %{BPCgroup}`" ]; then
+ if [ "`/usr/bin/getgid %{BPCgroup}`" != "150" ]; then
+ echo "Error: group %{BPCgroup} doesn't have gid=150. Correct this before installing %{name}." 1>&2
+ exit 1
+ fi
+ else
+ /usr/sbin/groupadd -g 150 %{BPCgroup}
+fi
+
+if [ -n "`/bin/id -u %{BPCuser} 2>/dev/null`" ]; then
+ if [ "`/bin/id -u %{BPCuser}`" != 150 ]; then
+ echo "Error: user %{BPCuser} doesn't have uid=150. Correct this before installing %{name}." 1>&2
+ exit 1
+ fi
+ else
+ /usr/sbin/useradd -c "systemowy u¿ytkownik dla %{name}" -u 150 -r -d /home/services/BackupPC -s /bin/false -g %{BPCgroup} %{BPCuser} 1>&2
+fi
-echo "y" | \
-fakeroot DEBIANDEST=$RPM_BUILD_ROOT %{__perl} configure.pl
-pod2man --section=8 --center="BackupPC manual" doc/BackupPC.pod backuppc.8
-perl -e "s/.IX Title.*/.SH NAME\nbackuppc \\- BackupPC manual/g" -p -i.tmp backuppc.8
-rm -f $RPM_BUILD_ROOT%{_datadir}/backuppc/doc/*
-mv -f $RPM_BUILD_ROOT/var/lib/backuppc/conf/* $RPM_BUILD_ROOT%{_sysconfdir}/backuppc
-mv -f $RPM_BUILD_ROOT%{_datadir}/backuppc/cgi-bin/* $RPM_BUILD_ROOT%{_datadir}/backuppc/cgi-bin/index.cgi
-install --mode=644 conf/hosts $RPM_BUILD_ROOT%{_sysconfdir}/backuppc
-install --mode=644 debian/localhost.pl $RPM_BUILD_ROOT%{_sysconfdir}/backuppc
-install --mode=644 debian/apache.conf $RPM_BUILD_ROOT%{_sysconfdir}/httpd/httpd.conf/93_backuppc.conf
-rmdir $RPM_BUILD_ROOT/var/lib/backuppc/conf
-cd $RPM_BUILD_ROOT%{_datadir}/backuppc/cgi-bin
-ln -s ../image
+%post
+ln -s %{_var}/lib/%{name}/conf/ %{_sysconfdir}/backuppc
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc doc/*.html
-%attr(750,root,root) %dir %{_sysconfdir}/backuppc
-%config(noreplace) %verify(not md5 size mtime) %attr(640,root,root) %{_sysconfdir}/backuppc/*
%attr(755,root,root) %{_bindir}/*
-%attr(750,root,root) %dir %{_var}/lib/backuppc
-%{_mandir}/man?/*
+%doc %{_usr}/doc/*.html
+%doc %{_usr}/doc/BackupPC.pod
+%dir %{_datadir}/%{name}/cgi-bin/
+%{_datadir}/%{name}/cgi-bin/*
+%dir %{_usr}/share/%{name}/www/html/
+%{_usr}/share/%{name}/www/html/*
+%dir %{_libdir}/BackupPC/
+%{_libdir}/BackupPC/*
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/cpool/
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/log/
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/pc/
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/pool/
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/trash/
+%dir %attr(750,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/conf/
+%attr(755,root,root) %{_sysconfdir}/rc.d/init.d/backuppc
+%{_sysconfdir}/httpd/httpd.conf/93_backuppc.conf
+%config(noreplace) %verify(not md5 size mtime) %attr(640,root,root) %{_datadir}/%{name}/cgi-bin/.htaccess
+%config(noreplace) %verify(not md5 size mtime) %attr(640,%{BPCuser},%{BPCgroup}) %{_var}/lib/%{name}/conf/*