]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
only add packages which dont exist yet
authorHolger Levsen <holger@layer-acht.org>
Fri, 28 Sep 2012 17:54:11 +0000 (19:54 +0200)
committerHolger Levsen <holger@layer-acht.org>
Fri, 28 Sep 2012 17:54:11 +0000 (19:54 +0200)
db_add.py
debian_packages2db.py

index 0b44674be4fab148d62026500960ced2999fe866..927bb751cce32d4d553f960e3dac485c32e0443e 100755 (executable)
--- a/db_add.py
+++ b/db_add.py
@@ -129,3 +129,14 @@ def add_package_version(origin, package, version):
     con.commit()
     return db_package_instance_id
 
+def get_package_instance(origin, package, version):
+    con = db_connect()
+    try:
+        cur.execute("SELECT id FROM deb_package_instance"
+                " JOIN deb_package ON (deb_package.id = deb_package_instance.deb_package_id)"
+                " JOIN deb_package_origin ON (deb_package_origin.id = deb_package_instance.deb_package_origin_id)"
+                " WHERE origin = '%s' AND package = '%s' AND version = '%s'" % (origin, package, version))
+    except:
+        return -1
+    return cur.fetchone()[0]
+
index 0a12d123a2dce2e42b422780b1cb7ba64d0d2b3a..7d132967c620ce9c3dc3339f4c0aae6c15b0f5bf 100755 (executable)
@@ -47,7 +47,8 @@ if __name__ == '__main__':
         pkg_name = pkg_name.strip().split()[1]
         version = tmp.readline()
         version = version.strip().split()[1]
-        print 'adding %s %s from %s' % (pkg_name,version,origin)
-        add_package_version(origin, pkg_name, version)
+        if not get_package_version(origin, pkg_name, version):
+           print 'adding %s %s from %s' % (pkg_name,version,origin)
+           add_package_version(origin, pkg_name, version)
 
     os.remove(tmp.name)