summaryrefslogtreecommitdiffstats
path: root/devel/management
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-02-27 04:52:16 +0100
committerDan McGee <dan@archlinux.org>2010-02-27 04:52:16 +0100
commit655b3db1b7a8a78cfd74723bd9ed17011ed0c935 (patch)
tree0d247ce905cab80d02d80019f027ececa3cfbd8c /devel/management
parentce0b9076ee149d139b16d978b31c9db56db9fbea (diff)
downloadarchweb-655b3db1b7a8a78cfd74723bd9ed17011ed0c935.tar.gz
archweb-655b3db1b7a8a78cfd74723bd9ed17011ed0c935.tar.xz
reporead: allow a force update
This allows re-running repoadd on all packages in case of adding data or fixing a bug without rendering the last_update values in the database useless. For packages that aren't geting their version bumped, don't touch last_update on a force import but do touch the rest of the fields. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'devel/management')
-rwxr-xr-xdevel/management/commands/reporead.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index 90337b8..dad5d30 100755
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -52,7 +52,10 @@ logging.basicConfig(
logger = logging.getLogger()
class Command(BaseCommand):
- option_list = BaseCommand.option_list
+ option_list = BaseCommand.option_list + (
+ make_option('-f', '--force', action='store_true', dest='force', default=False,
+ help='Force a re-import of data for all packages instead of only new ones. Will not touch the \'last updated\' value.'),
+ )
help = "Runs a package repository import for the given arch and file."
args = "<arch> <filename>"
@@ -75,7 +78,7 @@ class Command(BaseCommand):
elif v == 2:
logger.level = DEBUG
- return read_repo(arch, file)
+ return read_repo(arch, file, options)
class Pkg(object):
@@ -130,7 +133,6 @@ class Pkg(object):
def populate_pkg(dbpkg, repopkg, timestamp=None):
- if not timestamp: timestamp = datetime.now()
dbpkg.pkgbase = repopkg.base
dbpkg.pkgver = repopkg.ver
dbpkg.pkgrel = repopkg.rel
@@ -142,7 +144,8 @@ def populate_pkg(dbpkg, repopkg, timestamp=None):
dbpkg.build_date = datetime.utcfromtimestamp(int(repopkg.builddate))
dbpkg.needupdate = False
- dbpkg.last_update = timestamp
+ if timestamp:
+ dbpkg.last_update = timestamp
dbpkg.save()
# files are not in the repo.db.tar.gz
#for x in repopkg.files:
@@ -160,7 +163,7 @@ def populate_pkg(dbpkg, repopkg, timestamp=None):
logger.debug('Added %s as dep for pkg %s' % (dpname,repopkg.name))
-def db_update(archname, pkgs):
+def db_update(archname, pkgs, force):
"""
Parses a list and updates the Arch dev database accordingly.
@@ -212,7 +215,7 @@ def db_update(archname, pkgs):
for p in [x for x in pkgs if x.name in in_sync_not_db]:
logger.info("Adding package %s", p.name)
pkg = Package(pkgname = p.name, arch = architecture, repo = repository)
- populate_pkg(pkg, p)
+ populate_pkg(pkg, p, timestamp=datetime.now())
# packages in database and not in syncdb (remove from database)
logger.debug("Set theory: Packages in database not in syncdb")
@@ -228,12 +231,18 @@ def db_update(archname, pkgs):
for p in [x for x in pkgs if x.name in pkg_in_both]:
logger.debug("Looking for package updates")
dbp = dbdict[p.name]
+ timestamp = None
+ # for a force, we don't want to update the timestamp.
+ # for a non-force, we don't want to do anything at all.
if ''.join((p.ver,p.rel)) == ''.join((dbp.pkgver,dbp.pkgrel)):
- continue
+ if not force:
+ continue
+ else:
+ timestamp = datetime.now()
logger.info("Updating package %s in database", p.name)
pkg = Package.objects.get(
pkgname=p.name,arch=architecture, repo=repository)
- populate_pkg(pkg, p)
+ populate_pkg(pkg, p, timestamp=timestamp)
logger.info('Finished updating Arch: %s' % archname)
@@ -319,7 +328,7 @@ def validate_arch(arch):
return arch in available_arches
@transaction.commit_on_success
-def read_repo(primary_arch, file):
+def read_repo(primary_arch, file, options):
"""
Parses repo.db.tar.gz file and returns exit status.
"""
@@ -338,11 +347,11 @@ def read_repo(primary_arch, file):
logger.warning("Package %s arch = %s" % (
package.name,package.arch))
#package.arch = primary_arch
-
+ f = options.get('force', False)
logger.info('Starting database updates.')
for (arch, pkgs) in packages_arches.items():
if len(pkgs) > 0:
- db_update(arch,pkgs)
+ db_update(arch, pkgs, f)
logger.info('Finished database updates.')
return 0