[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFS: courier-pythonfilter



On Monday 03 November 2008 15:15, Stephan Peijnik wrote:
> > These .py files are not to be executed directly in any way, other
> > than from within the pythonfilter apps itself.
>
> If those files are not to be executed directly in any way removing
> the shebang might a.) be a good idea and b.) fix your lintian
> warnings. Hope that helps.

Stephan, thank you for that suggestion. Since there are quite 
a few .py files, I decided to write a small bash script[0] to help me 
quickly generate dpatches for all of them.

As such I've now done a new upload which utilizes dpatch for the 
purpose of removing the shebangs where it is appropriate to do so.

I've also included a watch file, btw.
http://mentors.debian.net/debian/pool/main/c/courier-pythonfilter/


I'm really crossing my fingers that a sponsor will find time
to do an upload to the official Debian archives of this package
as there is nothing similar currently in the Debian archives.


pythonfilter is incredible useful for anybody running the Courier MTA
as it provides a whole bunch of filters, ready to use. This includes
a greylisting filter, a spamassassin filter, a clamav filter, an 
attachments filter, a noduplicates filter (if courier receives
a message with multiple aliases that expand to the same address, 
the message may be delivered to that address multiple times. 
This module checks for, and removes the duplicates), and many
others.

At the same time, pythonfilter offers a framework for easy development
of new filters.

B/R,
Frederik Dannemare



[0]
#!/bin/bash
#set -x

APP="courier-pythonfilter-1.4"
PATCHDIR="${APP}/debian/patches"

PATCHDESC="is not
executable in upstream sources and should only be
called from within the pythonfilter apps themselves.
Hence, #!/usr/bin/python is removed for better
Debian Policy compliance."

[ -d ${PATCHDIR} ] || mkdir ${PATCHDIR}
:>${PATCHDIR}/00list

COUNTER=1
for dir in "${APP}/courier ${APP}/filters"; do
  for file in $(find ${dir} -name "*.py"); do
    if [ $(head -n1 ${file} | egrep '^#!/usr/bin/python') ]; then
      cp ${file} ${file}.upstream
      tail --lines=+2 ${file}.upstream >${file}
      diff -u ${file}.upstream ${file} >${file}.diff

      if [ ${COUNTER} -le 9 ]; then
        NUMBER="0${COUNTER}"
      else
        NUMBER="${COUNTER}"
      fi
      dpatch patch-template -p "${NUMBER}_shebang_removal" \
       "${file} ${PATCHDESC}" \
       <${file}.diff >${PATCHDIR}/${NUMBER}_shebang_removal.dpatch
      echo "$(basename ${PATCHDIR}/${NUMBER}_shebang_removal.dpatch)" >>${PATCHDIR}/00list
      (( COUNTER++ ))

      mv ${file}.upstream ${file}
      rm ${file}.diff
    else
      echo "${file} is without a shebang. No need to create patch for it."
    fi
  done
done

Attachment: pgpPwpu13mXhh.pgp
Description: PGP signature


Reply to: