In Test/System.Windows.Forms:
[mono-project.git] / scripts / mono-find-requires.in
blob5c9edddf391a71f0ab36d68eeb9dfc65cbd015db
1 #!/bin/bash
3 # mono-find-requires
5 # Authors:
6 # Ben Maurer (bmaurer@ximian.com)
8 # (C) 2005 Novell (http://www.novell.com)
11 IFS=$'\n'
12 filelist=($(grep -Ev '/usr/doc/|/usr/share/doc/'))
13 monolist=($(printf "%s\n" "${filelist[@]}" | egrep "\\.(exe|dll)\$"))
15 a=`which "$0"`
16 d=`dirname "$a"`
18 # Set the prefix, unless it is overriden (used when building mono rpms)
19 : ${prefix=$d/..}
21 exec_prefix=$d/..
22 libdir=$prefix/@reloc_libdir@
23 bindir=$d
25 # Bail out if monodis or libmono is missing
26 if [ ! -x $bindir/monodis ] || [ ! -f $libdir/libmono.so ] ; then
27 echo "monodis missing or unusable, exiting..."
28 exit 1
32 # set LD_LIBRARY_PATH to ensure that libmono.so is found
33 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
35 REQUIRES=$(
36 for i in "${monolist[@]}"; do
37 ($bindir/monodis --assemblyref $i | awk '
38 BEGIN { START=0; LIBNAME=""; VERSION=""; }
39 (START==0) && /^[0-9]+: Version=/ {
40 START=1;
41 sub(/Version=/, "", $2);
42 VERSION=$2
45 (START==1) && /^\tName=/ {
46 sub(/Name=/, "", $1);
47 LIBNAME=$1
48 # Allow rpm deps to be resolved for 1.0 profile version
49 if (VERSION=="1.0.3300.0")
50 OP=">="
51 else
52 OP="="
53 print "mono(" LIBNAME ") " OP " " VERSION
54 START=0
56 ') 2> /dev/null
57 done
60 PROVIDES=$(
61 for i in "${monolist[@]}"; do
62 ($bindir/monodis --assembly $i | awk '
63 BEGIN { LIBNAME=""; VERSION=""; }
64 /^Version:/ { VERSION=$2 }
65 /^Name:/ { LIBNAME=$2 }
66 END {
67 if (VERSION && LIBNAME)
68 print "mono(" LIBNAME ") = " VERSION
70 ') 2>/dev/null
71 done
74 # This is a little magic trick to get all REQUIRES that are not
75 # in PROVIDES. While RPM functions correctly when such deps exist,
76 # they make the metadata a bit bloated.
79 # Filter out dups from both lists
80 REQUIRES=$(echo "$REQUIRES" | sort | uniq)
81 PROVIDES=$(echo "$PROVIDES" | sort | uniq)
84 # Get a list of elements that exist in exactly one of PROVIDES or REQUIRES
86 UNIQ=$(echo "$PROVIDES
87 $REQUIRES" | sort | uniq -u)
90 # Of those, only choose the ones that are in REQUIRES
92 echo "$UNIQ
93 $REQUIRES" | sort | uniq -d