On Wed, 5 Feb 2014 20:57:24 +0100 Arfrever Frehtes Taifersar Arahesis wrote: > 2014-02-05 09:08 Mike Frysinger napisał(a): > > On Saturday, February 01, 2014 21:08:11 Arfrever Frehtes Taifersar Arahesis > > wrote: > > > bin/isolated-functions.sh contains at least 1 useful function, which could > > > be exposed for external consumers (without __ prefix), but must have > > > private name (with __ prefix) when bin/isolated-functions.sh is used in > > > ebuild environment. > > > > who are these mysterious external consumers ? > > E.g. euse, gentoo-bashcomp and potentially other tools written in bash, which > need some data from configuration of repositories. > > I would like to provide 3 functions: > - repos_read_config() > This function would use portageq to set PORTAGE_REPOSITORIES in environment. > > repos_read_config() { > eval "$(portageq envvar -v PORTAGE_REPOSITORIES)" > } > > If external consumer needs also other variables, then it can directly use: > eval "$(portageq envvar -v PORTAGE_REPOSITORIES VAR1 VAR2 VAR3)" > > - repos_list() > This function would print list of names of repositories. > > - repo_attr() > This function would print value of specified attribute (${2}) for specified > repository (${1}). This function would call __repo_attr() function currently > defined in bin/isolated-functions.sh. > > Example code: > . portage.bash > repos_read_config > for repo in $(repos_list); do > location=$(repo_attr ${repo} location) > … > done > > Calling portageq multiple times would be too slow for some tools. > > gentoo-bashcomp contains a custom implementation of parser of repos.conf, > which could be replaced by calls to functions provided by Portage: > http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-bashcomp.git;a=commitdiff;h=bf91db09a102544196b21cd792ac423262656a9a Calling portageq once is too slow for gentoo-bashcomp. :/ That parser is terrible, but it's 1000x faster than going through portage. -- Ryan Hill psn: dirtyepic_sk gcc-porting/toolchain/wxwidgets @ gentoo.org 47C3 6D62 4864 0E49 8E9E 7F92 ED38 BD49 957A 8463