Gentoo Archives: gentoo-dev

From: Chris White <chriswhite@g.o>
To: gentoo-dev@××××××××××××.org
Subject: [gentoo-dev] Parsing emerge
Date: Fri, 04 Mar 2005 09:04:19
Message-Id: 1109924970.11103.19.camel@secures
1 I'm putting this here for informative purposes as to achieving proper
2 parsing of portage for use in extending the already present behaviour to
3 better suit one's needs. A few things I'll bring into the table from my
4 experience:
5
6 1) NOCOLOR=true is a good idea. It's rather hard to account for both
7 color and no color in regex parsing (unless someone has a spectacularly
8 fun regex for that...) and I find it easiest to parse.
9
10 2) stdout is home to all the portage output, !!! type stuff goes to
11 stderr.
12
13 3) Portage is actually fairly parseable if you try. Lucky I also found
14 that the compile itself goes to stdout, giving you even more flexibility
15 for reporting type situations.
16
17 4) Parsing can, in some cases, help you add extra functionality to
18 portage without even having to hack the portage code. I've already
19 worked on a system that can buffer 20 lines or so backlog, catch an
20 error in the compile, and give you the next few lines. By doing this,
21 it makes it easier to give bug reports by narrowing down what's failing
22 in a compile, expecially if you're getting spewed 100 compile messages
23 and your backlog can't keep up. I've already talked with ferringb
24 regarding that and have looked at some added functionality to make such
25 a system more realiable.
26
27 I wrote a small perl script to exemplify what I'm trying to go at:
28
29 http://dev.gentoo.org/~chriswhite/emerge_parse.pl
30
31 In order to install this, you'll need to `g-cpan.pl Expect` in order to
32 get the Expect module (which interestingly enough also installs the dep
33 of IO::Tty).
34
35 I'm hoping that this information will be somewhat helpful to people here
36 in realizing the full potentional of parsing. Basically, you run the
37 script with -pv arguments (for now.. more to come) like so:
38
39 `emerge_parse.pl -pv xine-lib`
40
41 and you'll get a nice translation of the emerge -pv layout:
42
43 root@secures chris # emerge_parse.pl -pv xine-lib
44 [Pretend] emerge would do a(n) re-install of
45 media-libs/xine-lib-1_rc8-r1
46
47 root@secures chris # emerge_parse.pl -pv java-sdk-docs
48 [Pretend] emerge would do a(n) fetchonly re-install of
49 dev-java/java-sdk-docs-1.4.2
50
51 root@secures dev-util # emerge_parse.pl -pv flawfinder
52 [Pretend] emerge would do a(n) new install of dev-util/flawfinder-1.24
53
54 .. etc.. etc..
55
56 As you can see, extra functionality has been added, and now you get the
57 translation of emerge's abbreviated install method format to something
58 more human readable. I'll hope to have more to come with regards to
59 emerge parsing.

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-dev] Parsing emerge Ian Leitch <port001@g.o>
Re: [gentoo-dev] Parsing emerge Chris White <chriswhite@g.o>