summaryrefslogtreecommitdiff
path: root/devel/management/commands
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-04-16 20:02:22 -0500
committerDan McGee <dan@archlinux.org>2010-04-16 20:02:22 -0500
commit8ec2e404514770cce407a34b8149097d51192a40 (patch)
tree0a62a8f51583a11e68073b76230575ea54e7950a /devel/management/commands
parent5fb2fca70a13181ae8aaec60e855693114b1198f (diff)
reporead: allow removal of last package in an arch
We had a situation where the last 'any' architecture package was present in the [testing] repo and never got removed because we never did the db_update() call on that architecture. Instead of looping all possible architectures and only calling if len() > 0, always call db_update() for both the primary architecture and the 'any' architecture. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/management/commands')
-rw-r--r--devel/management/commands/reporead.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 32e7929e..777bc5dd 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -188,7 +188,7 @@ def populate_files(dbpkg, repopkg, force=False):
dbpkg.files_last_update = datetime.now()
dbpkg.save()
-def db_update(archname, pkgs, options):
+def db_update(archname, reponame, pkgs, options):
"""
Parses a list and updates the Arch dev database accordingly.
@@ -199,7 +199,7 @@ def db_update(archname, pkgs, options):
logger.info('Updating Arch: %s' % archname)
force = options.get('force', False)
filesonly = options.get('filesonly', False)
- repository = Repo.objects.get(name__iexact=pkgs[0].repo)
+ repository = Repo.objects.get(name__iexact=reponame)
architecture = Arch.objects.get(name__iexact=archname)
dbpkgs = Package.objects.filter(arch=architecture, repo=repository)
# It makes sense to fully evaluate our DB query now because we will
@@ -362,7 +362,7 @@ def parse_repo(repopath):
tpkg.write('\n') # just in case
repodb.close()
logger.info("Finished repo parsing")
- return pkgs
+ return (reponame, pkgs)
def validate_arch(arch):
"Check if arch is valid."
@@ -374,25 +374,23 @@ def read_repo(primary_arch, file, options):
"""
Parses repo.db.tar.gz file and returns exit status.
"""
- packages = parse_repo(file)
+ repo, packages = parse_repo(file)
# sort packages by arch -- to handle noarch stuff
packages_arches = {}
- available_arches = [x.name for x in Arch.objects.all()]
- for arch in available_arches:
- packages_arches[arch] = []
+ packages_arches['any'] = []
+ packages_arches[primary_arch] = []
for package in packages:
if package.arch in ('any', primary_arch):
packages_arches[package.arch].append(package)
else:
+ # we don't include mis-arched packages
logger.warning("Package %s arch = %s" % (
package.name,package.arch))
- #package.arch = primary_arch
logger.info('Starting database updates.')
for (arch, pkgs) in packages_arches.items():
- if len(pkgs) > 0:
- db_update(arch, pkgs, options)
+ db_update(arch, repo, pkgs, options)
logger.info('Finished database updates.')
return 0