From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.gentoo.org (smtp.gentoo.org [134.68.220.30]) by robin.gentoo.org (8.13.3/8.13.3) with ESMTP id j255kBOw016262 for ; Sat, 5 Mar 2005 05:46:11 GMT Received: from ns1.hostitnow.com ([209.152.181.224] helo=sls-ce5p311.hostitnow.com) by smtp.gentoo.org with esmtp (Exim 4.42) id 1D7S78-0008LS-Ey for gentoo-dev@robin.gentoo.org; Sat, 05 Mar 2005 05:46:10 +0000 Received: from c-67-181-38-200.client.comcast.net ([67.181.38.200] helo=192.168.0.106) by sls-ce5p311.hostitnow.com with esmtpsa (TLSv1:RC4-MD5:128) (Exim 4.44) id 1D7S7A-0000hN-BH for gentoo-dev@gentoo.org; Sat, 05 Mar 2005 00:46:12 -0500 Subject: Re: [gentoo-dev] Parsing emerge From: Chris White To: gentoo-dev@robin.gentoo.org In-Reply-To: <1109924970.11103.19.camel@secures> References: <1109924970.11103.19.camel@secures> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-4RffNThzrt7GFcqcn4He" Organization: Gentoo Linux Date: Sat, 05 Mar 2005 14:11:24 +0900 Message-Id: <1109999484.11103.54.camel@secures> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-To: gentoo-dev@gentoo.org Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - sls-ce5p311.hostitnow.com X-AntiAbuse: Original Domain - gentoo.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - gentoo.org X-Source: X-Source-Args: X-Source-Dir: X-Archives-Salt: ed1ffd01-662b-46e1-80fa-b1a38b53c16a X-Archives-Hash: 7ae40dd25a20bb80801f87e8f48e0541 --=-4RffNThzrt7GFcqcn4He Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 2005-03-04 (=E9=87=91) =E3=81=AE 17:29 +0900 =E3=81=AB Chris White =E3=81= =95=E3=82=93=E3=81=AF=E6=9B=B8=E3=81=8D=E3=81=BE=E3=81=97=E3=81=9F: 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: >=20 > http://dev.gentoo.org/~chriswhite/emerge_parse.pl >=20 > 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=3D0; while($_[$i] !~ /^\d/) { $i++; } $package_end=3D$i-1; $pn=3Djoin("-",@_[0..$package_end]); $pv=3D@_[$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 =3D 1.0 $pn =3D 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. =20 _big note_ I'd also like to thank Nick (carpaski) for his insight on the above code :). _big note_ --=-4RffNThzrt7GFcqcn4He Content-Type: application/pgp-signature; name=signature.asc Content-Description: =?UTF-8?Q?=E3=81=93=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?Q?=E3=82=B8=E3=81=AB=E3=81=AF=E3=83=87=E3=82=B8=E3=82=BF?= =?UTF-8?Q?=E3=83=AB=E7=BD=B2=E5=90=8D=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?Q?=E9=83=A8=E5=88=86=E3=81=8C=E3=81=82=E3=82=8A=E3=81=BE?= =?UTF-8?Q?=E3=81=99?= -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBCKT98FdQwWVoAgN4RAnmyAKCjhsYGXdBMYdC+OOJ377kAX/A6RACfVaQY ZFDuqK6tTYMqPuo/w0DBiFY= =2Z+/ -----END PGP SIGNATURE----- --=-4RffNThzrt7GFcqcn4He-- -- gentoo-dev@gentoo.org mailing list