When the user issues a emerge --config postgis then the ebuild will use the values that PG_USER & PGDATABASE had when the package was originally installed and not the current ones. So if you do the following PGDATABASE=db1 emerge postgis PGDATABASE=db2 emerge --config postgis then in the configuration stage, it will try to connect to the database db1 and not to db2. So if the user has many postgis-enabled databases (say db1, db2 and db3) then the following will not upgrade them: PGDATABASE=db1 emerge --config postgis PGDATABASE=db2 emerge --config postgis PGDATABASE=db3 emerge --config postgis I think it would be really useful if the above would work. Reproducible: Always Steps to Reproduce:
You're right, it should work like this. As I always use the ebuild command to config postgis, there is no need to copy the environment tarball used when emerging the ebuild. So using this commands should work : rm /var/tmp/portage/dev-db/postgis-1.3.6/temp/environment for i in db1 db2 ; do PGDATABASE=${i} ebuild /usr/portage/dev-db/postgis/postgis-1.3.6.ebuild config; done When we use the emerge --config command, then the environment tarball stored in /var/db/pkg/${CATEGORY}/${P}/environment.bz2 will be unpacked in /var/tmp/portage/${CATEGORY}/${P}/temp/environment. Then pkg_config will use this environment file to load your variables into its environment. So we have to find a way to force overloading of the evironment variables defined in this file. One way could be to use a specific variable which is for sure not set in your environment variables, but we can't ensure that the variable wasn't defined in your environment. By the way, the environment variables defined localy won't be used from pkg_config. I will invetigate more to find a solution, if there is any, to make emerge --config using localy defined evironment variables but realy unsure to be able to do something like that.
How about moving the pkg_config function from the ebuild into a separate helper script that will be installed along with postgis?
I think it could be a good idea. Nevertheless, imho the ebuild should be responsible to upgrade your databases. I'm currently creating a new ebuild using a conf.d file called postgis_dbs which includes on each line a database name to be updated by the emerge --config process. This way users only have to add their spatialy enabled databases in this file to be able to update them when they do the emerge --config part. Note that this conf.d file should be created automaticaly if needed.
I heard that if set the variables in /etc/portage/bashrc they will be taken into account. Please test
01 May 2011; Aaron W. Swenson <titanofold@gentoo.org> +postgis-1.5.2-r1.ebuild, +files/postgis_dbs, metadata.xml: Fixes bug 273960, 285082, 296172, 314243, 325113 and 339312