summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValerie R Young <spectranaut@riseup.net>2016-10-24 16:15:22 -0400
committerHolger Levsen <holger@layer-acht.org>2016-10-25 00:18:39 +0200
commitdf98a2d7da2a0690e479c5ef44b31e77dec971a7 (patch)
tree6315fb05f5f236d35597276281c70878d3ee1c2a
parentef373331a692ac8d0d81cd65b68b396504097aaa (diff)
downloadjenkins.debian.net-df98a2d7da2a0690e479c5ef44b31e77dec971a7.tar.xz
reproducible debian: handle new packages with multiple versions
This commit fixes a bug introduced by 07849060 Commit 07849060 changed the UPSERT that added new packages to the sources table into an INSERT. If the new package has two versions for (suite, arch) in debian archive, then the INSERT to sources will fail on unique constraint. The changes in this commit provide the same functionality without the UPSERT: there will be no failure, instead only the second source encountered in archive will be saved. Signed-off-by: Holger Levsen <holger@layer-acht.org>
-rwxr-xr-xbin/reproducible_scheduler.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/reproducible_scheduler.py b/bin/reproducible_scheduler.py
index c69e2909..b279e021 100755
--- a/bin/reproducible_scheduler.py
+++ b/bin/reproducible_scheduler.py
@@ -221,10 +221,21 @@ def update_sources(suite):
def update_sources_db(suite, arch, sources):
# extract relevant info (package name and version) from the sources file
- new_pkgs = []
+ new_pkgs = set()
+ newest_version = {}
for src in deb822.Sources.iter_paragraphs(sources.split('\n')):
pkg = (src['Package'], src['Version'], suite, arch)
- new_pkgs.append(pkg)
+
+ # only keep the most recent version of a src for each package/suite/arch
+ key = src['Package'] + suite + arch
+ if key in newest_version:
+ oldversion = newest_version[key]
+ oldpackage = (src['Package'], oldversion, suite, arch)
+ new_pkgs.remove(oldpackage)
+
+ newest_version[key] = src['Version']
+ new_pkgs.add(pkg)
+
# get the current packages in the database
query = "SELECT name, version, suite, architecture FROM sources " + \
"WHERE suite='{}' AND architecture='{}'".format(suite, arch)