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

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