From f81515d2a66b9454ae4cae42c962b865db76f9e2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 18 Feb 2006 23:39:05 +0000 Subject: [PATCH] Clean up do_upgrade() and add atom validation. svn path=/main/trunk/; revision=2735 --- pym/portage.py | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/pym/portage.py b/pym/portage.py index ea45dfaa6..0a0eadb74 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -6791,23 +6791,33 @@ def do_upgrade(mykey): db["/"]["bintree"]=binarytree("/",settings["PKGDIR"],virts) for myline in mylines: mysplit = myline.split() - if not len(mysplit): + if len(mysplit) == 0: continue - if mysplit[0]!="move" and mysplit[0]!="slotmove": + if mysplit[0] is not in ("move", "slotmove"): writemsg("portage: Update type \""+mysplit[0]+"\" not recognized.\n") processed=0 continue - if mysplit[0]=="move" and len(mysplit)!=3: - writemsg("portage: Update command \""+myline+"\" invalid; skipping.\n") - processed=0 - continue - if mysplit[0]=="slotmove" and len(mysplit)!=4: - writemsg("portage: Update command \""+myline+"\" invalid; skipping.\n") - processed=0 - continue - sys.stdout.write(".") - sys.stdout.flush() - + if mysplit[0]=="move": + if len(mysplit)!=3: + writemsg("portage: Update command \""+myline+"\" invalid; skipping.\n") + processed=0 + continue + orig_value, new_value = mysplit[1], mysplit[2] + for cp in (orig_value, new_value): + if not (isvalidatom(cp) and isjustname(cp)): + writemsg("\nERROR: Malformed update entry '%s'\n" % myline) + processed=0 + continue + if mysplit[0]=="slotmove": + if len(mysplit)!=4: + writemsg("portage: Update command \""+myline+"\" invalid; skipping.\n") + processed=0 + continue + pkg, origslot, newslot = mylist[1], mylist[2], mylist[3] + if not isvalidatom(pkg): + writemsg("\nERROR: Malformed update entry '%s'\n" % myline) + processed=0 + continue if mysplit[0]=="move": try: db["/"]["vartree"].dbapi.move_ent(mysplit) @@ -6825,6 +6835,8 @@ def do_upgrade(mykey): # The list of valid updates is filtered by continue statements above. myupd.append(mysplit) + sys.stdout.write(".") + sys.stdout.flush() if processed: #update our internal mtime since we processed all our directives. -- 2.26.2