summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/pgp_import.py42
-rw-r--r--devel/management/commands/rematch_developers.py4
-rw-r--r--devel/management/commands/reporead.py17
-rw-r--r--devel/management/commands/reporead_inotify.py2
4 files changed, 38 insertions, 27 deletions
diff --git a/devel/management/commands/pgp_import.py b/devel/management/commands/pgp_import.py
index b1f29d77..3f557fe9 100644
--- a/devel/management/commands/pgp_import.py
+++ b/devel/management/commands/pgp_import.py
@@ -134,7 +134,7 @@ def import_keys(keyring):
logger.info("creating or finding %d keys", len(keydata))
created_ct = updated_ct = 0
- with transaction.commit_on_success():
+ with transaction.atomic():
finder = UserFinder()
# we are dependent on parents coming before children; parse_keydata
# uses an OrderedDict to ensure this is the case.
@@ -176,8 +176,13 @@ def import_keys(keyring):
logger.info("created %d, updated %d keys", created_ct, updated_ct)
-SignatureData = namedtuple('SignatureData',
- ('signer', 'signee', 'created', 'expires', 'valid'))
+class SignatureData(object):
+ def __init__(self, signer, signee, created):
+ self.signer = signer
+ self.signee = signee
+ self.created = created
+ self.expires = None
+ self.revoked = None
def parse_sigdata(data):
@@ -192,21 +197,26 @@ def parse_sigdata(data):
if parts[0] == 'pub':
current_pubkey = parts[4]
nodes[current_pubkey] = None
- if parts[0] == 'uid':
+ elif parts[0] == 'uid':
uid = parts[9]
# only set uid if this is the first one encountered
if nodes[current_pubkey] is None:
nodes[current_pubkey] = uid
- if parts[0] == 'sig':
+ elif parts[0] == 'sig':
signer = parts[4]
created = get_date(parts[5])
- expires = None
+ edge = SignatureData(signer, current_pubkey, created)
if parts[6]:
- expires = get_date(parts[6])
- valid = parts[1] != '-'
- edge = SignatureData(signer, current_pubkey,
- created, expires, valid)
+ edge.expires = get_date(parts[6])
edges.append(edge)
+ elif parts[0] == 'rev':
+ signer = parts[4]
+ revoked = get_date(parts[5])
+ # revoke any prior edges that match
+ matches = [e for e in edges if e.signer == signer
+ and e.signee == current_pubkey]
+ for edge in matches:
+ edge.revoked = revoked
return nodes, edges
@@ -220,18 +230,18 @@ def import_signatures(keyring):
pruned_edges = {edge for edge in edges
if edge.signer in nodes and edge.signer != edge.signee}
- logger.info("creating or finding %d signatures", len(pruned_edges))
+ logger.info("creating or finding up to %d signatures", len(pruned_edges))
created_ct = updated_ct = 0
- with transaction.commit_on_success():
+ with transaction.atomic():
for edge in pruned_edges:
sig, created = PGPSignature.objects.get_or_create(
signer=edge.signer, signee=edge.signee,
created=edge.created, expires=edge.expires,
- defaults={ 'valid': edge.valid })
- if sig.valid != edge.valid:
- sig.valid = edge.valid
+ defaults={ 'revoked': edge.revoked })
+ if sig.revoked != edge.revoked:
+ sig.revoked = edge.revoked
sig.save()
- updated_ct = 1
+ updated_ct += 1
if created:
created_ct += 1
diff --git a/devel/management/commands/rematch_developers.py b/devel/management/commands/rematch_developers.py
index 2b379588..7a06e084 100644
--- a/devel/management/commands/rematch_developers.py
+++ b/devel/management/commands/rematch_developers.py
@@ -44,7 +44,7 @@ class Command(NoArgsCommand):
match_packager(finder)
match_flagrequest(finder)
-@transaction.commit_on_success
+@transaction.atomic
def match_packager(finder):
logger.info("getting all unmatched packager strings")
package_count = matched_count = 0
@@ -70,7 +70,7 @@ def match_packager(finder):
package_count, matched_count)
-@transaction.commit_on_success
+@transaction.atomic
def match_flagrequest(finder):
logger.info("getting all flag request email addresses from unknown users")
req_count = matched_count = 0
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 3e835f7c..8b591aeb 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -13,6 +13,7 @@ Example:
./manage.py reporead i686 /tmp/core.db.tar.gz
"""
+from base64 import b64decode
from collections import defaultdict
from copy import copy
import io
@@ -140,8 +141,8 @@ DEPEND_RE = re.compile(r"^(.+?)((>=|<=|=|>|<)(.+))?$")
def create_depend(package, dep_str, deptype='D'):
depend = Depend(pkg=package, deptype=deptype)
- # lop off any description first
- parts = dep_str.split(':', 1)
+ # lop off any description first, don't get confused by epoch
+ parts = dep_str.split(': ', 1)
if len(parts) > 1:
depend.description = parts[1].strip()
match = DEPEND_RE.match(parts[0].strip())
@@ -222,7 +223,7 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
dbpkg.packager_str = repopkg.packager
# attempt to find the corresponding django user for this string
dbpkg.packager = finder.find(repopkg.packager)
- dbpkg.pgp_signature = repopkg.pgpsig
+ dbpkg.signature_bytes = b64decode(repopkg.pgpsig.encode('utf-8'))
if timestamp:
dbpkg.last_update = timestamp
@@ -307,7 +308,7 @@ def update_common(archname, reponame, pkgs, sanity_check=True):
# If isolation level is repeatable-read, we need to ensure each package
# update starts a new transaction and re-queries the database as
# necessary to guard against simultaneous updates.
- with transaction.commit_on_success():
+ with transaction.atomic():
# force the transaction dirty, even though we will only do reads
transaction.set_dirty()
@@ -370,7 +371,7 @@ def db_update(archname, reponame, pkgs, force=False):
dbpkg = Package(pkgname=pkg.name, arch=architecture, repo=repository,
created=timestamp)
try:
- with transaction.commit_on_success():
+ with transaction.atomic():
populate_pkg(dbpkg, pkg, timestamp=timestamp)
Update.objects.log_update(None, dbpkg)
except IntegrityError:
@@ -385,7 +386,7 @@ def db_update(archname, reponame, pkgs, force=False):
for pkgname in (dbset - syncset):
logger.info("Removing package %s", pkgname)
dbpkg = dbdict[pkgname]
- with transaction.commit_on_success():
+ with transaction.atomic():
Update.objects.log_update(dbpkg, None)
# no race condition here as long as simultaneous threads both
# issue deletes; second delete will be a no-op
@@ -408,7 +409,7 @@ def db_update(archname, reponame, pkgs, force=False):
# The odd select_for_update song and dance here are to ensure
# simultaneous updates don't happen on a package, causing
# files/depends/all related items to be double-imported.
- with transaction.commit_on_success():
+ with transaction.atomic():
dbpkg = Package.objects.select_for_update().get(id=dbpkg.id)
if not force and pkg_same_version(pkg, dbpkg):
logger.debug("Package %s was already updated", pkg.name)
@@ -436,7 +437,7 @@ def filesonly_update(archname, reponame, pkgs, force=False):
# The odd select_for_update song and dance here are to ensure
# simultaneous updates don't happen on a package, causing
# files to be double-imported.
- with transaction.commit_on_success():
+ with transaction.atomic():
if not dbpkg.files_last_update or not dbpkg.last_update:
pass
elif not force and dbpkg.files_last_update >= dbpkg.last_update:
diff --git a/devel/management/commands/reporead_inotify.py b/devel/management/commands/reporead_inotify.py
index 6aa4e0e0..e3c720bc 100644
--- a/devel/management/commands/reporead_inotify.py
+++ b/devel/management/commands/reporead_inotify.py
@@ -66,7 +66,7 @@ class Command(BaseCommand):
if hasattr(thread, 'cancel'):
thread.cancel()
- @transaction.commit_on_success
+ @transaction.atomic
def setup_notifier(self):
'''Set up and configure the inotify machinery and logic.
This takes the provided or default path_template and builds a list of