Gentoo Archives: gentoo-dev

From: Ian Leitch <port001@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Parsing emerge
Date: Fri, 04 Mar 2005 11:09:04
Message-Id: 422841C8.10407@gentoo.org
In Reply to: [gentoo-dev] Parsing emerge by Chris White
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Chris White wrote:
5 | I'm putting this here for informative purposes as to achieving proper
6 | parsing of portage for use in extending the already present behaviour to
7 | better suit one's needs. A few things I'll bring into the table from my
8 | experience:
9 |
10 | 1) NOCOLOR=true is a good idea. It's rather hard to account for both
11 | color and no color in regex parsing (unless someone has a spectacularly
12 | fun regex for that...) and I find it easiest to parse.
13 |
14 | 2) stdout is home to all the portage output, !!! type stuff goes to
15 | stderr.
16 |
17 | 3) Portage is actually fairly parseable if you try. Lucky I also found
18 | that the compile itself goes to stdout, giving you even more flexibility
19 | for reporting type situations.
20 |
21 | 4) Parsing can, in some cases, help you add extra functionality to
22 | portage without even having to hack the portage code. I've already
23 | worked on a system that can buffer 20 lines or so backlog, catch an
24 | error in the compile, and give you the next few lines. By doing this,
25 | it makes it easier to give bug reports by narrowing down what's failing
26 | in a compile, expecially if you're getting spewed 100 compile messages
27 | and your backlog can't keep up. I've already talked with ferringb
28 | regarding that and have looked at some added functionality to make such
29 | a system more realiable.
30 |
31 | I wrote a small perl script to exemplify what I'm trying to go at:
32 |
33 | http://dev.gentoo.org/~chriswhite/emerge_parse.pl
34 |
35 | In order to install this, you'll need to `g-cpan.pl Expect` in order to
36 | get the Expect module (which interestingly enough also installs the dep
37 | of IO::Tty).
38 |
39 | I'm hoping that this information will be somewhat helpful to people here
40 | in realizing the full potentional of parsing. Basically, you run the
41 | script with -pv arguments (for now.. more to come) like so:
42 |
43 | `emerge_parse.pl -pv xine-lib`
44 |
45 | and you'll get a nice translation of the emerge -pv layout:
46 |
47 | root@secures chris # emerge_parse.pl -pv xine-lib
48 | [Pretend] emerge would do a(n) re-install of
49 | media-libs/xine-lib-1_rc8-r1
50 |
51 | root@secures chris # emerge_parse.pl -pv java-sdk-docs
52 | [Pretend] emerge would do a(n) fetchonly re-install of
53 | dev-java/java-sdk-docs-1.4.2
54 |
55 | root@secures dev-util # emerge_parse.pl -pv flawfinder
56 | [Pretend] emerge would do a(n) new install of dev-util/flawfinder-1.24
57 |
58 | .. etc.. etc..
59 |
60 | As you can see, extra functionality has been added, and now you get the
61 | translation of emerge's abbreviated install method format to something
62 | more human readable. I'll hope to have more to come with regards to
63 | emerge parsing.
64
65 Sorry to spoil your post Chris, but I think this is just another
66 testimonial to how badly we all need that portage API (plus the portage
67 daemon for tools such as Porthole who currently also have to parse
68 emerge output). This is by no means the first attempt at parsing I've seen.
69
70 But hey, nice work in the absence of the API, it does look like the
71 script has uses.
72
73 Regards,
74 Ian Leitch
75 -----BEGIN PGP SIGNATURE-----
76 Version: GnuPG v1.4.0 (GNU/Linux)
77
78 iD8DBQFCKEHIefZ4eWAXRGIRAtzxAJ0WzeL5erEZZISc2RtHN7fmUiAKlgCgj7nv
79 GdAhWXwT+BUrhrgkFJIU8eI=
80 =pqYj
81 -----END PGP SIGNATURE-----
82 --
83 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] Parsing emerge Chris White <chriswhite@g.o>
Re: [gentoo-dev] Parsing emerge Chris White <chriswhite@g.o>
Re: [gentoo-dev] Parsing emerge Jason Stubbs <jstubbs@g.o>