Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/cygwin-apps/calm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2022-06-20 18:52:08 +0300
committerJon Turney <jon.turney@dronecode.org.uk>2023-10-15 16:03:47 +0300
commit17dc61e9f95c74366465d0a56121cef84b88d415 (patch)
treea47e476074c9353500c6e54b4b6bf95e207c07f0
parent72608dc7f48988a3509538d0a01411c2586a513f (diff)
Persist missing_obsolete
Persist the missing obsolete: data generated from old-style obsoletion packages, so it is remembered, even if after the obsoleted package is removed.
-rwxr-xr-xcalm/calm.py2
-rw-r--r--calm/db.py34
-rwxr-xr-xcalm/package.py3
3 files changed, 36 insertions, 3 deletions
diff --git a/calm/calm.py b/calm/calm.py
index 22b0a7a..73b0e05 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -111,7 +111,7 @@ def process_relarea(args, state):
state.valid_provides = db.update_package_names(args, packages)
for arch in common_constants.ARCHES:
- state.missing_obsolete[arch] = package.upgrade_oldstyle_obsoletes(packages[arch])
+ state.missing_obsolete[arch] = db.update_missing_obsolete(args, packages, arch)
# validate the package set for each arch
for arch in common_constants.ARCHES:
diff --git a/calm/db.py b/calm/db.py
index b7f7040..0aef83a 100644
--- a/calm/db.py
+++ b/calm/db.py
@@ -30,6 +30,7 @@ import logging
import os
import sqlite3
+from . import package
from . import utils
@@ -48,6 +49,12 @@ def connect(args):
vr TEXT NOT NULL
)''')
+ conn.execute('''CREATE TABLE IF NOT EXISTS missing_obsolete
+ (name TEXT NOT NULL,
+ arch TEXT NOT NULL,
+ replaces TEXT NOT NULL,
+ PRIMARY KEY (name, arch)
+ )''')
conn.commit()
return conn
@@ -104,3 +111,30 @@ def vault_requests(args):
def vault_request_add(args, p, v):
with connect(args) as conn:
conn.execute('INSERT INTO vault_requests (srcpackage, vr) VALUES (?,?)', (p, v))
+
+
+#
+# this accumulates missing_obsoletes data for packages, so we will remember it
+# even after the obsoleted package has been removed
+#
+def update_missing_obsolete(args, packages, arch):
+ data = {}
+ with connect(args) as conn:
+ conn.row_factory = sqlite3.Row
+
+ # read
+ cur = conn.execute("SELECT name, replaces FROM missing_obsolete WHERE arch = ?", (arch,))
+ for row in cur.fetchall():
+ data[row['name']] = set(row['replaces'].split())
+
+ # update missing obsoletes data
+ missing_obsolete = package.upgrade_oldstyle_obsoletes(packages[arch], data.copy())
+
+ # update
+ for n, r in missing_obsolete.items():
+ if n not in data:
+ conn.execute('INSERT INTO missing_obsolete (name, arch, replaces) VALUES (?, ? , ?)', (n, arch, ' '.join(r)))
+ else:
+ conn.execute('UPDATE missing_obsolete SET replaces = ? WHERE name = ? AND arch = ?', (' '.join(r), n, arch))
+
+ return missing_obsolete
diff --git a/calm/package.py b/calm/package.py
index 238b76d..9f50d6f 100755
--- a/calm/package.py
+++ b/calm/package.py
@@ -587,8 +587,7 @@ def sort_key(k):
OBSOLETE_CONVERT_THRESHOLD_YEARS = 20
-def upgrade_oldstyle_obsoletes(packages):
- missing_obsolete = {}
+def upgrade_oldstyle_obsoletes(packages, missing_obsolete):
certain_age = time.time() - (OBSOLETE_CONVERT_THRESHOLD_YEARS * 365.25 * 24 * 60 * 60)
logging.debug("cut-off date for _obsolete package to be considered for conversion is %s" % (time.strftime("%F %T %Z", time.localtime(certain_age))))