git: 9dc8d74ac07b - main - mail/offlineimap3: Two-way synchronization of local Maildir and IMAP folders (new port)

From: Kurt Jaeger <pi_at_FreeBSD.org>
Date: Tue, 27 Dec 2022 15:26:00 UTC
The branch main has been updated by pi:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9dc8d74ac07b580cb1e57194956f0f23a03d4555

commit 9dc8d74ac07b580cb1e57194956f0f23a03d4555
Author:     Derek Schrock <dereks@lifeofadishwasher.com>
AuthorDate: 2022-12-27 15:22:20 +0000
Commit:     Kurt Jaeger <pi@FreeBSD.org>
CommitDate: 2022-12-27 15:22:20 +0000

    mail/offlineimap3: Two-way synchronization of local Maildir and IMAP folders (new port)
    
    OfflineIMAP is software that downloads your email mailbox(es) as
    local Maildirs. OfflineIMAP will synchronize both sides via IMAP.
    
    PR:                     262233
    Author:                 Derek Schrock <dereks@lifeofadishwasher.com>
    Reviewed by:            koobs
    Differential Revision:  https://reviews.freebsd.org/D34388
---
 mail/Makefile                                      |  1 +
 mail/py-offlineimap3/Makefile                      | 90 ++++++++++++++++++++++
 mail/py-offlineimap3/distinfo                      |  3 +
 .../files/patch-offlineimap_imapserver.py          | 11 +++
 .../files/patch-test_tests_test__01__basic.py      | 59 ++++++++++++++
 mail/py-offlineimap3/pkg-descr                     |  2 +
 6 files changed, 166 insertions(+)

diff --git a/mail/Makefile b/mail/Makefile
index 48cc9bcbfe1a..967ae6987d77 100644
--- a/mail/Makefile
+++ b/mail/Makefile
@@ -514,6 +514,7 @@
     SUBDIR += py-milter
     SUBDIR += py-notmuch
     SUBDIR += py-notmuch2
+    SUBDIR += py-offlineimap3
     SUBDIR += py-postfix-mta-sts-resolver
     SUBDIR += py-premailer
     SUBDIR += py-pymailq
