From: "Nirbheek Chauhan" <nirbheek@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gnome:master commit in: scripts/
Date: Wed, 23 Mar 2011 21:59:22 +0000 (UTC) [thread overview]
Message-ID: <5ea970fbdfa52f7e9f5a222ad99bfb228b57330f.nirbheek@gentoo> (raw)
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=proj/gnome.git;a=commit;h=5ea970fb
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
import portage
from portage.versions import vercmp
-from portage.output import colorize
+from portage.output import EOutput
+from _emerge.stdout_spinner import stdout_spinner
###############
## Variables ##
###############
quiet = False
+force = False
root = '/'
gir_dirs = ['/usr/share/gir-1.0']
girs = {}
girversion = ''
gi = 'gobject-introspection'
settings = portage.settings
+eoutput = EOutput()
+spinner = stdout_spinner()
###############
## Functions ##
###############
def usage():
- print """
-gir-rebuilder: Rebuilds gobject-introspection typelibs and girs in the following directories:
+ print """gir-rebuilder: Rebuilds gobject-introspection typelibs and girs in the following directories:
%s
-Usage: %s [ARGUMENTS TO EMERGE]
+Usage: %s [--force] [ARGUMENTS TO EMERGE]
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])
def get_version(gir):
@@ -51,26 +57,26 @@ def get_contents(cpv):
cpv = portage.catsplit(cpv)
return set(portage.dblink(cpv[0], cpv[1], root, settings).getcontents().keys())
-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 = True
+ sys.argv.remove('--force')
##############
## Set vars ##
##############
if os.environ.has_key('ROOT'):
root = os.environ['ROOT']
-portdb = portage.db[root]["vartree"].dbapi
+vardbapi = 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 = portdb.match(gi)[0]
+eoutput.ebegin("Finding current GIRepository version")
+gi = 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 = get_version(girepository)
-print_colorize("green", "Current GIRepository version is " + girversion)
+eoutput.eend(0)
+eoutput.einfo("Current GIRepository version is " + girversion)
##########
## Work ##
##########
-print_colorize("green", "Finding broken GIR files...")
+if force:
+ eoutput.ebegin("Finding GIR files")
+else:
+ eoutput.ebegin("Finding broken GIR files")
files_list = 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 = get_version(osp.join(path, f))
# If not the same version as GIRepository.gir, rebuild it
if vercmp(girversion, version) != 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)
# FIXME: Doesn't warn if it was unable to assign a file to a package
rebuild_list = set()
if files_list:
- print_colorize("green", "Assigning files to packages...")
+ eoutput.ebegin("Assigning files to packages")
files_assigned = 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 = get_contents(cpv).intersection(files_list)
if files_owned:
- files_assigned.add(files_owned)
- slot = portage.portdb.aux_get(cpv, ['SLOT'])[0]
+ files_assigned.update(files_owned)
+ slot = vardbapi.aux_get(cpv, ['SLOT'])[0]
# We strip the version, but maintain the slot (same as revdep-rebuild)
rebuild_list.add(portage.pkgsplit(cpv)[0]+':'+slot)
files_unassigned = 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)
if files_list and rebuild_list:
- print_colorize("green", "All done, starting rebuild...")
- command = "emerge -1 " + '\n'.join(sys.argv[1:]+list(rebuild_list))
+ eoutput.einfo("All done, starting rebuild")
+ command = "emerge --oneshot " + ' \\\n'.join(sys.argv[1:]+list(rebuild_list))
print command
# Run emerge
- subprocess.check_call(command, shell=True)
+ subprocess.call(command, shell=True)
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 rebuilt")
next reply other threads:[~2011-03-23 21:59 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-23 21:59 Nirbheek Chauhan [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-04-03 19:42 [gentoo-commits] proj/gnome:master commit in: scripts/ Matt Turner
2020-04-03 19:42 Matt Turner
2020-03-28 8:31 Mart Raudsepp
2020-03-10 22:05 Matt Turner
2019-02-07 11:58 Mart Raudsepp
2018-04-25 10:32 Mart Raudsepp
2018-01-10 3:25 Mart Raudsepp
2012-04-01 21:14 Nirbheek Chauhan
2012-04-01 19:12 Nirbheek Chauhan
2011-08-18 6:23 Nirbheek Chauhan
2011-07-12 21:15 Nirbheek Chauhan
2011-05-21 18:38 Nirbheek Chauhan
2011-05-19 12:35 Gilles Dartiguelongue
2011-04-13 9:57 Nirbheek Chauhan
2011-04-09 6:29 Nirbheek Chauhan
2011-03-28 16:15 Nirbheek Chauhan
2011-03-28 15:04 Nirbheek Chauhan
2011-03-26 1:58 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 21:59 Nirbheek Chauhan
2011-03-23 19:21 Gilles Dartiguelongue
2011-03-23 10:39 Gilles Dartiguelongue
2011-03-20 8:11 Nirbheek Chauhan
2011-03-18 9:59 Nirbheek Chauhan
2011-03-18 8:23 Nirbheek Chauhan
2011-03-17 17:12 Nirbheek Chauhan
2011-03-15 13:08 Nirbheek Chauhan
2011-03-14 18:41 Nirbheek Chauhan
2011-03-12 20:10 Nirbheek Chauhan
2011-03-04 15:40 Nirbheek Chauhan
2011-02-18 4:40 Nirbheek Chauhan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5ea970fbdfa52f7e9f5a222ad99bfb228b57330f.nirbheek@gentoo \
--to=nirbheek@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox