aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Bacherikov <slava@bacher09.org>2012-08-21 20:19:25 +0300
committerSlava Bacherikov <slava@bacher09.org>2012-08-21 20:19:25 +0300
commitfb52b4806558ffcc31630ed0721028f933809b4c (patch)
treea8c56079b39880de78b89cb8f7f08dbc4e4b13fe
parentAdd herds_count to repository template (diff)
downloadgentoo-packages-fb52b4806558ffcc31630ed0721028f933809b4c.tar.gz
gentoo-packages-fb52b4806558ffcc31630ed0721028f933809b4c.tar.bz2
gentoo-packages-fb52b4806558ffcc31630ed0721028f933809b4c.zip
Improve updateebuildmask command
-rw-r--r--gpackages/apps/packages/management/commands/updateebuildmask.py10
-rw-r--r--gpackages/apps/packages/scan.py31
2 files changed, 28 insertions, 13 deletions
diff --git a/gpackages/apps/packages/management/commands/updateebuildmask.py b/gpackages/apps/packages/management/commands/updateebuildmask.py
index a26554d..15a0ec5 100644
--- a/gpackages/apps/packages/management/commands/updateebuildmask.py
+++ b/gpackages/apps/packages/management/commands/updateebuildmask.py
@@ -10,8 +10,14 @@ class Command(BaseCommand):
dest='show_time',
default=True,
help='Show time of scanning'),
+ make_option('-m', '--update-missing',
+ action='store_true',
+ dest='missing',
+ default=False,
+ help='Add missing ebuilds'),
)
args = ''
- help = 'Will add missing ebuilds'
+ help = 'Will update ebuild mask status'
def handle(self, *args, **options):
- Scanner(**options).update_ebuild_mask()
+ missing = options.get('missing', False) # maybe move it to function ?
+ Scanner(**options).update_ebuild_mask(missing = missing)
diff --git a/gpackages/apps/packages/scan.py b/gpackages/apps/packages/scan.py
index 660fcc3..84d73f5 100644
--- a/gpackages/apps/packages/scan.py
+++ b/gpackages/apps/packages/scan.py
@@ -773,27 +773,35 @@ class Scanner(object):
models.PackageModel.objects.filter(pk = package_id). \
update(latest_ebuild = latest_ebuild)
+ def missing_ebuild(self, ebuild):
+ try:
+ package_obj = models.PackageModel.objects. \
+ get(package = ebuild.package)
+
+ except models.PackageModel.DoesNotExist:
+ pass
+ else:
+ # Don't run this for updated packages
+ if package_obj.manifest_hash == ebuild.package.manifest_sha1:
+ self.output('%-44s [%s]M\n', (ebuild,
+ ebuild.package.category.porttree_name))
+ self.update_ebuilds(ebuild.package, package_obj)
+
def add_mising_ebuilds(self):
for ebuild in porttree.iter_ebuilds():
try:
ebuild_obj = models.EbuildModel.objects.get(ebuild = ebuild)
except models.EbuildModel.DoesNotExist:
- self.output('%-44s [%s]\n', (ebuild,
- ebuild.package.category.porttree_name))
- try:
- package_obj = models.PackageModel.objects. \
- get(package = ebuild.package)
-
- except models.PackageModel.DoesNotExist:
- pass
- else:
- self.update_ebuilds(ebuild.package, package_obj)
+ self.missing_ebuild(ebuild)
- def update_ebuild_mask(self):
+ def update_ebuild_mask(self, missing = False):
for ebuild in porttree.iter_ebuilds():
try:
ebuild_obj = models.EbuildModel.objects.get(ebuild = ebuild)
except models.EbuildModel.DoesNotExist:
+ if missing:
+ self.missing_ebuild(ebuild)
+
continue
if ebuild_obj.is_hard_masked != ebuild.is_hard_masked:
self.output('%-44s [%s]\n', (ebuild,
@@ -801,3 +809,4 @@ class Scanner(object):
ebuild_obj.is_hard_masked = ebuild.is_hard_masked
ebuild_obj.save(force_update = True)
+