From: Chris White <chriswhite@gentoo.org>
To: gentoo-dev@robin.gentoo.org
Subject: Re: [gentoo-dev] Parsing emerge
Date: Sat, 05 Mar 2005 14:11:24 +0900 [thread overview]
Message-ID: <1109999484.11103.54.camel@secures> (raw)
In-Reply-To: <1109924970.11103.19.camel@secures>
[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]
2005-03-04 (金) の 17:29 +0900 に Chris White さんは書きました:
I've updated the script now, it has a better more functional layout than
before (A large page script :).
Re-cap of the install is here:
>
> http://dev.gentoo.org/~chriswhite/emerge_parse.pl
>
> In order to install this, you'll need to `g-cpan.pl Expect` in order to
> get the Expect module (which interestingly enough also installs the dep
> of IO::Tty).
the main update was the parsing of category, package, and versions from
ebuilds. The code of interest comes from these lines of code:
sub package_nvsplit {
$i=0;
while($_[$i] !~ /^\d/) {
$i++;
}
$package_end=$i-1;
$pn=join("-",@_[0..$package_end]);
$pv=@_[$i..$#package_array];
return $pn, $pv;
}
So for those interested in parsing out package versions and what not,
this is basically how to go about it. First, you splitup the category
and the package name+version (or $P). So...
media-video/xine-lib-1.0 gets splitup into:
media-video (category) and xine-lib-1.0 ($P). Now then, to get package
and version seperation, one simply splits up $P with the - seperator.
This gives us:
xine lib 1.0
Which, a simple loop checks to see if we've hit a section that starts
with a digit (the version number), and re-combines the values before it
with -'s, giving us:
$pv = 1.0
$pn = xine-lib
So there you have it, the basis on seperation of package category, name,
and version. Hopefully this will help those who wish to hack around a
little get an idea of what's involved in the minute areas of portage.
Note that while the code is perl, the concept is very language
non-specific (I could do one in C.. but I'd rather save some of my
sanity ;).
Next stop will be getting USE flag descriptions in a more speedy manner
than simple grep-ing. Please note that suggestions for
improvement/comments/etc. are welcome, and I hope this turns into a nice
informative developer's discussion.
_big note_
I'd also like to thank Nick (carpaski) for his insight on the above
code :).
_big note_
[-- Attachment #2: このメッセージにはデジタル署名された部分があります --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2005-03-05 5:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-04 8:29 [gentoo-dev] Parsing emerge Chris White
2005-03-04 11:08 ` Ian Leitch
2005-03-04 15:05 ` Chris White
2005-03-04 15:05 ` Chris White
2005-03-04 16:19 ` Chris Gianelloni
2005-03-04 17:52 ` Ian Leitch
2005-03-05 3:03 ` Jason Stubbs
2005-03-05 5:11 ` Chris White [this message]
2005-03-06 22:49 ` Aron Griffis
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=1109999484.11103.54.camel@secures \
--to=chriswhite@gentoo.org \
--cc=gentoo-dev@gentoo.org \
--cc=gentoo-dev@robin.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