On Thu, 2007-11-15 at 03:11 -0800, Simon Marlow wrote:
> Thu Nov 15 02:32:49 PST 2007  Simon Marlow <[EMAIL PROTECTED]>
>   * Avoid the use of unversioned package dependencies
>   Fortunately "ghc-pkg list $pkg --simple-output" is a good way to add
>   the version number.

You're lucky that you've only got one version of each package and no
per-user package DB. I was trying to do the same in Gtk2Hs which still
does not use Cabal and so has to find the package version itself.
Currently I have to use:

if test "$USERPKGCONF" = "yes"; then
        #select packages from all sections
        PKGS=$(${GHCPKG} list $pkg | sed -e '/package.conf:/d')
else
        #select packages from the first section only
        PKGS=$(${GHCPKG} list $pkg | sed -e '1d;/package.conf:/,$d')
fi
$PKG_VER=$(echo "${PKGS}"
        | sed -e 's/,/\n/g'             \#break into lines on ,
              -e 's/[[(){}, ]]//g'      \#strip hidden package markers
        | grep -v '^$'                  \#strip blank lines
        | sed -e 's/[[A-Za-z-]]*//'     \#select version components
        | sort -r -n                    \#sort on version 'number'
        | head -n1)                     \#head

Yes it is that ugly :-) (partly because it also has to work on Solaris)

It's particularly ugly because it has to work on the normal human
readable output rather than the nice --simple-output because the simple
output does not distinguish between global and user package dbs, whereas
the human readable form does.

If ghc-pkg let me select which package dbs I'm interested in then it
would be a lot simpler. If we could directly resolve a package name to
the package-name-version that would be even better. That is it should
use the same algorithm that ghc uses to resolve "-package Foo" to some
specific version of Foo (latest non-hidden one). Though again we need
control over the dbs it consults since we might be doing a global
install.

Duncan

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to