merge -r 60439:60440
[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
19 a=`which "$0"`
20 d=`dirname "$a"`
21
22 # Set the prefix, unless it is overriden (used when building mono rpms)
23 : ${prefix=$d/..}
24
25 exec_prefix=$d/..
26 libdir=$prefix/@reloc_libdir@
27 bindir=$d
28
29 [ -x $bindir/monodis ] || exit 0;
30 [ -f $libdir/libmono.so ] || exit 0;
31
32
33 # set LD_LIBRARY_PATH to ensure that libmono.so is found
34 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
35
36 for i in "${monolist[@]}"; do
37         ($bindir/monodis --assembly $i | awk '
38                 BEGIN { LIBNAME=""; VERSION=""; }
39                 /^Version:/ { VERSION=$2 }
40                 /^Name:/    { LIBNAME=$2 }
41                 END {
42                         if (LIBNAME ~ /^policy/) {
43                                 cnt = split(LIBNAME, toks, ".")
44                                 VERSION=toks[2] "." toks[3] ".0.0"
45                                 LIBNAME=""
46                                 for (i=4; i<= cnt; i++)
47                                         LIBNAME = (LIBNAME toks[i] ".")
48                                 LIBNAME=substr(LIBNAME, 1, length(LIBNAME)-1)
49                         }
50                         if (VERSION && LIBNAME)
51                                 print "mono(" LIBNAME ") = " VERSION
52                 }
53             ') 2>/dev/null
54 done