New test.
[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 # Only include files with /gac/ in path
16 #  (Allows packages to contain private assemblies that don't conflict with other packages)
17 #monolist=($(printf "%s\n" "${monolist[@]}" | egrep "/gac/"))
18 # Disabled... see ChangeLog
19
20 a=`which "$0"`
21 d=`dirname "$a"`
22
23 # Set the prefix, unless it is overriden (used when building mono rpms)
24 : ${prefix=$d/..}
25
26 exec_prefix=$d/..
27 libdir=$prefix/@reloc_libdir@
28 bindir=$d
29
30 [ -x $bindir/monodis ] || exit 0;
31 [ -f $libdir/libmono.so ] || exit 0;
32
33
34 # set LD_LIBRARY_PATH to ensure that libmono.so is found
35 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
36
37 for i in "${monolist[@]}"; do
38         ($bindir/monodis --assembly $i | awk '
39                 BEGIN { LIBNAME=""; VERSION=""; }
40                 /^Version:/ { VERSION=$2 }
41                 /^Name:/    { LIBNAME=$2 }
42                 END {
43                         if (LIBNAME ~ /^policy/) {
44                                 cnt = split(LIBNAME, toks, ".")
45                                 VERSION=toks[2] "." toks[3] ".0.0"
46                                 LIBNAME=""
47                                 for (i=4; i<= cnt; i++)
48                                         LIBNAME = (LIBNAME toks[i] ".")
49                                 LIBNAME=substr(LIBNAME, 1, length(LIBNAME)-1)
50                         }
51                         if (VERSION && LIBNAME)
52                                 print "mono(" LIBNAME ") = " VERSION
53                 }
54             ') 2>/dev/null
55 done