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