[cups/f16] Small error handling improvements in the configuration migration script.

Tim Waugh twaugh at fedoraproject.org
Tue Dec 4 12:33:09 UTC 2012


commit 7e8843a3e525f43f683a81a3d840557754a2a039
Author: Tim Waugh <twaugh at redhat.com>
Date:   Tue Dec 4 11:23:03 2012 +0000

    Small error handling improvements in the configuration migration script.

 cups.spec |   66 +++++++++++++++++++++++++++++++++---------------------------
 1 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/cups.spec b/cups.spec
index c2557eb..52446c3 100644
--- a/cups.spec
+++ b/cups.spec
@@ -19,7 +19,7 @@
 Summary: Common Unix Printing System
 Name: cups
 Version: 1.5.4
-Release: 9%{?dist}
+Release: 10%{?dist}
 License: GPLv2
 Group: System Environment/Daemons
 Source: http://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -445,6 +445,32 @@ php --no-php-ini \
 
 
 %post
+if [ $1 -eq 1 ] ; then
+	# Initial installation
+	/bin/systemctl enable cups.{service,socket,path} >/dev/null 2>&1 || :
+fi
+
+# Remove old-style certs directory; new-style is /var/run
+# (see bug #194581 for why this is necessary).
+/bin/rm -rf %{_sysconfdir}/cups/certs
+%if %use_alternatives
+/usr/sbin/alternatives --install %{_bindir}/lpr print %{_bindir}/lpr.cups 40 \
+	 --slave %{_bindir}/lp print-lp %{_bindir}/lp.cups \
+	 --slave %{_bindir}/lpq print-lpq %{_bindir}/lpq.cups \
+	 --slave %{_bindir}/lprm print-lprm %{_bindir}/lprm.cups \
+	 --slave %{_bindir}/lpstat print-lpstat %{_bindir}/lpstat.cups \
+	 --slave %{_bindir}/cancel print-cancel %{_bindir}/cancel.cups \
+	 --slave %{_sbindir}/lpc print-lpc %{_sbindir}/lpc.cups \
+	 --slave %{_mandir}/man1/cancel.1.gz print-cancelman %{_mandir}/man1/cancel-cups.1.gz \
+	 --slave %{_mandir}/man1/lp.1.gz print-lpman %{_mandir}/man1/lp-cups.1.gz \
+	 --slave %{_mandir}/man8/lpc.8.gz print-lpcman %{_mandir}/man8/lpc-cups.8.gz \
+	 --slave %{_mandir}/man1/lpq.1.gz print-lpqman %{_mandir}/man1/lpq-cups.1.gz \
+	 --slave %{_mandir}/man1/lpr.1.gz print-lprman %{_mandir}/man1/lpr-cups.1.gz \
+	 --slave %{_mandir}/man1/lprm.1.gz print-lprmman %{_mandir}/man1/lprm-cups.1.gz \
+	 --slave %{_mandir}/man1/lpstat.1.gz print-lpstatman %{_mandir}/man1/lpstat-cups.1.gz
+%endif
+rm -f %{_localstatedir}/cache/cups/*.ipp %{_localstatedir}/cache/cups/*.cache
+
 # Deal with config migration due to CVE-2012-5519 (STR #4223)
 IN=%{_sysconfdir}/cups/cupsd.conf
 OUT=%{_sysconfdir}/cups/cups-files.conf
@@ -463,49 +489,25 @@ for keyword in AccessLog CacheDir ConfigFilePerm	\
 	     "`/bin/grep -i ^$keyword "$OUT"`" ]; then
 	    copy=no
 	else
-	    /bin/sed -i -e "s,^$keyword,#$keyword,i" "$OUT"
+	    /bin/sed -i -e "s,^$keyword,#$keyword,i" "$OUT" || :
 	fi
     fi
     if [ "$copy" == "yes" ]; then
 	if [ "$copiedany" == "no" ]; then
-	    cat >> "$OUT" <<EOF
+	    ( cat >> "$OUT" <<EOF
 
 # Settings automatically moved from cupsd.conf by RPM package:
 EOF
+	    ) || :
 	fi
 
-	/bin/grep -i ^$keyword "$IN" >> "$OUT"
+	( /bin/grep -i ^$keyword "$IN" >> "$OUT" ) || :
 	copiedany=yes
     fi
 
-    /bin/sed -i -e "s,^$keyword,#$keyword,i" "$IN"
+    /bin/sed -i -e "s,^$keyword,#$keyword,i" "$IN" || :
 done
 
-if [ $1 -eq 1 ] ; then
-	# Initial installation
-	/bin/systemctl enable cups.{service,socket,path} >/dev/null 2>&1 || :
-fi
-
-# Remove old-style certs directory; new-style is /var/run
-# (see bug #194581 for why this is necessary).
-/bin/rm -rf %{_sysconfdir}/cups/certs
-%if %use_alternatives
-/usr/sbin/alternatives --install %{_bindir}/lpr print %{_bindir}/lpr.cups 40 \
-	 --slave %{_bindir}/lp print-lp %{_bindir}/lp.cups \
-	 --slave %{_bindir}/lpq print-lpq %{_bindir}/lpq.cups \
-	 --slave %{_bindir}/lprm print-lprm %{_bindir}/lprm.cups \
-	 --slave %{_bindir}/lpstat print-lpstat %{_bindir}/lpstat.cups \
-	 --slave %{_bindir}/cancel print-cancel %{_bindir}/cancel.cups \
-	 --slave %{_sbindir}/lpc print-lpc %{_sbindir}/lpc.cups \
-	 --slave %{_mandir}/man1/cancel.1.gz print-cancelman %{_mandir}/man1/cancel-cups.1.gz \
-	 --slave %{_mandir}/man1/lp.1.gz print-lpman %{_mandir}/man1/lp-cups.1.gz \
-	 --slave %{_mandir}/man8/lpc.8.gz print-lpcman %{_mandir}/man8/lpc-cups.8.gz \
-	 --slave %{_mandir}/man1/lpq.1.gz print-lpqman %{_mandir}/man1/lpq-cups.1.gz \
-	 --slave %{_mandir}/man1/lpr.1.gz print-lprman %{_mandir}/man1/lpr-cups.1.gz \
-	 --slave %{_mandir}/man1/lprm.1.gz print-lprmman %{_mandir}/man1/lprm-cups.1.gz \
-	 --slave %{_mandir}/man1/lpstat.1.gz print-lpstatman %{_mandir}/man1/lpstat-cups.1.gz
-%endif
-rm -f %{_localstatedir}/cache/cups/*.ipp %{_localstatedir}/cache/cups/*.cache
 exit 0
 
 %post libs -p /sbin/ldconfig
@@ -702,6 +704,10 @@ rm -rf $RPM_BUILD_ROOT
 %{_mandir}/man1/ipptool.1.gz
 
 %changelog
+* Tue Dec  4 2012 Tim Waugh <twaugh at redhat.com> 1:1.5.4-10
+- Small error handling improvements in the configuration migration
+  script.
+
 * Mon Dec  3 2012 Tim Waugh <twaugh at redhat.com> 1:1.5.4-9
 - Applied additional upstream patch for CVE-2012-5519 so that the
   RemoteRoot keyword is recognised in the correct configuration file.


More information about the scm-commits mailing list