Reportcourier-filter-perlpreinst

Status: Accepted

Colis script


function prep_mv_conffile begin
                            PKGNAME := arg 1 ;
                            CONFFILE := arg 2 ;
                            if [ [ '-e'; CONFFILE; ']' ]
                            then begin
                                   md5sum :=
                                     embed {
                                     pipe
                                     md5sum [ '\' CONFFILE '\' ]
                                     into sed [ '-e'; '\' 's/ .*//\' ] epip } ;
                                   old_md5sum :=
                                     embed {
                                     pipe
                                     dpkg-query [ '-W'; '-f=' '${Conffiles}';
                                                split PKGNAME ]
                                     into sed [ '-n'; '-e';
                                              '\'
                                              '\\\\' ' CONFFILE
                                              ''{s/ obsolete$//;s/.* //p}\' ]
                                     epip } ;
                                   if [ [ md5sum; '='; old_md5sum; ']' ]
                                   then rm [ '-f'; CONFFILE ] fi
                              end
                            fi
end
begin
  true ;
  mode := arg 1 ;
  true ;
  case_4244755 := mode ;
  if (test [ case_4244755; '='; 'install' ] ||
       test [ case_4244755; '='; 'upgrade' ])
  then begin
         old_version := arg 2 ;
         if dpkg [ '--compare-versions'; old_version; 'lt'; '0.200' ]
         then begin
                pureperlfilter_link :=
                  '/etc/courier/filters/active/pureperlfilter' ;
                if [ [ '-h'; split pureperlfilter_link; ']' ]
                then begin
                       echo [ 'Disabling pureperlfilter mail filter ...' ] ;
                       rm [ split pureperlfilter_link ] ;
                       courierfilter [ 'restart' ]
                  end
                fi ;
                call prep_mv_conffile [ 'courier-filter-perl';
                                      '/etc/courier/filters/pureperlfilter.conf' ]
           end
         fi
    end
  fi
end

Original Shell script

#!/bin/sh

set -e

mode=$1

# Prepare to move a conffile without triggering a dpkg question
prep_mv_conffile() {
    PKGNAME="$1"
    CONFFILE="$2"
    
    if [ -e "$CONFFILE" ]; then
        md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
        old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
        if [ "$md5sum" = "$old_md5sum" ]; then
            rm -f "$CONFFILE"
        fi
    fi
}

case "$mode" in
  install | upgrade )
    old_version=$2
    
    if dpkg --compare-versions "$old_version" lt "0.200"; then
        pureperlfilter_link=/etc/courier/filters/active/pureperlfilter
        if [ -h $pureperlfilter_link ]; then
            echo "Disabling pureperlfilter mail filter ..."
            rm $pureperlfilter_link
            courierfilter restart
        fi
        
        prep_mv_conffile courier-filter-perl /etc/courier/filters/pureperlfilter.conf
    fi
    ;;
esac