File precheckin_cripple_tarball.sh of Package libavutil
# The following source parts of ffmpeg may not be distributed for legal
# reasons
# Thus we have to cripple the source tree in a way that it still builds.
# Find source tarball + unpack
tmp="$(mktemp)"
trap 'rm -f $tmp; echo 1>&2 "$0 failed"' EXIT
tarsource="$(echo ffmpeg-*[0-9].tar.bz2)"
if [ ! -s "$tarsource" ] ; then
echo "Error: cannot find source tarball"
exit 1
fi
tarbase="${tarsource%.tar.bz2}"
tardest="$tarbase-crippled.tar.bz2"
rm -rf ffmpeg-*-crippled.tar.bz2
# Cripple source
echo 1>&2 "Crippling..."
files=$(tar -tf ${tarsource} | grep \
-e '^ffmpeg-[0-9\.]\+/libavresample/$' \
-e '^ffmpeg-[0-9\.]\+/libavcodec/$' \
-e '^ffmpeg-[0-9\.]\+/libavdevice/$' \
-e '^ffmpeg-[0-9\.]\+/libavfilter/$' \
-e '^ffmpeg-[0-9\.]\+/libavformat/$' \
-e '^ffmpeg-[0-9\.]\+/libpostproc/$' \
-e '^ffmpeg-[0-9\.]\+/libswresample/$' \
-e '^ffmpeg-[0-9\.]\+/libswscale/$' \
-e '^ffmpeg-[0-9\.]\+/[^/]*.[ch]$' \
)
bzip2 -cd ${tarsource} > ${tmp}
tar --delete --file=${tmp} ${files}
bzip2 -c ${tmp} > ${tardest}
echo 1>&2 ""
echo 1>&2 "Successfully crippled tarball. :-("
echo 1>&2 ""
rm -rf $tmp
trap - EXIT
exit 0