Merge pull request #1843 from info-lvsys/patch-1
[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 # Set the prefix, unless it is overriden (used when building mono rpms)
21 : ${prefix=@prefix@}
22
23 libdir=$prefix/@reloc_libdir@
24 bindir=$prefix/bin
25
26 # Bail out if monodis or libmono is missing
27 if [ ! -x $bindir/monodis ] || [ ! -f $libdir/libmono-2.0.so.1 ] ; then
28         echo "monodis missing or unusable, exiting..." 1>&2
29         exit 1
30 fi
31
32
33 # set LD_LIBRARY_PATH to ensure that libmono is found
34 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
35 # and set MONO_PATH to ensure that mscorlib.dll can be found
36 export MONO_PATH=$prefix/lib/mono/4.5
37
38 for i in "${monolist[@]}"; do
39         ($bindir/monodis --assembly $i | awk '
40                 BEGIN { LIBNAME=""; VERSION=""; }
41                 /^Version:/ { VERSION=$2 }
42                 /^Name:/    { LIBNAME=$2 }
43                 END {
44                         if (LIBNAME ~ /^policy/) {
45                                 cnt = split(LIBNAME, toks, ".")
46                                 VERSION=toks[2] "." toks[3] ".0.0"
47                                 LIBNAME=""
48                                 for (i=4; i<= cnt; i++)
49                                         LIBNAME = (LIBNAME toks[i] ".")
50                                 LIBNAME=substr(LIBNAME, 1, length(LIBNAME)-1)
51                         }
52                         if (VERSION && LIBNAME)
53                                 print "mono(" LIBNAME ") = " VERSION
54                 }
55             ') 2>/dev/null
56 done