Merge pull request #5714 from alexischr/update_bockbuild
[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 if [ -n "$DISABLE_MONO_RPM_AUTO_DEPS" ]; then exit 0; fi
12
13 IFS=$'\n'
14 filelist=($(grep -Ev '/usr/doc/|/usr/share/doc/'))
15 monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$"))
16
17 # Only include files with /gac/ in path
18 #  (Allows packages to contain private assemblies that don't conflict with other packages)
19 monolist=($(printf "%s\n" "${monolist[@]}" | egrep "/gac/"))
20 # Disabled... see ChangeLog
21
22 # Set the prefix, unless it is overriden (used when building mono rpms)
23 : ${prefix=@prefix@}
24
25 libdir=$prefix/@reloc_libdir@
26 bindir=$prefix/bin
27
28 # Bail out if monodis or libmono is missing
29 if [ ! -x $bindir/monodis ] || [ ! -f $libdir/libmono-2.0.so.1 ] ; then
30         echo "monodis missing or unusable, exiting..." 1>&2
31         exit 1
32 fi
33
34
35 # set LD_LIBRARY_PATH to ensure that libmono is found
36 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
37 # and set MONO_PATH to ensure that mscorlib.dll can be found
38 export MONO_PATH=$prefix/lib/mono/4.5
39
40 for i in "${monolist[@]}"; do
41         ($bindir/monodis --assembly $i | awk '
42                 BEGIN { LIBNAME=""; VERSION=""; }
43                 /^Version:/ { VERSION=$2 }
44                 /^Name:/    { LIBNAME=$2 }
45                 END {
46                         if (LIBNAME ~ /^policy/) {
47                                 cnt = split(LIBNAME, toks, ".")
48                                 VERSION=toks[2] "." toks[3] ".0.0"
49                                 LIBNAME=""
50                                 for (i=4; i<= cnt; i++)
51                                         LIBNAME = (LIBNAME toks[i] ".")
52                                 LIBNAME=substr(LIBNAME, 1, length(LIBNAME)-1)
53                         }
54                         if (VERSION && LIBNAME)
55                                 print "mono(" LIBNAME ") = " VERSION
56                 }
57             ') 2>/dev/null
58 done