Use the .. Perl operator to simplify prerms.
authorEvan Broder <broder@mit.edu>
Thu, 27 May 2010 15:58:35 +0000 (11:58 -0400)
committerEvan Broder <broder@mit.edu>
Thu, 27 May 2010 15:58:35 +0000 (11:58 -0400)
invirt-console-host, invirt-dev, and all of the packages in
xvm-munin-config previously used a convoluted one-liner to clean up
/etc/sudoers, but we can do it much more easily using the .. operator.

Taken from http://blog.ksplice.com/2010/05/top-10-perl-one-liner-tricks/

svn path=/trunk/packages/invirt-console/; revision=3011

debian/changelog
debian/invirt-console-host.postinst
debian/invirt-console-host.prerm

index e476e95..4bda8a2 100644 (file)
@@ -1,3 +1,9 @@
+invirt-console (0.2.14) unstable; urgency=low
+
+  * Use the .. Perl operator to simplify the invirt-console-host prerm.
+
+ -- Evan Broder <broder@mit.edu>  Thu, 27 May 2010 11:55:53 -0400
+
 invirt-console (0.2.13) unstable; urgency=low
 
   * Changed dependency debathena-kerberos-config -> invirt-kerberos-config
 invirt-console (0.2.13) unstable; urgency=low
 
   * Changed dependency debathena-kerberos-config -> invirt-kerberos-config
index 9f4b5a8..d2c7c08 100755 (executable)
@@ -20,9 +20,6 @@ set -e
 
 case "$1" in
     configure)
 
 case "$1" in
     configure)
-        # Clean up the old sudoers line before we add it back
-        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
-        
         cat >>/etc/sudoers <<EOF
 ### BEGIN invirt-console-host
 conservr ALL=(ALL) NOPASSWD: /usr/sbin/xm console d_*
         cat >>/etc/sudoers <<EOF
 ### BEGIN invirt-console-host
 conservr ALL=(ALL) NOPASSWD: /usr/sbin/xm console d_*
index 9d0b178..16b07d0 100755 (executable)
@@ -19,7 +19,7 @@ set -e
 
 case "$1" in
     remove|upgrade|deconfigure)
 
 case "$1" in
     remove|upgrade|deconfigure)
-        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+        perl -i.bak -ne 'print unless /^### BEGIN invirt-console-host/../^### END invirt-console-host/' /etc/sudoers
     ;;
 
     failed-upgrade)
     ;;
 
     failed-upgrade)