Am Fri, Dec 09, 2022 at 10:23:03AM +0000 schrieb Stuart Henderson:
> On 2022/12/09 09:17, Martin Ziemer wrote:
> > Am Tue, Dec 06, 2022 at 04:27:53PM +0000 schrieb Stuart Henderson:
> > > On 2022/12/06 16:50, Martin Ziemer wrote:
> > > > Am Tue, Dec 06, 2022 at 03:42:10PM +0000 schrieb Stuart Henderson:
> > > > > On 2022/12/06 16:38, Martin Ziemer wrote:
> > > > > > Am Tue, Dec 06, 2022 at 03:24:51PM +0000 schrieb Stuart Henderson:
> > > > > > > On 2022/12/06 15:22, Stuart Henderson wrote:
> > > > > > > > I have left the getmails patch alone for now as I can't test it 
> > > > > > > > but the
> > > > > > > > pgrep invocation is wrong, it should probably search for 
> > > > > > > > something like
> > > > > > > > "^/bin/sh /usr/local/bin/getmails$" and then I expect the set 
> > > > > > > > -e will
> > > > > > > > work.
> > > > > > > ...or here's an (untested) version with that proposed change.
> > > > > > > (sorry for the spam!)
> > > > > > > +-PID_GETMAILS=$(pgrep -U $UID_BY_ID '^getmails$')
> > > > > > > ++PID_GETMAILS=$(pgrep -U $UID_BY_ID '^/bin/sh 
> > > > > > > /usr/local/bin/getmails$')
> > > > > > Just tested the getmails change: it still exits at the pgrep line. 
> > > > > Try pgrep -f [...]
> > > > Does not work either. 
> > > > The problem is a premature end of the whole script, of pgrep finds
> > > > noting, instead of just filling the variable to empty.
> > > Have a poke around with pgrep while the script is running and see
> > > what's needed to get it to match then; in particular this part of the
> > > diff breaks the whole reason they're using pgrep:
> > > 
> > > +-if [ "x$PID_GETMAILS" != "x$$" ]; then
> > > ++if [ "x${PID_GETMAILS}x" != "xx" ]; then
> > 
> > Today i got my hands on a Debian and a FreeBSD system. 
> > 
> > On Debian getmails is not distributed with the package. If i use
> > getmails from git there, i get the same error.
> > 
> > On FreeBSD getmails is distributed unpatched. It shows the same error
> > (and tries to start getmail from /usr/bin/getmail)
> > 
> > So i see 3 Options for us:
> > 
> > 1. We do not distribute the script in the package
> > 2. We patch getmails in a way like the diff below and install it (This
> >    version i use on my systems)
> > 3. We ship a patched version as example
> or 4. Actually fix it
This was Option 2 for me. (Perhaps my Idea of fixing it was not the
best)
But your solution (Removing the Test altogether) sounds good. It would be 
the safest solution, I think.

Diff for port with skipping concurrent start detection is below.

> I must say I don't really understand going to the trouble of looking at
> several OS rather than just figuring out what's needed to fix.
Reason is, if i find a fix, which works on other systems too, there is
a good chance, i can find someone in upstream, who accepts a solution
for the problem i encountered.

> > I tend to say for the moment not shipping it would be the safest way,
> > until the version in upstream is better.
> > The original getmail had no script for multiple configuration files,
> > so we will get no problems with compatibility.
> > 
> > --- /usr/obj/ports/getmail-6.18.10/getmail6-6.18.10/getmails        Sun Sep 
> > 18 19:56:20 2022
> > +++ /usr/local/bin/getmails Fri Dec  9 08:15:44 2022
> > @@ -28,8 +28,8 @@ BASE1=${1##*/}
> >  [ "$BASE1" != "${BASE1#$2}" ] && return 0 || return 1
> >  }
> >  UID_BY_ID=$(id -u)
> > -PID_GETMAILS=$(pgrep -U $UID_BY_ID '^getmails$')
> > -if [ "x$PID_GETMAILS" != "x$$" ]; then
> > +PID_GETMAILS=$(pgrep -fU $UID_BY_ID '/usr/local/bin/getmails'  | sed 
> > "s/$$//" | tr -d '\n' )
> > +if [ "x${PID_GETMAILS}x" != "xx" ]; then
> >     echo "The getmails script is already running as PID=\"$PID_GETMAILS\" 
> > ." >&2
> 
> This patched test is completely broken. It would be better to
> remove the "are we already running" check completely than patch it
> in a way that might at first glance look like a fix, but really
> isn't. Think about what it's doing. pgrep should *always* return
> at least one running instance here (the one which is currently
> running), or more than one if another instance is running.
> Then the 'if [ "x$PID_GETMAILS" != "x$$" ]' is checking whether the
> string returned from pgrep is equal to the script's current pid.
> If so, it's ok. If not (because it is "<current pid> <other pid>"
> then it reports the duplicate.
It works (on my systems). Reason is: the sed in the pipe removes the running
pid.  ($$ is our pid) The main problem (premature end of the script) is 
solved, because there is a pipe, which means the "set -e" only terminates, if
the last command in pipe has a exit code.
This version would also only report the "offending" pid, while the
original version would also report our own pid als already running if
there was another instance.

But removing the check is perhaps the better solution, as there is less
chance of failure. (And no code can not fail under circumstances,
which I had not thought about)

> >     exit 1
> >  fi
> > @@ -44,7 +44,7 @@ if [ -f $getmailrcdir/stop ]; then
> >     echo "Do not run getmail ... (if not, remove $getmailrcdir/stop)" >&2
> >     exit 1
> >  fi
> > -rcfiles="/usr/bin/getmail"
> > +rcfiles="/usr/local/bin/getmail"
> >  # Address concerns raised by #863856
> >  #  emacs backup files:   foo~ foo#
> >  #  vim backup files:     foo~ foo.swp
> > @@ -57,7 +57,8 @@ if $para ; then
> >             ! endwith "$file" '#' && \
> >             ! startswith "$file" 'oldmail-' && \
> >             ! endwith "$file" '.swp' && \
> > -           ! endwith "$file" '.bak' ; then
> > +           ! endwith "$file" '.bak' && \
> > +           [ -f "$file" ]; then
> >         $rcfiles --rcfile "$file" "$@" &
> >         pids="$pids $!"
> >          fi
> > @@ -79,7 +80,8 @@ else
> >             ! endwith "$file" '#' && \
> >             ! startswith "$file" 'oldmail-' && \
> >             ! endwith "$file" '.swp' && \
> > -           ! endwith "$file" '.bak' ; then
> > +           ! endwith "$file" '.bak' && \
> > +           [ -f "$file" ]; then
> >             rcfiles="$rcfiles --rcfile \"$file\""
> >          fi
> >      done


Index: Makefile
===================================================================
RCS file: /cvs/ports/mail/getmail/Makefile,v
retrieving revision 1.102
diff -u -p -r1.102 Makefile
--- Makefile    11 Mar 2022 19:34:37 -0000      1.102
+++ Makefile    9 Dec 2022 13:12:13 -0000
@@ -1,24 +1,22 @@
 COMMENT=       IMAP/POP3/SDPS mail retriever
 
-MODPY_EGG_VERSION=     5.16
-DISTNAME=      getmail-${MODPY_EGG_VERSION}
+MODPY_EGG_VERSION=     6.18.10
+GH_ACCOUNT=    getmail6
+GH_PROJECT=    getmail6
+GH_TAGNAME=    v${MODPY_EGG_VERSION}
+PKGNAME=       getmail-${MODPY_EGG_VERSION}
 CATEGORIES=    mail
 
-HOMEPAGE=      http://pyropus.ca/software/getmail/
+# https://github.com/getmail6/getmail6
+HOMEPAGE=      https://getmail6.org/
 
 MAINTAINER=    Martin Ziemer <hor...@horrad.de>
 
 # GPLv2
 PERMIT_PACKAGE=        Yes
 
-MASTER_SITES=  ${HOMEPAGE}/old-versions/
-
 MODULES=       lang/python
-
-# No Python 3 support as of 5.16
-# https://pyropus.ca/software/getmail/documentation.html#python3
-MODPY_VERSION =        ${MODPY_DEFAULT_VERSION_2}
-
+MODPY_PYBUILD= setuptools
 NO_TEST=       Yes
 
 EXDIR=         ${PREFIX}/share/examples/getmail
Index: distinfo
===================================================================
RCS file: /cvs/ports/mail/getmail/distinfo,v
retrieving revision 1.81
diff -u -p -r1.81 distinfo
--- distinfo    24 Nov 2021 09:06:39 -0000      1.81
+++ distinfo    9 Dec 2022 13:12:13 -0000
@@ -1,2 +1,2 @@
-SHA256 (getmail-5.16.tar.gz) = auj46u+avEZQUMO2TlWjGvvc1Mbt8xl7W1m71WymZ/o=
-SIZE (getmail-5.16.tar.gz) = 180577
+SHA256 (getmail6-6.18.10.tar.gz) = DlYXz6LMh8WyWWNPWfVyjfOyVoqSyqVkdn4lb3mGatY=
+SIZE (getmail6-6.18.10.tar.gz) = 205481
Index: patches/patch-getmails
===================================================================
RCS file: patches/patch-getmails
diff -N patches/patch-getmails
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-getmails      9 Dec 2022 13:12:13 -0000
@@ -0,0 +1,47 @@
+# Fix filepaths, only parse files and skip duplicate invocation detection
+
+Index: getmails
+--- getmails.orig
++++ getmails
+@@ -27,12 +27,6 @@ startswith () {
+ BASE1=${1##*/}
+ [ "$BASE1" != "${BASE1#$2}" ] && return 0 || return 1
+ }
+-UID_BY_ID=$(id -u)
+-PID_GETMAILS=$(pgrep -U $UID_BY_ID '^getmails$')
+-if [ "x$PID_GETMAILS" != "x$$" ]; then
+-      echo "The getmails script is already running as PID=\"$PID_GETMAILS\" 
." >&2
+-      exit 1
+-fi
+ configdir=${XDG_CONFIG_HOME:-$HOME/.config}
+ if [ ! -d "$configdir" ]; then
+     getmailrcdir="$HOME/.getmail/config"
+@@ -44,7 +38,7 @@ if [ -f $getmailrcdir/stop ]; then
+       echo "Do not run getmail ... (if not, remove $getmailrcdir/stop)" >&2
+       exit 1
+ fi
+-rcfiles="/usr/bin/getmail"
++rcfiles="/usr/local/bin/getmail"
+ # Address concerns raised by #863856
+ #  emacs backup files:   foo~ foo#
+ #  vim backup files:     foo~ foo.swp
+@@ -57,7 +51,8 @@ if $para ; then
+            ! endwith "$file" '#' && \
+            ! startswith "$file" 'oldmail-' && \
+            ! endwith "$file" '.swp' && \
+-           ! endwith "$file" '.bak' ; then
++           ! endwith "$file" '.bak' && \
++           [ -f "$file" ]; then
+           $rcfiles --rcfile "$file" "$@" &
+           pids="$pids $!"
+         fi
+@@ -79,7 +74,8 @@ else
+            ! endwith "$file" '#' && \
+            ! startswith "$file" 'oldmail-' && \
+            ! endwith "$file" '.swp' && \
+-           ! endwith "$file" '.bak' ; then
++           ! endwith "$file" '.bak' && \
++           [ -f "$file" ]; then
+       rcfiles="$rcfiles --rcfile \"$file\""
+         fi
+     done
Index: patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/mail/getmail/patches/patch-setup_py,v
retrieving revision 1.5
diff -u -p -r1.5 patch-setup_py
--- patches/patch-setup_py      11 Mar 2022 19:34:37 -0000      1.5
+++ patches/patch-setup_py      9 Dec 2022 13:12:13 -0000
@@ -1,25 +1,16 @@
 Index: setup.py
 --- setup.py.orig
 +++ setup.py
-@@ -39,12 +39,11 @@ GETMAILDOCDIR = os.path.join(
-     datadir or prefix,
-     'share',
-     'doc',
--    'getmail-%s' % __version__
-+    'getmail'
- )
+@@ -36,10 +36,10 @@ for (pos, arg) in enumerate(args):
+         # hack hack hack hack hack hack hack
+         datadir = args[pos + 1]
  
- GETMAILMANDIR = os.path.join(
-     datadir or prefix,
--    'share',
-     'man',
-     'man1'
- )
-@@ -101,7 +100,6 @@ setup(
-     data_files=[
-         (GETMAILDOCDIR, [
-             './README',
--            './getmail.spec',
-             'docs/BUGS',
-             'docs/COPYING',
-             'docs/CHANGELOG',
+-DOCDIR = os.path.join('share','doc','getmail-%s' % __version__)
++DOCDIR = os.path.join('share','doc','getmail')
+ GETMAILDOCDIR = os.path.join(datadir or prefix, DOCDIR)
+ 
+-MANDIR = os.path.join('share','man','man1')
++MANDIR = os.path.join('man','man1')
+ GETMAILMANDIR = os.path.join( datadir or prefix, MANDIR)
+ 
+ if '--show-default-install-dirs' in args:
Index: pkg/PLIST
===================================================================
RCS file: /cvs/ports/mail/getmail/pkg/PLIST,v
retrieving revision 1.16
diff -u -p -r1.16 PLIST
--- pkg/PLIST   11 Mar 2022 19:34:37 -0000      1.16
+++ pkg/PLIST   9 Dec 2022 13:12:13 -0000
@@ -3,47 +3,61 @@ bin/getmail-gmail-xoauth-tokens
 bin/getmail_fetch
 bin/getmail_maildir
 bin/getmail_mbox
-lib/python${MODPY_VERSION}/site-packages/getmail-${MODPY_EGG_VERSION}-py${MODPY_VERSION}.egg-info
+bin/getmails
+lib/python${MODPY_VERSION}/site-packages/getmail6-${MODPY_EGG_VERSION}.dist-info/
+lib/python${MODPY_VERSION}/site-packages/getmail6-${MODPY_EGG_VERSION}.dist-info/METADATA
+lib/python${MODPY_VERSION}/site-packages/getmail6-${MODPY_EGG_VERSION}.dist-info/RECORD
+lib/python${MODPY_VERSION}/site-packages/getmail6-${MODPY_EGG_VERSION}.dist-info/WHEEL
+lib/python${MODPY_VERSION}/site-packages/getmail6-${MODPY_EGG_VERSION}.dist-info/top_level.txt
 lib/python${MODPY_VERSION}/site-packages/getmailcore/
 lib/python${MODPY_VERSION}/site-packages/getmailcore/__init__.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/__init__.pyc
-lib/python${MODPY_VERSION}/site-packages/getmailcore/_pop3ssl.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/_pop3ssl.pyc
+${MODPY_COMMENT}lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}/
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}__init__.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}_retrieverbases.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}_retrieverbases.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}baseclasses.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}baseclasses.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}constants.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}constants.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}destinations.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}destinations.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}exceptions.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}exceptions.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}filters.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}filters.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}imap_utf7.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}imap_utf7.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}logging.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}logging.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}message.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}message.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}retrievers.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}retrievers.${MODPY_PYC_MAGIC_TAG}pyc
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}utilities.${MODPY_PYC_MAGIC_TAG}${MODPY_PYOEXTENSION}
+lib/python${MODPY_VERSION}/site-packages/getmailcore/${MODPY_PYCACHE}utilities.${MODPY_PYC_MAGIC_TAG}pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/_retrieverbases.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/_retrieverbases.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/baseclasses.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/baseclasses.pyc
-lib/python${MODPY_VERSION}/site-packages/getmailcore/compatibility.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/compatibility.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/constants.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/constants.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/destinations.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/destinations.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/exceptions.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/exceptions.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/filters.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/filters.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/imap_utf7.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/imap_utf7.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/logging.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/logging.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/message.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/message.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/retrievers.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/retrievers.pyc
 lib/python${MODPY_VERSION}/site-packages/getmailcore/utilities.py
-lib/python${MODPY_VERSION}/site-packages/getmailcore/utilities.pyc
 @man man/man1/getmail.1
 @man man/man1/getmail_fetch.1
 @man man/man1/getmail_maildir.1
 @man man/man1/getmail_mbox.1
+@man man/man1/getmails.1
 share/doc/getmail/
 share/doc/getmail/BUGS
 share/doc/getmail/CHANGELOG
 share/doc/getmail/COPYING
 share/doc/getmail/README
 share/doc/getmail/THANKS
-share/doc/getmail/TODO
 share/doc/getmail/configuration.html
 share/doc/getmail/configuration.txt
 share/doc/getmail/documentation.html

Reply via email to