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]
+
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)