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

56b13a
#!/bin/sh
56b13a
56b13a
# Process a gst-plugins-bad tarball to remove
56b13a
# unwanted GStreamer plugins.
56b13a
#
56b13a
# See https://bugzilla.redhat.com/show_bug.cgi?id=532470
56b13a
# for details
56b13a
#
56b13a
# Bastien Nocera <bnocera@redhat.com> - 2010
56b13a
#
56b13a
56b13a
SOURCE="$1"
56b13a
NEW_SOURCE=`echo $SOURCE | sed 's/bad-/bad-free-/'`
56b13a
DIRECTORY=`echo $SOURCE | sed 's/\.tar\.xz//'`
56b13a
56b13a
ALLOWED="
56b13a
aacparse
56b13a
adpcmdec
56b13a
adpcmenc
56b13a
aiff
56b13a
aiffparse
56b13a
amrparse
56b13a
asfmux
56b13a
audioparsers
56b13a
audiovisualizers
56b13a
autoconvert
56b13a
bayer
56b13a
camerabin
56b13a
camerabin2
56b13a
cdxaparse
56b13a
coloreffects
56b13a
colorspace
56b13a
dataurisrc
56b13a
dccp
56b13a
debugutils
56b13a
dtmf
56b13a
faceoverlay
56b13a
festival
56b13a
fieldanalysis
56b13a
freeverb
56b13a
freeze
56b13a
frei0r
56b13a
gaudieffects
56b13a
geometrictransform
56b13a
h264parse
56b13a
hdvparse
56b13a
hls
56b13a
id3tag
56b13a
inter
56b13a
interlace
56b13a
invtelecine
56b13a
ivfparse
56b13a
jpegformat
56b13a
jp2kdecimator
56b13a
legacyresample
56b13a
librfb
56b13a
liveadder
56b13a
mve
56b13a
mpegdemux
56b13a
mpeg4videoparse
56b13a
mpegpsmux
56b13a
mpegtsdemux
56b13a
mpegtsmux
56b13a
mpegvideoparse
56b13a
mxf
56b13a
nsf
56b13a
nuvdemux
56b13a
patchdetect
56b13a
pcapparse
56b13a
pnm
56b13a
qtmux
56b13a
rawparse
56b13a
removesilence
56b13a
rtpmux
56b13a
rtpvp8
56b13a
scaletempo
56b13a
sdi
56b13a
sdp
56b13a
segmentclip
56b13a
selector
56b13a
smooth
56b13a
speed
56b13a
stereo
56b13a
subenc
56b13a
tta
56b13a
valve
56b13a
videofilters
56b13a
videomaxrate
56b13a
videomeasure
56b13a
videoparsers
56b13a
videosignal
56b13a
vmnc
56b13a
y4m
56b13a
"
56b13a
56b13a
NOT_ALLOWED="
56b13a
dvbsuboverlay
56b13a
dvdspu
56b13a
real
56b13a
siren
56b13a
"
56b13a
56b13a
error()
56b13a
{
56b13a
	MESSAGE=$1
56b13a
	echo $MESSAGE
56b13a
	exit 1
56b13a
}
56b13a
56b13a
check_allowed()
56b13a
{
56b13a
	MODULE=$1
56b13a
	for i in $ALLOWED ; do
56b13a
		if test x$MODULE = x$i ; then
56b13a
			return 0;
56b13a
		fi
56b13a
	done
56b13a
	# Ignore errors coming from ext/ directory
56b13a
	# they require external libraries so are ineffective anyway
56b13a
	return 1;
56b13a
}
56b13a
56b13a
check_not_allowed()
56b13a
{
56b13a
	MODULE=$1
56b13a
	for i in $NOT_ALLOWED ; do
56b13a
		if test x$MODULE = x$i ; then
56b13a
			return 0;
56b13a
		fi
56b13a
	done
56b13a
	return 1;
56b13a
}
56b13a
56b13a
rm -rf $DIRECTORY
56b13a
tar xJf $SOURCE || error "Cannot unpack $SOURCE"
56b13a
pushd $DIRECTORY > /dev/null || error "Cannot open directory \"$DIRECTORY\""
56b13a
56b13a
unknown=""
56b13a
for subdir in gst ext sys; do
56b13a
	for dir in $subdir/* ; do
56b13a
		# Don't touch non-directories
56b13a
		if ! [ -d $dir ] ; then
56b13a
			continue;
56b13a
		fi
56b13a
		MODULE=`basename $dir`
56b13a
		if ( check_not_allowed $MODULE ) ; then
56b13a
			echo "**** Removing $MODULE ****"
56b13a
			echo "Removing directory $dir"
56b13a
			rm -r $dir || error "Cannot remove $dir"
56b13a
			if grep -q "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac ; then
56b13a
				echo "Removing element check for $MODULE"
56b13a
				grep -v "AG_GST_CHECK_PLUGIN($MODULE)" configure.ac > configure.ac.new && mv configure.ac.new configure.ac
56b13a
			fi
56b13a
			echo "Removing Makefile generation for $MODULE"
56b13a
			grep -v "$dir/Makefile" configure.ac > configure.ac.new && mv configure.ac.new configure.ac
56b13a
			# Urgh
56b13a
			if test $MODULE = real ; then
56b13a
				grep -v "AG_GST_DISABLE_PLUGIN(real)" configure.ac > configure.ac.new && mv configure.ac.new configure.ac
56b13a
			fi
56b13a
			echo "Removing documentation for $MODULE"
56b13a
			if grep -q "$MODULE" docs/plugins/Makefile.am ; then
56b13a
				grep -v $dir docs/plugins/Makefile.am > docs/plugins/Makefile.am.new && mv docs/plugins/Makefile.am.new docs/plugins/Makefile.am
56b13a
			fi
56b13a
			echo
56b13a
		elif test $subdir = ext  || test $subdir = sys; then
56b13a
			# Ignore library or system non-blacklisted plugins
56b13a
			continue;
56b13a
		elif ! ( check_allowed $MODULE ) ; then
56b13a
			echo "Unknown module in $dir"
56b13a
			unknown="$unknown $dir"
56b13a
		fi
56b13a
	done
56b13a
done
56b13a
56b13a
echo
56b13a
56b13a
if test "x$unknown" != "x"; then
56b13a
  echo -n "Aborting due to unkown modules: "
56b13a
  echo "$unknown" | sed "s/ /\n  /g"
56b13a
  exit 1
56b13a
fi
56b13a
56b13a
autoreconf
56b13a
56b13a
popd > /dev/null
56b13a
56b13a
tar cJf $NEW_SOURCE $DIRECTORY
56b13a
echo "$NEW_SOURCE is ready to use"
56b13a