2005-09-05 Geoff Norton <gnorton@customerdna.com>
[mono-project.git] / scripts / mono-find-requires.in
blob46c939ef97068305a4668a2c7a5b9681f1aa064c
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 # Set the prefix, unless it is overriden (used when building mono rpms)
16 : ${prefix=@prefix@}
18 exec_prefix=@exec_prefix@
19 libdir=@libdir@
20 bindir=@bindir@
22 [ -x $bindir/monodis ] || exit 0;
23 [ -f $libdir/libmono.so ] || exit 0;
26 # set LD_LIBRARY_PATH to ensure that libmono.so is found
27 export LD_LIBRARY_PATH=$libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
29 REQUIRES=$(
30 for i in "${monolist[@]}"; do
31 ($bindir/monodis --assemblyref $i | awk '
32 BEGIN { START=0; LIBNAME=""; VERSION=""; }
33 (START==0) && /^[0-9]+: Version=/ {
34 START=1;
35 sub(/Version=/, "", $2);
36 VERSION=$2
39 (START==1) && /^\tName=/ {
40 sub(/Name=/, "", $1);
41 LIBNAME=$1
43 print "mono(" LIBNAME ") = " VERSION
44 START=0
46 ') 2> /dev/null
47 done
50 PROVIDES=$(
51 for i in "${monolist[@]}"; do
52 ($bindir/monodis --assembly $i | awk '
53 BEGIN { LIBNAME=""; VERSION=""; }
54 /^Version:/ { VERSION=$2 }
55 /^Name:/ { LIBNAME=$2 }
56 END {
57 if (VERSION && LIBNAME)
58 print "mono(" LIBNAME ") = " VERSION
60 ') 2>/dev/null
61 done
64 # This is a little magic trick to get all REQUIRES that are not
65 # in PROVIDES. While RPM functions correctly when such deps exist,
66 # they make the metadata a bit bloated.
69 # Filter out dups from both lists
70 REQUIRES=$(echo "$REQUIRES" | sort | uniq)
71 PROVIDES=$(echo "$PROVIDES" | sort | uniq)
74 # Get a list of elements that exist in exactly one of PROVIDES or REQUIRES
76 UNIQ=$(echo "$PROVIDES
77 $REQUIRES" | sort | uniq -u)
80 # Of those, only chose the ones that are in REQUIRES
82 echo "$UNIQ
83 $REQUIRES" | sort | uniq -d