#!/bin/bash

# Generate list of features provided by devstudio
devstudio=/opt/rh/rh-eclipse46/root/usr/share/eclipse/droplets/devstudio/eclipse
for f in $devstudio/features/* ; do
	devfeatures="$devfeatures $(basename $f | rev | cut -d_ -f1 --complement | rev)"
done

# Check for duplicates provided by other packages
archful=/opt/rh/rh-eclipse46/root/usr/lib64/eclipse
noarch=/opt/rh/rh-eclipse46/root/usr/share/eclipse
for f in $archful/features/* $archful/droplets/*/eclipse/features/* $noarch/droplets/*/eclipse/features/* ; do
	if [ -e "$f" ] ; then
		feature=$(basename $f | rev | cut -d_ -f1 --complement | rev)
		for devfeature in $devfeatures ; do
			if [ "$feature" == "$devfeature" ] ; then
				pkg=$(rpm -qf $f | rev | cut -d- -f1,2 --complement | rev)
				if [ "$pkg" != "rh-eclipse46-devstudio" ] ; then
					echo "$feature is provided by $pkg"
				fi
			fi
		done
	fi
done
