Blame SOURCES/gst-p-ugly-cleanup.sh

e5dec0
#!/bin/sh
e5dec0
e5dec0
# Process a gst-plugins-ugly tarball to remove
e5dec0
# unwanted GStreamer plugins.
e5dec0
#
e5dec0
# See https://bugzilla.redhat.com/show_bug.cgi?id=1397261
e5dec0
# for details
e5dec0
#
e5dec0
# Bastien Nocera <bnocera@redhat.com> - 2010
e5dec0
# Yaakov Selkowitz <yselkowi@redhat.com> - 2016
e5dec0
#
e5dec0
e5dec0
SOURCE="$1"
e5dec0
NEW_SOURCE=`echo $SOURCE | sed 's/ugly-/ugly-free-/'`
e5dec0
DIRECTORY=`echo $SOURCE | sed 's/\.tar\.xz//'`
e5dec0
e5dec0
ALLOWED="
e5dec0
xingmux
e5dec0
"
e5dec0
e5dec0
NOT_ALLOWED="
e5dec0
asfdemux
e5dec0
dvdlpcmdec
e5dec0
dvdsub
e5dec0
realmedia
e5dec0
"
e5dec0
e5dec0
error()
e5dec0
{
e5dec0
	MESSAGE=$1
e5dec0
	echo $MESSAGE
e5dec0
	exit 1
e5dec0
}
e5dec0
e5dec0
check_allowed()
e5dec0
{
e5dec0
	MODULE=$1
e5dec0
	for i in $ALLOWED ; do
e5dec0
		if test x$MODULE = x$i ; then
e5dec0
			return 0;
e5dec0
		fi
e5dec0
	done
e5dec0
	# Ignore errors coming from ext/ directory
e5dec0
	# they require external libraries so are ineffective anyway
e5dec0
	return 1;
e5dec0
}
e5dec0
e5dec0
check_not_allowed()
e5dec0
{
e5dec0
	MODULE=$1
e5dec0
	for i in $NOT_ALLOWED ; do
e5dec0
		if test x$MODULE = x$i ; then
e5dec0
			return 0;
e5dec0
		fi
e5dec0
	done
e5dec0
	return 1;
e5dec0
}
e5dec0
e5dec0
rm -rf $DIRECTORY
e5dec0
tar xJf $SOURCE || error "Cannot unpack $SOURCE"
e5dec0
pushd $DIRECTORY > /dev/null || error "Cannot open directory \"$DIRECTORY\""
e5dec0
e5dec0
unknown=""
e5dec0
for subdir in gst ext; do
e5dec0
	for dir in $subdir/* ; do
e5dec0
		# Don't touch non-directories
e5dec0
		if ! [ -d $dir ] ; then
e5dec0
			continue;
e5dec0
		fi
e5dec0
		MODULE=`basename $dir`
e5dec0
		if ( check_not_allowed $MODULE ) ; then
e5dec0
			echo "**** Removing $MODULE ****"
e5dec0
			echo "Removing directory $dir"
e5dec0
			rm -r $dir || error "Cannot remove $dir"
e5dec0
			if grep -q "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac ; then
e5dec0
				echo "Removing element check for $MODULE"
e5dec0
				grep -v "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac > configure.ac.new && mv configure.ac.new configure.ac
e5dec0
			fi
e5dec0
			echo "Removing Makefile generation for $MODULE"
e5dec0
			grep -v "$dir/Makefile" configure.ac > configure.ac.new && mv configure.ac.new configure.ac
e5dec0
			echo "Removing documentation for $MODULE"
e5dec0
			if grep -q "$MODULE" docs/plugins/Makefile.am ; then
e5dec0
				grep -v $dir docs/plugins/Makefile.am > docs/plugins/Makefile.am.new && mv docs/plugins/Makefile.am.new docs/plugins/Makefile.am
e5dec0
			fi
e5dec0
			echo
e5dec0
		elif test $subdir = ext  || test $subdir = sys; then
e5dec0
			# Ignore library or system non-blacklisted plugins
e5dec0
			continue;
e5dec0
		elif ! ( check_allowed $MODULE ) ; then
e5dec0
			echo "Unknown module in $dir"
e5dec0
			unknown="$unknown $dir"
e5dec0
		fi
e5dec0
	done
e5dec0
done
e5dec0
e5dec0
echo "Fixing up AC_CONFIG_SRCDIR"
e5dec0
sed -e '/AC_CONFIG_SRCDIR/s/asfdemux/xingmux/g' configure.ac > configure.ac.new && mv configure.ac.new configure.ac
e5dec0
e5dec0
echo "Fixing up docs/plugins/Makefile.am"
e5dec0
sed -e ':a;N;$!ba;s| *\\\n\n|\n\n|g' docs/plugins/Makefile.am > docs/plugins/Makefile.am.new && mv docs/plugins/Makefile.am.new docs/plugins/Makefile.am
e5dec0
e5dec0
echo
e5dec0
e5dec0
if test "x$unknown" != "x"; then
e5dec0
  echo -n "Aborting due to unknown modules: "
e5dec0
  echo "$unknown" | sed "s/ /\n  /g"
e5dec0
  exit 1
e5dec0
fi
e5dec0
e5dec0
autoreconf
e5dec0
e5dec0
popd > /dev/null
e5dec0
e5dec0
tar cJf $NEW_SOURCE $DIRECTORY
e5dec0
echo "$NEW_SOURCE is ready to use"
e5dec0