Blame ffmpeg_find_free_source_headers.sh

45f894e
#!/bin/bash
45f894e
45f894e
# Script to identify trivial new headers for new sources added
45f894e
# Requires: bash, coreutils, tar, xz
45f894e
# Author: Neal Gompa <ngompa@fedoraproject.org>
45f894e
#
45f894e
# This program is free software: you can redistribute it and/or modify
45f894e
# it under the terms of the GNU General Public License as published by
45f894e
# the Free Software Foundation, either version 3 of the License, or
45f894e
# (at your option) any later version.
45f894e
#
45f894e
# This program is distributed in the hope that it will be useful,
45f894e
# but WITHOUT ANY WARRANTY; without even the implied warranty of
45f894e
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45f894e
# GNU General Public License for more details.
45f894e
#
45f894e
# You should have received a copy of the GNU General Public License
45f894e
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
45f894e
45f894e
45f894e
FFMPEG_VERSION=$1
45f894e
FF_SRC_DIFF=$2
45f894e
45f894e
if [ -z $1 -o -z $2 ]; then
45f894e
	echo "No arguments provided, quitting!"
45f894e
	exit 1
45f894e
fi
45f894e
45f894e
echo "Setting up..."
45f894e
# Get local directory
45f894e
LOCALDIR=$(realpath $(dirname $0))
45f894e
45f894e
# Create working area
45f894e
TMPDIR=$(mktemp -d /tmp/ffsrchdrsXXXXXX)
45f894e
mkdir -pv $TMPDIR
45f894e
45f894e
# Extract ffmpeg sources
45f894e
if [ ! -f "ffmpeg-${FFMPEG_VERSION}.tar.xz" ]; then
45f894e
	echo "No ffmpeg tarball, exiting!"
45f894e
	exit 2
45f894e
fi
45f894e
if [ ! -f "$FF_SRC_DIFF" ]; then
45f894e
	echo "No ffmpeg sources diff, exiting!"
45f894e
	exit 2
45f894e
fi
45f894e
echo "Extracting upstream ffmpeg sources..."
45f894e
tar -C ${TMPDIR} -xf ffmpeg-${FFMPEG_VERSION}.tar.xz
45f894e
45f894e
echo "Generating header list from diff..."
45f894e
# Read in ffmpeg_free_sources diff
45f894e
while IFS= read -r line
45f894e
do
45f894e
	if [[ $line = \+* ]]; then
45f894e
		ffmpeg_src_file="${line:1}"
45f894e
		if [ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_src_file}" ]; then
45f894e
			ffmpeg_hdr_file="${ffmpeg_src_file%.c}.h"
45f894e
			[ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_hdr_file}" ] && echo "${ffmpeg_hdr_file}" >> ${LOCALDIR}/ffmpeg_free_sources
45f894e
			ffmpeg_hdr_file="${ffmpeg_src_file%.c}_cb.h"
45f894e
			[ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_hdr_file}" ] && echo "${ffmpeg_hdr_file}" >> ${LOCALDIR}/ffmpeg_free_sources
45f894e
			ffmpeg_hdr_file="${ffmpeg_src_file%.c}data.h"
45f894e
			[ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_hdr_file}" ] && echo "${ffmpeg_hdr_file}" >> ${LOCALDIR}/ffmpeg_free_sources
45f894e
			ffmpeg_hdr_file="${ffmpeg_src_file%.c}_data.h"
45f894e
			[ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_hdr_file}" ] && echo "${ffmpeg_hdr_file}" >> ${LOCALDIR}/ffmpeg_free_sources
45f894e
			ffmpeg_hdr_file="${ffmpeg_src_file%.c}_tablegen.h"
45f894e
			[ -f "${TMPDIR}/ffmpeg-${FFMPEG_VERSION}/${ffmpeg_hdr_file}" ] && echo "${ffmpeg_hdr_file}" >> ${LOCALDIR}/ffmpeg_free_sources
45f894e
		fi
45f894e
	fi
45f894e
done < <(cat $FF_SRC_DIFF)
45f894e
45f894e
# Clean up
45f894e
echo "Clean up workspace..."
45f894e
rm -rf ${TMPDIR}