2005-12-07 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / scripts / mono-find-provides.in
1 #!/bin/bash
2 #
3 # mono-find-provides
4 #
5 # Authors:
6 #       Ben Maurer (bmaurer@ximian.com)
7 #
8 # (C) 2005 Novell (http://www.novell.com)
9 #
10
11 IFS=$'\n'
12 filelist=($(grep -Ev '/usr/doc/|/usr/share/doc/'))
13 monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$"))
14
15 a=`which "$0"`
16 d=`dirname "$a"`
17
18 # Set the prefix, unless it is overriden (used when building mono rpms)
19 : ${prefix=$d/..}
20
21 exec_prefix=$d/..
22 libdir=$prefix/@reloc_libdir@
23 bindir=$d
24
25 [ -x $bindir/monodis ] || exit 0;
26 [ -f $libdir/libmono.so ] || exit 0;
27
28
29 # set LD_LIBRARY_PATH to ensure that libmono.so is found
30 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
31
32 for i in "${monolist[@]}"; do
33         ($bindir/monodis --assembly $i | awk '
34                 BEGIN { LIBNAME=""; VERSION=""; }
35                 /^Version:/ { VERSION=$2 }
36                 /^Name:/    { LIBNAME=$2 }
37                 END {
38                         if (LIBNAME ~ /^policy/) {
39                                 cnt = split(LIBNAME, toks, ".")
40                                 VERSION=toks[2] "." toks[3] ".0.0"
41                                 LIBNAME=""
42                                 for (i=4; i<= cnt; i++)
43                                         LIBNAME = (LIBNAME toks[i] ".")
44                                 LIBNAME=substr(LIBNAME, 1, length(LIBNAME)-1)
45                         }
46                         if (VERSION && LIBNAME)
47                                 print "mono(" LIBNAME ") = " VERSION
48                 }
49             ') 2>/dev/null
50 done