Blame scripts/mono-find-requires

2ff057
#!/bin/bash
2ff057
#
2ff057
# mono-find-requires
2ff057
#
2ff057
# Authors:
2ff057
#       Ben Maurer (bmaurer@ximian.com)
2ff057
#
2ff057
# (C) 2005 Novell (http://www.novell.com)
2ff057
#
2ff057
# Args: builddir buildroot libdir
2ff057
2ff057
IFS=$'\n'
2ff057
filelist=($(grep -Ev '/usr/doc/|/usr/share/doc/'))
2ff057
monolist=($(printf "%s\n" "${filelist[@]}" | grep -E "\\.(exe|dll)\$"))
2ff057
2ff057
# If monodis is in the package being installed, use that one
2ff057
# This is to support building mono
2ff057
build_bindir="$2/usr/bin"
2ff057
build_libdir="$2$3"
2ff057
2ff057
if [ -x $build_bindir/monodis ]; then
2ff057
    monodis="$build_bindir/monodis"
2ff057
    export LD_LIBRARY_PATH=$build_libdir${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
2ff057
elif [ -x /usr/bin/monodis ]; then
2ff057
    monodis="/usr/bin/monodis"
2ff057
else
2ff057
    exit 0;
2ff057
fi
2ff057
2ff057
export MONO_SHARED_DIR=$1
2ff057
2ff057
REQUIRES=$(
2ff057
	for i in "${monolist[@]}"; do
2ff057
		($monodis --assemblyref $i | awk '
2ff057
			BEGIN { START=0; LIBNAME=""; VERSION=""; }
2ff057
			(START==0) && /^[0-9]+: Version=/ {
2ff057
				START=1;
2ff057
				sub(/Version=/, "", $2);
2ff057
				VERSION=$2
2ff057
			}
2ff057
	
2ff057
			(START==1) && /^\tName=/ {
2ff057
				sub(/Name=/, "", $1);
2ff057
				LIBNAME=$1
2ff057
	
2ff057
				print "mono(" LIBNAME ") = " VERSION
2ff057
				START=0
2ff057
			}
2ff057
		    ') 2> /dev/null
2ff057
	done
2ff057
)
2ff057
2ff057
PROVIDES=$(
2ff057
	for i in "${monolist[@]}"; do
2ff057
		($monodis --assembly $i | awk '
2ff057
			BEGIN { LIBNAME=""; VERSION=""; }
2ff057
			/^Version:/ { VERSION=$2 }
2ff057
			/^Name:/    { LIBNAME=$2 }
2ff057
			END {
2ff057
				if (VERSION && LIBNAME)
2ff057
					print "mono(" LIBNAME ") = " VERSION
2ff057
			}
2ff057
		    ') 2>/dev/null
2ff057
	done
2ff057
)
2ff057
#
2ff057
# This is a little magic trick to get all REQUIRES that are not
2ff057
# in PROVIDES. While RPM functions correctly when such deps exist,
2ff057
# they make the metadata a bit bloated.
2ff057
#
2ff057
2ff057
# Filter out dups from both lists
2ff057
REQUIRES=$(echo "$REQUIRES" | sort | uniq)
2ff057
PROVIDES=$(echo "$PROVIDES" | sort | uniq)
2ff057
2ff057
#
2ff057
# Get a list of elements that exist in exactly one of PROVIDES or REQUIRES
2ff057
#
2ff057
UNIQ=$(echo "$PROVIDES
2ff057
$REQUIRES" | sort | uniq -u)
2ff057
2ff057
#
2ff057
# Of those, only chose the ones that are in REQUIRES
2ff057
#
2ff057
echo "$UNIQ
2ff057
$REQUIRES" | sort | uniq -d