From: Holger Levsen Date: Fri, 28 Sep 2012 17:54:11 +0000 (+0200) Subject: only add packages which dont exist yet X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=17fe24fac46520ec0b35ce49850c693a594ebdd6;p=profitbricks%2Fjenkins-build-scripts.git only add packages which dont exist yet --- diff --git a/db_add.py b/db_add.py index 0b44674..927bb75 100755 --- 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] + diff --git a/debian_packages2db.py b/debian_packages2db.py index 0a12d12..7d13296 100755 --- a/debian_packages2db.py +++ b/debian_packages2db.py @@ -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)