#! /bin/sh /usr/share/dpatch/dpatch-run
## 30_update_perlcalling.sh.dpatch by Sven Mueller <debian@incase.de>
## Updated to 2.3.13 by Duncan Gibb <duncan.gibb@siriusit.co.uk>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: updates calling of the perl interpreter to what we expect in Debian.
## DP: More precisely: Call /usr/bin/perl directly instead of using some
## DP: shell magic to locate perl and run it.
## DP: NOTE: only some script use the "-w" or even the "-T" flag for perl.
## DP:       This should be the default actually. 

@DPATCH@
--- a/perl/imap/examples/auditmbox.pl
+++ b/perl/imap/examples/auditmbox.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
--- a/perl/imap/examples/imapcollate.pl
+++ b/perl/imap/examples/imapcollate.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
--- a/perl/imap/examples/imapdu.pl
+++ b/perl/imap/examples/imapdu.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
--- a/perl/sieve/scripts/installsieve.pl
+++ b/perl/sieve/scripts/installsieve.pl
@@ -1,6 +1,4 @@
-#! /bin/sh
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
--- a/perl/sieve/scripts/sieveshell.pl
+++ b/perl/sieve/scripts/sieveshell.pl
@@ -1,6 +1,4 @@
-#! /bin/sh
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
--- a/snmp/snmpgen
+++ b/snmp/snmpgen
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,24 +41,6 @@
 #
 # $Id: snmpgen,v 1.21 2010/01/06 17:02:00 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-w", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 #Tim Martin
--- a/tools/config2header
+++ b/tools/config2header
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,24 +41,6 @@
 #
 # $Id: config2header,v 1.17 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 use strict;
--- a/tools/config2man
+++ b/tools/config2man
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,24 +41,6 @@
 #
 # $Id: config2man,v 1.6 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 use strict;
--- a/tools/dohash
+++ b/tools/dohash
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,26 +41,9 @@
 #
 # $Id: dohash,v 1.14 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
 # script to upgrade from versions of imapd previous to 1.6.2
 # make sure you run it as the cyrus user
 
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 $| = 1;
--- a/tools/masssievec
+++ b/tools/masssievec
@@ -1,4 +1,6 @@
-#!/bin/sh
+#!/usr/bin/perl -w
+#
+# Script for mass compilation of sieve scripts.
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,26 +43,6 @@
 #
 # $Id: masssievec,v 1.8 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-#
-# Script for mass compilation of sieve scripts.
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 $| = 1;
--- a/tools/mkimap
+++ b/tools/mkimap
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/perl -w
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,24 +41,6 @@
 #
 # $Id: mkimap,v 1.20 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 sub read_conf {
--- a/tools/mknewsgroups
+++ b/tools/mknewsgroups
@@ -1,4 +1,6 @@
-#!/bin/sh
+#!/usr/bin/perl -w
+# 
+# Create newsgroups on imap server
 #
 # Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
 #
@@ -41,27 +43,6 @@
 #
 # $Id: mknewsgroups,v 1.4 2010/01/06 17:02:01 murch Exp $
 
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
-#
-# Create newsgroups on imap server
-# Based on the make_fromactive.pl script by Tim Martin
-
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 use Getopt::Long;
--- a/tools/translatesieve
+++ b/tools/translatesieve
@@ -1,6 +1,4 @@
-#!/bin/sh
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
+#!/usr/bin/perl
 # script to translate sieve scripts to use unixhierarchysep and/or altnamespace
 # make sure you run it as the cyrus user
 #!/usr/bin/perl
@@ -46,21 +44,6 @@ exec perl -x -S $0 ${1+"$@"} # -*-perl-*
 #
 # $Id: translatesieve,v 1.10 2010/01/06 17:02:02 murch Exp $
 
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 $| = 1;
--- a/tools/undohash
+++ b/tools/undohash
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
 # script to downgrade from cyrus imapd 1.6.2+ to earlier.
 # do NOT run this script while imapd's are running
 #
--- a/tools/upgradesieve
+++ b/tools/upgradesieve
@@ -1,6 +1,4 @@
-#!/bin/sh
-exec perl -x -S $0 ${1+"$@"} # -*-perl-*-
-#!perl -w
+#!/usr/bin/perl -w
 # script to upgrade sievedir from imapd 1.6.13
 # make sure you run it as the cyrus user
 #!/usr/bin/perl
@@ -46,21 +44,6 @@ exec perl -x -S $0 ${1+"$@"} # -*-perl-*
 #
 # $Id: upgradesieve,v 1.10 2010/01/06 17:02:02 murch Exp $
 
-if ($] !~ /^5\..*/) {
-  # uh-oh. this isn't perl 5.
-  foreach (split(/:/, $ENV{PATH})) { # try to find "perl5".
-    exec("$_/perl5", "-x", "-S", $0, @ARGV) if (-x "$_/perl5");
-  }
-  # we failed. bail.
-  die "Your perl is too old; I need perl 5.\n";
-}
-
-# load the real script. this is isolated in an 'eval' so perl4 won't
-# choke on the perl5-isms.
-eval join("\n", <DATA>);
-if ($@) { die "$@"; }
-
-__END__
 require 5;
 
 $| = 1;
