teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame mono-find-requires

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