Gentoo Archives: gentoo-portage-dev

From: Ryan Hill <dirtyepic@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] Re: [RFC] Location of Portage bash API (outside of ebuilds)
Date: Thu, 06 Feb 2014 02:21:48
Message-Id: 20140205202111.121af993@caribou.gateway.pace.com
In Reply to: Re: [gentoo-portage-dev] [RFC] Location of Portage bash API (outside of ebuilds) by Arfrever Frehtes Taifersar Arahesis
1 On Wed, 5 Feb 2014 20:57:24 +0100
2 Arfrever Frehtes Taifersar Arahesis <arfrever.fta@×××××.com> wrote:
3
4 > 2014-02-05 09:08 Mike Frysinger napisał(a):
5 > > On Saturday, February 01, 2014 21:08:11 Arfrever Frehtes Taifersar Arahesis
6 > > wrote:
7 > > > bin/isolated-functions.sh contains at least 1 useful function, which could
8 > > > be exposed for external consumers (without __ prefix), but must have
9 > > > private name (with __ prefix) when bin/isolated-functions.sh is used in
10 > > > ebuild environment.
11 > >
12 > > who are these mysterious external consumers ?
13 >
14 > E.g. euse, gentoo-bashcomp and potentially other tools written in bash, which
15 > need some data from configuration of repositories.
16 >
17 > I would like to provide 3 functions:
18 > - repos_read_config()
19 > This function would use portageq to set PORTAGE_REPOSITORIES in environment.
20 >
21 > repos_read_config() {
22 > eval "$(portageq envvar -v PORTAGE_REPOSITORIES)"
23 > }
24 >
25 > If external consumer needs also other variables, then it can directly use:
26 > eval "$(portageq envvar -v PORTAGE_REPOSITORIES VAR1 VAR2 VAR3)"
27 >
28 > - repos_list()
29 > This function would print list of names of repositories.
30 >
31 > - repo_attr()
32 > This function would print value of specified attribute (${2}) for specified
33 > repository (${1}). This function would call __repo_attr() function currently
34 > defined in bin/isolated-functions.sh.
35 >
36 > Example code:
37 > . portage.bash
38 > repos_read_config
39 > for repo in $(repos_list); do
40 > location=$(repo_attr ${repo} location)
41 > …
42 > done
43 >
44 > Calling portageq multiple times would be too slow for some tools.
45 >
46 > gentoo-bashcomp contains a custom implementation of parser of repos.conf,
47 > which could be replaced by calls to functions provided by Portage:
48 > http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-bashcomp.git;a=commitdiff;h=bf91db09a102544196b21cd792ac423262656a9a
49
50 Calling portageq once is too slow for gentoo-bashcomp. :/ That parser is
51 terrible, but it's 1000x faster than going through portage.
52
53
54 --
55 Ryan Hill psn: dirtyepic_sk
56 gcc-porting/toolchain/wxwidgets @ gentoo.org
57
58 47C3 6D62 4864 0E49 8E9E 7F92 ED38 BD49 957A 8463

Attachments

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