diff --git a/mail/py-offlineimap3/Makefile b/mail/py-offlineimap3/Makefile
new file mode 100644
index 000000000000..ad6d8f495172
--- /dev/null
+++ b/mail/py-offlineimap3/Makefile
@@ -0,0 +1,90 @@
+PORTNAME=	offlineimap3
+DISTVERSIONPREFIX=	v
+DISTVERSION=	8.0.0-18
+DISTVERSIONSUFFIX=	-g${GH_TAGNAME}
+CATEGORIES=	mail python
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+MAINTAINER=	dereks@lifeofadishwasher.com
+COMMENT=	Two-way synchronization of local Maildir and IMAP folders
+WWW=		https://github.com/OfflineIMAP/offlineimap3
+
+LICENSE=	GPLv2
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+# setup.py requires these during build time. Possible move to setup/install_requires:
+# https://github.com/OfflineIMAP/offlineimap3/issues/110
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}distro>=0:sysutils/py-distro@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}imaplib2>=3.5:mail/py-imaplib2@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}rfc6555>=0:mail/py-rfc6555@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}certifi>=2020.6.20:security/py-certifi@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}distro>=0:sysutils/py-distro@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}imaplib2>=3.5:mail/py-imaplib2@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}rfc6555>=0:mail/py-rfc6555@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}urllib3>=1.25.9:net/py-urllib3@${PY_FLAVOR}
+
+# Upstream doesn't have exact version currently only able to test up to 3.9 since
+# imaplib2 is 3.6-3.9.
+USES=		pytest python:3.7-3.9
+
+# Project is currently not publishing to pypi sdist.  pypi/naming status:
+# https://github.com/OfflineIMAP/offlineimap3/issues/111
+USE_GITHUB=	yes
+GH_ACCOUNT=	OfflineIMAP
+GH_TAGNAME=	253f97a3e947
+
+USE_PYTHON=	autoplist concurrent distutils
+
+CONFLICTS_INSTALL=	mail/py-offlineimap
+
+NO_ARCH=	yes
+
+PORTDOCS=	*
+PORTEXAMPLES=	offlineimap.conf
+
+OPTIONS_DEFINE=		DOCS EXAMPLES GSSAPI MANPAGES
+OPTIONS_DEFAULT=	MANPAGES
+
+COMMON_BUILD_DEPENDS=	a2x:textproc/asciidoc \
+			gmake:devel/gmake
+
+DOCS_BUILD_DEPENDS=	${COMMON_BUILD_DEPENDS} \
+			${PYTHON_PKGNAMEPREFIX}sphinx>=0:textproc/py-sphinx@${PY_FLAVOR}
+
+GSSAPI_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}gssapi>=1.6.9:security/py-gssapi@${PY_FLAVOR}
+
+MANPAGES_BUILD_DEPENDS=	${COMMON_BUILD_DEPENDS}
+MANPAGES_PLIST_FILES+=	man/man1/offlineimap.1.gz \
+			man/man7/offlineimapui.7.gz
+
+# In concurrent env. sphinx-build is only exist for py38 add "-${PYTHON_VER}" to command
+post-patch:
+	cd ${WRKSRC} && \
+	${REINPLACE_CMD} '/^SPHINXBUILD = sphinx-build$$/s/$$/-${PYTHON_VER}/' \
+		docs/Makefile
+
+post-build-DOCS-on:
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+	cd ${WRKSRC}/docs && ${GMAKE} docs && \
+	cd html && \
+	${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR} \
+		'! ( -name .lock -or -name .buildinfo )'
+
+post-build-MANPAGES-on:
+	${MKDIR} ${STAGEDIR}${MAN7PREFIX}/man/man7/
+	${MKDIR} ${STAGEDIR}${MAN7PREFIX}/man/man1/
+	cd ${WRKSRC}/docs && ${GMAKE} man && \
+	${INSTALL_MAN} offlineimapui.7 ${STAGEDIR}${MAN7PREFIX}/man/man7/ && \
+	${INSTALL_MAN} offlineimap.1 ${STAGEDIR}${MAN1PREFIX}/man/man1/
+
+post-install-EXAMPLES-on:
+	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
+	${INSTALL_DATA} ${WRKSRC}/offlineimap.conf ${STAGEDIR}${EXAMPLESDIR}
+
+pre-test:
+	cd ${WRKSRC} && \
+	${CP} test/credentials.conf.sample test/credentials.conf
+
+.include <bsd.port.mk>
diff --git a/mail/py-offlineimap3/distinfo b/mail/py-offlineimap3/distinfo
new file mode 100644
index 000000000000..fe44869552b3
--- /dev/null
+++ b/mail/py-offlineimap3/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1671226862
+SHA256 (OfflineIMAP-offlineimap3-v8.0.0-18-g253f97a3e947-253f97a3e947_GH0.tar.gz) = c1bcc5e18df029bf377dafbef38aeb651455238b60279e45aad2c81d2b95da0f
+SIZE (OfflineIMAP-offlineimap3-v8.0.0-18-g253f97a3e947-253f97a3e947_GH0.tar.gz) = 703329
diff --git a/mail/py-offlineimap3/files/patch-offlineimap_imapserver.py b/mail/py-offlineimap3/files/patch-offlineimap_imapserver.py
new file mode 100644
index 000000000000..9655d920c7f8
--- /dev/null
+++ b/mail/py-offlineimap3/files/patch-offlineimap_imapserver.py
@@ -0,0 +1,11 @@
+--- offlineimap/imapserver.py.orig	2022-02-27 05:55:01 UTC
++++ offlineimap/imapserver.py
+@@ -879,7 +879,7 @@ class IdleThread:
+             while not success:
+                 imapobj = self.parent.acquireconnection()
+                 try:
+-                    imapobj.select(self.folder)
++                    imapobj.select(imaputil.foldername_to_imapname(self.folder))
+                 except OfflineImapError as e:
+                     if e.severity == OfflineImapError.ERROR.FOLDER_RETRY:
+                         # Connection closed, release connection and retry.
diff --git a/mail/py-offlineimap3/files/patch-test_tests_test__01__basic.py b/mail/py-offlineimap3/files/patch-test_tests_test__01__basic.py
new file mode 100644
index 000000000000..615492c8fe8d
--- /dev/null
+++ b/mail/py-offlineimap3/files/patch-test_tests_test__01__basic.py
@@ -0,0 +1,59 @@
+--- test/tests/test_01_basic.py.orig	2022-03-04 03:43:46 UTC
++++ test/tests/test_01_basic.py
+@@ -17,6 +17,8 @@ import unittest
+ import logging
+ from test.OLItest import OLITestLib
+ 
++import pytest
++
+ # Things need to be setup first, usually setup.py initializes everything.
+ # but if e.g. called from command line, we take care of default values here:
+ if not OLITestLib.cred_file:
+@@ -47,6 +49,7 @@ class TestBasicFunctions(unittest.TestCase):
+     def tearDown(self):
+         OLITestLib.delete_remote_testfolders()
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_01_olistartup(self):
+         """Tests if OLI can be invoked without exceptions
+ 
+@@ -60,6 +63,7 @@ class TestBasicFunctions(unittest.TestCase):
+                             "mails, but sync led to {0} folders and {1} mails"
+                         .format(boxes, mails))
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_02_createdir(self):
+         """Create local 'OLItest 1', sync"""
+         OLITestLib.delete_maildir('')  # Delete all local maildir folders
+@@ -71,6 +75,7 @@ class TestBasicFunctions(unittest.TestCase):
+                             "mails, but sync led to {0} folders and {1} mails"
+                         .format(boxes, mails))
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_03_createdir_quote(self):
+         """Create local 'OLItest "1"' maildir, sync
+ 
+@@ -87,6 +92,7 @@ class TestBasicFunctions(unittest.TestCase):
+                             "mails, but sync led to {0} folders and {1} mails"
+                         .format(boxes, mails))
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_04_nametransmismatch(self):
+         """Create mismatching remote and local nametrans rules
+ 
+@@ -108,6 +114,7 @@ class TestBasicFunctions(unittest.TestCase):
+         # Write out default config file again
+         OLITestLib.write_config_file()
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_05_createmail(self):
+         """Create mail in OLItest 1, sync, wipe folder sync
+ 
+@@ -133,6 +140,7 @@ class TestBasicFunctions(unittest.TestCase):
+                              "assigned the IMAP's UID number, but {0} messages had no valid ID "
+                          .format(len([None for x in uids if x is None])))
+ 
++    @pytest.mark.skip(reason="skpping test needs remote auth")
+     def test_06_createfolders(self):
+         """Test if createfolders works as expected
+ 
diff --git a/mail/py-offlineimap3/pkg-descr b/mail/py-offlineimap3/pkg-descr
new file mode 100644
index 000000000000..17b73c0fa280
--- /dev/null
+++ b/mail/py-offlineimap3/pkg-descr
@@ -0,0 +1,2 @@
+OfflineIMAP is software that downloads your email mailbox(es) as
+local Maildirs. OfflineIMAP will synchronize both sides via IMAP.