tupkgupdate: add config_use_db check to allow skipping of DB operations

This should prevent us from needing to completely duplicate the tupkgupdate
script for x86_64, where we currently skip the DB updates step.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
Dan McGee 2008-11-11 19:37:20 -06:00 committed by Loui Chang
parent 7a1169431a
commit 3c8442d70c

View file

@ -17,6 +17,7 @@ if not os.path.isfile(conffile):
config = ConfigParser.ConfigParser() config = ConfigParser.ConfigParser()
config.read(conffile) config.read(conffile)
config_use_db = config.has_section('mysql')
############################################################ ############################################################
@ -366,11 +367,12 @@ else:
repo_dir, pkgbuild_dir, build_dir = args_proper repo_dir, pkgbuild_dir, build_dir = args_proper
# Open the database so we find out now if we can't! # Open the database if we need it so we find out now if we can't!
db = PackageDatabase(config.get('mysql', 'host'), if config_use_db:
config.get('mysql', 'username'), db = PackageDatabase(config.get('mysql', 'host'),
config.get('mysql', 'password'), config.get('mysql', 'username'),
config.get('mysql', 'db')) config.get('mysql', 'password'),
config.get('mysql', 'db'))
# Set up the lists and tables # Set up the lists and tables
packages = dict() packages = dict()
@ -531,21 +533,22 @@ if (had_error == 1):
# PASS 3: EXECUTION # PASS 3: EXECUTION
# #
# First, do all the database updates if config_use_db:
for package in dbremove: # First, do all the database updates if asked for
id = db.lookup(package.name) for package in dbremove:
# Note: this could remove a package from unsupported; probably want to restrict to locationId and/or non-dummy id = db.lookup(package.name)
if (id != None): # Note: this could remove a package from unsupported; probably want to restrict to locationId and/or non-dummy
db.clearOldInfo(id) if (id != None):
db.remove(id, 3) db.clearOldInfo(id)
db.remove(id, 3)
for package in dbmodify: for package in dbmodify:
warning("DB: Package in dbmodify: " + package.name) warning("DB: Package in dbmodify: " + package.name)
id = db.lookup(package.name) id = db.lookup(package.name)
if (id == None): if (id == None):
db.insert(package, 3) db.insert(package, 3)
else: else:
db.update(id, package, 3) db.update(id, package, 3)
# Copy # Copy
for file in copy: for file in copy: