summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-15 19:31:56 -0600
committerDan McGee <dan@archlinux.org>2011-02-16 17:43:50 -0600
commit7f1c7b08227e49172734f09552ceae8bc1f685ad (patch)
tree79104fdca2aa1035a8ee8f42079314b50b27823a /devel/management/commands
parent4444f25d5cd9a9e1cb310a2d9c0b6b1ec1f55789 (diff)
Read in optional deps and show in web interface
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/reporead.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 9b99e0f7..f3ec50e8 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -29,7 +29,7 @@ from optparse import make_option
from logging import ERROR, WARNING, INFO, DEBUG
-from main.models import Arch, Package, Repo
+from main.models import Arch, Package, PackageDepend, Repo
logging.basicConfig(
level=WARNING,
@@ -155,6 +155,20 @@ def find_user(userstring):
# lookup more than strictly necessary.
find_user.cache = {}
+def create_depend(package, dep_str, optional=False):
+ depend = PackageDepend(pkg=package, optional=optional)
+ # lop off any description first
+ parts = dep_str.split(':', 1)
+ if len(parts) > 1:
+ depend.description = parts[1].strip()
+ match = re.match(r"^(.+?)((>=|<=|=|>|<)(.*))?$", parts[0].strip())
+ if match:
+ depend.depname = match.group(1)
+ if match.group(2):
+ depend.depvcmp = match.group(2)
+ depend.save(force_insert=True)
+ return depend
+
def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
if repopkg.base:
dbpkg.pkgbase = repopkg.base
@@ -188,24 +202,20 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
populate_files(dbpkg, repopkg, force=force)
dbpkg.packagedepend_set.all().delete()
- if 'depends' in repopkg.__dict__:
+ if hasattr(repopkg, 'depends'):
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)
+ dep = create_depend(dbpkg, y)
+ if hasattr(repopkg, 'optdepends'):
+ for y in repopkg.optdepends:
+ dep = create_depend(dbpkg, y, True)
dbpkg.groups.all().delete()
- if 'groups' in repopkg.__dict__:
+ if hasattr(repopkg, 'groups'):
for y in repopkg.groups:
dbpkg.groups.create(name=y)
dbpkg.licenses.all().delete()
- if 'license' in repopkg.__dict__:
+ if hasattr(repopkg, 'license'):
for y in repopkg.license:
dbpkg.licenses.create(name=y)
@@ -223,7 +233,7 @@ def populate_files(dbpkg, repopkg, force=False):
elif dbpkg.files_last_update > dbpkg.last_update:
return
# only delete files if we are reading a DB that contains them
- if 'files' in repopkg.__dict__:
+ if hasattr(repopkg, 'files'):
dbpkg.packagefile_set.all().delete()
logger.info("adding %d files for package %s",
len(repopkg.files), dbpkg.pkgname)