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-dev/; revision=3011

debian/changelog
debian/invirt-dev.prerm

index 3ef804a..0cf4983 100644 (file)
@@ -7,8 +7,9 @@ invirt-dev (0.1.0) unstable; urgency=low
   * Since the prerm code to remove the repo group from sudoers runs on
     upgrades, make sure the postinst code to add it back runs on all
     upgrades, too.
   * Since the prerm code to remove the repo group from sudoers runs on
     upgrades, make sure the postinst code to add it back runs on all
     upgrades, too.
+  * Use the .. Perl operator to simplify the prerm.
 
 
- -- Evan Broder <broder@mit.edu>  Thu, 17 Dec 2009 16:06:31 -0600
+ -- Evan Broder <broder@mit.edu>  Thu, 27 May 2010 11:55:06 -0400
 
 invirt-dev (0.0.14) unstable; urgency=low
 
 
 invirt-dev (0.0.14) unstable; urgency=low
 
index 80d7817..3a0d421 100755 (executable)
@@ -21,7 +21,7 @@ case "$1" in
     remove|upgrade|deconfigure)
         [ "$1" = "remove" ] && update-inetd --disable git
 
     remove|upgrade|deconfigure)
         [ "$1" = "remove" ] && update-inetd --disable git
 
-        perl -i.bak -ne 's%^### (BEGIN|END) invirt-dev\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+        perl -i.bak -ne 'print unless /^### BEGIN invirt-dev/../^### END invirt-dev/' /etc/sudoers
     ;;
 
     failed-upgrade)
     ;;
 
     failed-upgrade)