From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from <gentoo-commits+bounces-328856-garchives=archives.gentoo.org@lists.gentoo.org>) id 1Q2W5h-0003Kr-A5 for garchives@archives.gentoo.org; Wed, 23 Mar 2011 21:59:46 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B13511C0CF; Wed, 23 Mar 2011 21:59:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 702541C0CF for <gentoo-commits@lists.gentoo.org>; Wed, 23 Mar 2011 21:59:23 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 011EE1B4087 for <gentoo-commits@lists.gentoo.org>; Wed, 23 Mar 2011 21:59:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2ABED8006E for <gentoo-commits@lists.gentoo.org>; Wed, 23 Mar 2011 21:59:22 +0000 (UTC) From: "Nirbheek Chauhan" <nirbheek@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Nirbheek Chauhan" <nirbheek@gentoo.org> Message-ID: <5ea970fbdfa52f7e9f5a222ad99bfb228b57330f.nirbheek@gentoo> Subject: [gentoo-commits] proj/gnome:master commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/gir-rebuilder.py X-VCS-Directories: scripts/ X-VCS-Committer: nirbheek X-VCS-Committer-Name: Nirbheek Chauhan X-VCS-Revision: 5ea970fbdfa52f7e9f5a222ad99bfb228b57330f Date: Wed, 23 Mar 2011 21:59:22 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 6c24f6a67de960dfc96f41ea600e2cdc commit: 5ea970fbdfa52f7e9f5a222ad99bfb228b57330f Author: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org> AuthorDate: Wed Mar 23 21:55:21 2011 +0000 Commit: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org> CommitDate: Wed Mar 23 21:59:03 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gnome.git;a=3D= commit;h=3D5ea970fb gir-rebuilder.py: add a --force option, use EOutput, fix small bugs * Add --force to force rebuilding of all .girs * Use EOutput and spinners to display status * Fix a bug where an installed package was no longer in portage * Use vartree dbapi for *all* API access --- scripts/gir-rebuilder.py | 63 +++++++++++++++++++++++++++++-----------= ----- 1 files changed, 40 insertions(+), 23 deletions(-) diff --git a/scripts/gir-rebuilder.py b/scripts/gir-rebuilder.py index 6cecd59..db6458f 100755 --- a/scripts/gir-rebuilder.py +++ b/scripts/gir-rebuilder.py @@ -17,31 +17,37 @@ from xml.dom import minidom as dom =20 import portage from portage.versions import vercmp -from portage.output import colorize +from portage.output import EOutput +from _emerge.stdout_spinner import stdout_spinner =20 ############### ## Variables ## ############### quiet =3D False +force =3D False root =3D '/' gir_dirs =3D ['/usr/share/gir-1.0'] girs =3D {} girversion =3D '' gi =3D 'gobject-introspection' settings =3D portage.settings +eoutput =3D EOutput() +spinner =3D stdout_spinner() =20 ############### ## Functions ## ############### def usage(): - print """ -gir-rebuilder: Rebuilds gobject-introspection typelibs and girs in the f= ollowing directories: + print """gir-rebuilder: Rebuilds gobject-introspection typelibs and = girs in the following directories: %s =20 -Usage: %s [ARGUMENTS TO EMERGE] +Usage: %s [--force] [ARGUMENTS TO EMERGE] =20 Arguments: - All arguments are passed to portage + --help This text + --force Force rebuilding of *all* girs and typelibs + + All other arguments are passed to portage """ % ('\n '.join(gir_dirs), sys.argv[0]) =20 def get_version(gir): @@ -51,26 +57,26 @@ def get_contents(cpv): cpv =3D portage.catsplit(cpv) return set(portage.dblink(cpv[0], cpv[1], root, settings).getcontent= s().keys()) =20 -def print_colorize(color, text): - print colorize(color, " * ") + text - ################ ## Parse Args ## ################ if '--help' in sys.argv: usage() exit(0) +if '--force' in sys.argv: + force =3D True + sys.argv.remove('--force') =20 ############## ## Set vars ## ############## if os.environ.has_key('ROOT'): root =3D os.environ['ROOT'] -portdb =3D portage.db[root]["vartree"].dbapi +vardbapi =3D portage.vardbapi() # Find the latest g-i # XXX: Assumes there's only one slot for g-i -print_colorize("green", "Finding current GIRepository version...") -gi =3D portdb.match(gi)[0] +eoutput.ebegin("Finding current GIRepository version") +gi =3D vardbapi.match(gi)[0] for each in get_contents(gi): # Find GIRepository-$ver.gir, and get the internal version if re.match('.*GIRepository[^/]+\.gir$', each): @@ -79,12 +85,16 @@ for each in get_contents(gi): else: raise Exception("GIRepository .gir not found") girversion =3D get_version(girepository) -print_colorize("green", "Current GIRepository version is " + girversion) +eoutput.eend(0) +eoutput.einfo("Current GIRepository version is " + girversion) =20 ########## ## Work ## ########## -print_colorize("green", "Finding broken GIR files...") +if force: + eoutput.ebegin("Finding GIR files") +else: + eoutput.ebegin("Finding broken GIR files") files_list =3D set() for dir in gir_dirs: # Walk the gir directories to find files @@ -92,38 +102,45 @@ for dir in gir_dirs: for f in files: if not f.endswith('.gir'): continue + if force: + files_list.add(osp.join(path, f)) + continue + spinner.update() # Get the .gir version version =3D get_version(osp.join(path, f)) # If not the same version as GIRepository.gir, rebuild it if vercmp(girversion, version) !=3D 0: - print_colorize("yellow", "GIR file to be rebuilt: " + \ + eoutput.ewarn("GIR file to be rebuilt: " + \ osp.join(path, f)) files_list.add(osp.join(path, f)) +eoutput.eend(0) =20 # FIXME: Doesn't warn if it was unable to assign a file to a package rebuild_list =3D set() if files_list: - print_colorize("green", "Assigning files to packages...") + eoutput.ebegin("Assigning files to packages") files_assigned =3D set() - for cpv in portage.db[root]["vartree"].dbapi.cpv_all(): + for cpv in vardbapi.cpv_all(): + spinner.update() # If some of the files of this package are in the gir file list files_owned =3D get_contents(cpv).intersection(files_list) if files_owned: - files_assigned.add(files_owned) - slot =3D portage.portdb.aux_get(cpv, ['SLOT'])[0] + files_assigned.update(files_owned) + slot =3D vardbapi.aux_get(cpv, ['SLOT'])[0] # We strip the version, but maintain the slot (same as revde= p-rebuild) rebuild_list.add(portage.pkgsplit(cpv)[0]+':'+slot) files_unassigned =3D files_list.symmetric_difference(files_assigned) if files_unassigned: for file in files_unassigned: - print_colorize("yellow", "Unable to assign file to package: = " + \ + eoutput.ewarn("Unable to assign file to package: " + \ osp.join(path, file)) +eoutput.eend(0) =20 if files_list and rebuild_list: - print_colorize("green", "All done, starting rebuild...") - command =3D "emerge -1 " + '\n'.join(sys.argv[1:]+list(rebuild_list)= ) + eoutput.einfo("All done, starting rebuild") + command =3D "emerge --oneshot " + ' \\\n'.join(sys.argv[1:]+list(reb= uild_list)) print command # Run emerge - subprocess.check_call(command, shell=3DTrue) + subprocess.call(command, shell=3DTrue) else: - print_colorize("green", "Everything seems to be in order, nothing to= be rebuilt") + eoutput.einfo("Everything seems to be in order, nothing to be rebuil= t")