summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2009-08-02 21:38:47 -0500
committerDusty Phillips <buchuki@gmail.com>2009-08-04 09:27:27 -0400
commit64a6af01e8528147364e88a76904e14a3e9ff073 (patch)
treefd5fcb3a2a4f6d3cb9704a8dc31f06156f7cc2e0 /scripts
parente03dd1c195f162b0475e75f30ec6fe7e51f2eea8 (diff)
reporead: unify add and update package code
We had a bit of a disparity between the add and update sections in reporead, causing issues like FS#12400 to only manifest themselves on updated packages rather than brand new ones. Unify the code into a function that does the updating so this doesn't happen again. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Dusty Phillips <buchuki@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/reporead.py65
1 files changed, 29 insertions, 36 deletions
diff --git a/scripts/reporead.py b/scripts/reporead.py
index 7332a918..16dffd58 100755
--- a/scripts/reporead.py
+++ b/scripts/reporead.py
@@ -151,6 +151,30 @@ def dictize(cursor,row):
return result
+def populate_pkg(dbpkg, repopkg):
+ dbpkg.pkgver = repopkg.ver
+ dbpkg.pkgrel = repopkg.rel
+ dbpkg.pkgdesc = repopkg.desc
+ dbpkg.license = repopkg.license
+ dbpkg.url = repopkg.url
+ dbpkg.needupdate = False
+ dbpkg.last_update = now
+ dbpkg.save()
+ # files are not in the repo.db.tar.gz
+ #for x in repopkg.files:
+ # dbpkg.packagefile_set.create(path=x)
+ if 'depends' in repopkg.__dict__:
+ for y in repopkg.depends:
+ # make sure we aren't adding self depends..
+ # yes *sigh* i have seen them in pkgbuilds
+ dpname,dpvcmp = re.match(r"([a-z0-9._+-]+)(.*)", y).groups()
+ if dpname == repopkg.name:
+ logger.warning('Package %s has a depend on itself' % repopkg.name)
+ continue
+ dbpkg.packagedepend_set.create(depname=dpname, depvcmp=dpvcmp)
+ logger.debug('Added %s as dep for pkg %s' % (dpname,repopkg.name))
+
+
def db_update(archname, pkgs):
"""
Parses a list and updates the Arch dev database accordingly.
@@ -201,24 +225,9 @@ def db_update(archname, pkgs):
## maybe later we can add logic to match pkgbuild maintainers
## to db maintainer ids
pkg = Package(
- repo = repository, arch = architecture, maintainer_id = 0,
- needupdate = False, url = p.url, last_update = now,
- pkgname = p.name, pkgver = p.ver, pkgrel = p.rel,
- pkgdesc = p.desc, license = p.license)
- pkg.save()
- # files are not in the repo.db.tar.gz
- #for x in p.files:
- # pkg.packagefile_set.create(path=x)
- if 'depends' in p.__dict__:
- for y in p.depends:
- # make sure we aren't adding self depends..
- # yes *sigh* i have seen them in pkgbuilds
- dpname,dpvcmp = re.match(r"([a-z0-9._+-]+)(.*)", y).groups()
- if dpname == p.name:
- logger.warning('Package %s has a depend on itself' % p.name)
- continue
- pkg.packagedepend_set.create(depname=dpname, depvcmp=dpvcmp)
- logger.debug('Added %s as dep for pkg %s' % (dpname,p.name))
+ pkgname = p.name, arch = architecture, repo = repository,
+ maintainer_id = 0)
+ populate_pkg(pkg, p)
# packages in database and not in syncdb (remove from database)
logger.debug("Set theory: Packages in database not in syncdb")
@@ -239,24 +248,8 @@ def db_update(archname, pkgs):
logger.info("Updating package %s in database", p.name)
pkg = Package.objects.get(
pkgname=p.name,arch=architecture, repo=repository)
- pkg.pkgver = p.ver
- pkg.pkgrel = p.rel
- pkg.pkgdesc = p.desc
- pkg.license = p.license
- pkg.url = p.url
- pkg.needupdate = False
- pkg.last_update = now
- pkg.save()
-
- # files are not in the repo.db.tar.gz
- #pkg.packagefile_set.all().delete()
- #for x in p.files:
- # pkg.packagefile_set.create(path=x)
- pkg.packagedepend_set.all().delete()
- if 'depends' in p.__dict__:
- for y in p.depends:
- dpname,dpvcmp = re.match(r"([a-z0-9-]+)(.*)", y).groups()
- pkg.packagedepend_set.create(depname=dpname, depvcmp=dpvcmp)
+ populate_pkg(pkg, p)
+
logger.info('Finished updating Arch: %s' % archname)