[BackupPC] attempt to make sure $Conf{TopDir} is listed in updatedb PRUNEPATHS, otherwise at least generate a w

Bernard Johnson bjohnson at fedoraproject.org
Sat Jul 9 05:33:30 UTC 2011


commit bbae64c8dca720f4532d48f4a8fa6cb25a9bbf68
Author: Bernard Johnson <bjohnson at symetrix.com>
Date:   Thu Jul 7 22:16:49 2011 -0600

    attempt to make sure $Conf{TopDir} is listed in updatedb PRUNEPATHS,
    otherwise at least generate a warning on statup (bz #554491)

 BackupPC-3.2.1-locatedb.patch |   37 +++++++++++++++++++++++++++++++++++++
 BackupPC.spec                 |   20 +++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/BackupPC-3.2.1-locatedb.patch b/BackupPC-3.2.1-locatedb.patch
new file mode 100644
index 0000000..c631383
--- /dev/null
+++ b/BackupPC-3.2.1-locatedb.patch
@@ -0,0 +1,37 @@
+diff -Naur BackupPC-3.2.1-pristine/init.d/src/linux-backuppc BackupPC-3.2.1/init.d/src/linux-backuppc
+--- BackupPC-3.2.1-pristine/init.d/src/linux-backuppc	2011-04-24 21:31:55.000000000 -0600
++++ BackupPC-3.2.1/init.d/src/linux-backuppc	2011-07-07 21:36:41.363281386 -0600
+@@ -20,6 +20,25 @@
+ 
+ RETVAL=0
+ 
++topDirCheck()
++{
++    updatedb=/etc/updatedb.conf
++    topdir=$(perl <<_EOF_
++      require '__CONFDIR__/config.pl';
++      print \$Conf{TopDir};
++_EOF_
++)
++    if [ -r $updatedb ]; then
++      grep ^PRUNEPATHS $updatedb | grep ${topdir%%/} > /dev/null
++      if [ $? -eq 1]; then
++        logger -t BackupPC -s "WARNING:  Your BackupPC \$Conf{TopDir} is not listed in the locate"
++        logger -t BackupPC -s "database configuration's PRUNEPATHS.  This may cause all of your"
++        logger -t BackupPC -s "backed up files to be indexed!"
++      fi
++    fi
++}
++
++
+ start() {
+     #
+     # You can set the SMB share password here is you wish.  Otherwise
+@@ -38,6 +57,7 @@
+     echo
+     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/backuppc || \
+        RETVAL=1
++    topDirCheck 
+     return $RETVAL
+ }	
+ 
diff --git a/BackupPC.spec b/BackupPC.spec
index 2e59676..d23316a 100644
--- a/BackupPC.spec
+++ b/BackupPC.spec
@@ -11,6 +11,7 @@ Group:          Applications/System
 License:        GPLv2+
 URL:            http://backuppc.sourceforge.net/
 Source0:        http://downloads.sourceforge.net/backuppc/%{name}-%{version}.tar.gz
+Patch0:         BackupPC-3.2.1-locatedb.patch
 Source1:        BackupPC.htaccess
 Source2:        BackupPC.logrotate
 Source3:        BackupPC-README.fedora
@@ -63,6 +64,8 @@ configurable and easy to install and maintain.
 
 %setup -q
 
+%patch0 -p1 -b .locatedb
+
 sed -i "s|\"backuppc\"|\"$LOGNAME\"|g" configure.pl
 for f in ChangeLog doc/BackupPC.pod doc/BackupPC.html; do
   iconv -f ISO-8859-1 -t UTF-8 $f > $f.utf && mv $f.utf $f
@@ -206,6 +209,14 @@ chkconfig --add backuppc || :
 service httpd condrestart > /dev/null 2>&1 || :
 %{_sbindir}/usermod -a -G backuppc apache || :
 
+# add BackupPC backup directories to PRUNEPATHS in locate database
+UPDATEDB=/etc/updatedb.conf
+if [ -w $UPDATEDB ]; then
+  grep ^PRUNEPATHS $UPDATEDB | grep %{_sharedstatedir}/%{name} > /dev/null
+  if [ $? -eq 1 ]; then
+    sed -i '\@PRUNEPATHS at s@"$@ '%{_sharedstatedir}/%{name}'"@' $UPDATEDB
+  fi
+fi
 
 %postun
 service httpd condrestart > /dev/null 2>&1 || :
@@ -215,6 +226,11 @@ if [ "$1" -eq "0" ]; then
      # Remove the SElinux policy.
      semodule -r %{name} || :
      )&>/dev/null
+
+    # remove BackupPC backup directories from PRUNEPATHS in locate database
+    if [ -w $UPDATEDB ]; then
+      sed -i '\@PRUNEPATHS at s@[ ]*'%{_sharedstatedir}/%{name}'@@' $UPDATEDB
+    fi
 fi
 %endif
 
@@ -244,7 +260,7 @@ fi
 %endif
 
 %changelog
-* Wed Jul 06 2011 Bernard Johnson <bjohnson at symetrix.com> - 3.2.1-1
+* Thu Jul 07 2011 Bernard Johnson <bjohnson at symetrix.com> - 3.2.1-1
 - v 3.2.1
 - add lower case script alias for typing impaired
 - cleanup selinux macros
@@ -253,6 +269,8 @@ fi
   or samba3x-client (bz #667479)
 - unbundle perl(Net::FTP::AutoReconnect) and perl(Net::FTP::RetrHandle)
 - remove old patch that is no longer needed
+- attempt to make sure $Conf{TopDir} is listed in updatedb PRUNEPATHS,
+  otherwise at least generate a warning on statup (bz #554491)
 
 * Mon Feb 07 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 3.1.0-17
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild


More information about the scm-commits mailing list