Provide the pkgroot value in ghc-pkg dump & describe when necessary
authorDuncan Coutts <duncan@well-typed.com>
Wed, 25 May 2011 12:06:14 +0000 (13:06 +0100)
committerDuncan Coutts <duncan@well-typed.com>
Wed, 25 May 2011 14:11:11 +0000 (15:11 +0100)
commitf35a3d247e023b6c1b0abe677549b29398933b50
tree25fa366068c230d536f5dd3a1122899650a76157
parent4063e1d8501b38b5ed8d620dcd8e27adee0e7091
Provide the pkgroot value in ghc-pkg dump & describe when necessary

Tools handling installed packages need to be able to interpret the
paths which are relative to the ${pkgroot} which means they need to
know the value of ${pkgroot}. With ghc-pkg this is not always obvious
since ghc-pkg does not currently have any way machine interface for
reporting the location of its package dbs (global, user). The solution
we have arrived at is simply to emit the pkgroot as an extra field
when it is needed.

There are two cases:
 * --no-expand-pkgroot: ghc-pkg dump/describe will not expand the
   ${pkgroot} var, so it will appear literally in the output and the
   pkgroot field will be generated so that tools know what value to
   use for the ${pkgroot}.
 * --expand-pkgroot: ghc-pkg dump/describe will expand the ${pkgroot}
   and ${pkgrooturl} vars and will not generate the pkgroot field.

The defaults are:
 * ghc-pkg dump/describe --no-expand-pkgroot
 * ghc-pkg field --expand-pkgroot
utils/ghc-pkg/Main.hs