[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20230209-49-g23cbaac

Jon Turney jturney@sourceware.org
Thu Nov 23 14:10:51 GMT 2023




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=23cbaac193afe222962fe12b8a5710973678b363

commit 23cbaac193afe222962fe12b8a5710973678b363
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Nov 22 14:07:40 2023 +0000

    Store first msgid for announce of a srcpackage
    
    Store the first msgid allocated for a srcpackage announce, so we can set
    in-reply-to and thus allow threading of subsequent announces for that
    package.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=24046373b914f5038e23b6821080bd3af8d810f9

commit 24046373b914f5038e23b6821080bd3af8d810f9
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Nov 22 13:45:21 2023 +0000

    Omit empty provides_rebuild reports from list of report


Diff:
---
 calm/calm.py    | 12 ++++++++----
 calm/db.py      | 23 +++++++++++++++++++++++
 calm/reports.py |  7 ++++---
 calm/utils.py   |  2 ++
 4 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/calm/calm.py b/calm/calm.py
index 66337ab..e092468 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -284,9 +284,6 @@ def _announce_upload(args, scan_result, maintainer, r):
     # TODO: maybe other mechanisms for getting package ChangeLog?
     # NEWS inside upstream source tarball?
 
-    # TODO: store initial msgid for a package, so we can do in-reply-to and thus
-    # allow threading of announces for that package
-
     # build the email
     hdr = {}
     hdr['From'] = maintainer.name + ' <cygwin-no-reply@cygwin.com>'
@@ -299,6 +296,10 @@ def _announce_upload(args, scan_result, maintainer, r):
     hdr['Subject'] = srcpkg.orig_name + ' ' + version + (' (TEST)' if test else '')
     hdr['X-Calm-Announce'] = '1'
 
+    irtid = db.announce_msgid_get(args, srcpkg.orig_name)
+    if irtid:
+        hdr['In-Reply-To'] = irtid
+
     msg = '''
 The following packages have been uploaded to the Cygwin distribution:
 
@@ -311,7 +312,10 @@ The following packages have been uploaded to the Cygwin distribution:
 
     # TODO: add an attachment: sha512 hashes of packages, gpg signed?
 
-    utils.sendmail(hdr, msg)
+    msgid = utils.sendmail(hdr, msg)
+
+    if not irtid:
+        db.announce_msgid_set(args, srcpkg.orig_name, msgid)
 
 
 def _process_maintainer_uploads(scan_result, args, state, all_packages, m, basedir, desc):
diff --git a/calm/db.py b/calm/db.py
index 0aef83a..3c2f761 100644
--- a/calm/db.py
+++ b/calm/db.py
@@ -55,6 +55,11 @@ def connect(args):
                      replaces TEXT NOT NULL,
                      PRIMARY KEY (name, arch)
                     )''')
+    conn.execute('''CREATE TABLE IF NOT EXISTS announce_msgid
+                    (srcpackage TEXT NOT NULL PRIMARY KEY,
+                     msgid TEXT NOT NULL
+                    )''')
+
     conn.commit()
 
     return conn
@@ -138,3 +143,21 @@ def update_missing_obsolete(args, packages, arch):
                 conn.execute('UPDATE missing_obsolete SET replaces = ? WHERE name = ? AND arch = ?', (' '.join(r), n, arch))
 
     return missing_obsolete
+
+
+def announce_msgid_get(args, srcpackage):
+    msgid = None
+    with connect(args) as conn:
+        conn.row_factory = sqlite3.Row
+
+        cur = conn.execute("SELECT msgid FROM announce_msgid WHERE srcpackage = ?", (srcpackage,))
+        row = cur.fetchone()
+        if row:
+            msgid = row['msgid']
+
+    return msgid
+
+
+def announce_msgid_set(args, srcpackage, msgid):
+    with connect(args) as conn:
+        conn.execute('INSERT INTO announce_msgid (srcpackage, msgid) VALUES (?, ?)', (srcpackage, msgid))
diff --git a/calm/reports.py b/calm/reports.py
index b101ef4..6fa570e 100644
--- a/calm/reports.py
+++ b/calm/reports.py
@@ -57,8 +57,9 @@ def template(title, body, f):
     </html>'''), file=f)
 
 
-def write_report(args, title, body, fn, reportlist):
-    reportlist[title] = os.path.join('reports', fn)
+def write_report(args, title, body, fn, reportlist, not_empty=True):
+    if not_empty:
+        reportlist[title] = os.path.join('reports', fn)
 
     fn = os.path.join(args.htdocs, 'reports', fn)
 
@@ -251,7 +252,7 @@ def provides_rebuild(args, packages, fn, provide_package, reportlist):
 
     print('</table>', file=body)
 
-    write_report(args, 'Packages needing rebuilds for latest %s' % provide_package, body, fn, reportlist)
+    write_report(args, 'Packages needing rebuilds for latest %s' % provide_package, body, fn, reportlist, bool(pr_list))
 
 
 #
diff --git a/calm/utils.py b/calm/utils.py
index 47085fd..26e3655 100644
--- a/calm/utils.py
+++ b/calm/utils.py
@@ -196,3 +196,5 @@ def sendmail(hdr, msg):
         with subprocess.Popen(['/usr/sbin/sendmail', '-t', '-oi', '-f', hdr['From']], stdin=subprocess.PIPE) as p:
             p.communicate(m.as_bytes())
             logging.debug('sendmail: msgid %s, exit status %d' % (m['Message-Id'], p.returncode))
+
+    return m['Message-Id']



More information about the Cygwin-apps-cvs mailing list