tools/ffmpeg: add gen-patches.sh script

This script creates or updates the ffmpeg patch files from
the various feature branches and record patch info (repo,
branch, gitrevs) where the changes came from in the commit
message.

The feature branch to process can be specified via command a
line argument, "all" will create/update all known branches.

By default the patches are updated to HEAD of the branches.

If only a single branch is processed the full githash to use
instead of HEAD can be specified as an optional second argument.
This can be used to drop some of the top-most commits in the
branch, eg if later changes cause issues.

The script has to be run in a local ffmpeg git tree. eg:

$ cd ~/ffmpeg-git
$ ~/libreelec-git/tools/ffmpeg/gen-patches.sh all

Additional git commit options (eg -s) can be set via the
GIT_COMMIT_ARGS environment variable

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl 2020-07-09 12:33:50 +02:00
parent d5d98b3f7b
commit 1ff4329545

98
tools/ffmpeg/gen-patches.sh Executable file
View File

@ -0,0 +1,98 @@
#!/bin/bash
# base ffmpeg version
KODI_FFMPEG_REPO="https://github.com/xbmc/FFmpeg"
KODI_FFMPEG_VERSION="4.3-Matrix-Alpha1"
ALL_FEATURE_SETS="v4l2-drmprime v4l2-request libreelec rpi"
if [ $# -eq 0 ]; then
echo "usage: $0 all|featureset [githash]"
echo "available feature sets: ${ALL_FEATURE_SETS}"
exit 1
fi
FFMPEG_ROOT="$(pwd)"
LE_ROOT="$(cd $(dirname $0)/../.. ; pwd)"
# get kodi's ffmpeg version
git fetch "${KODI_FFMPEG_REPO}" "${KODI_FFMPEG_VERSION}"
KODI_REV=$(git rev-parse FETCH_HEAD)
create_patch() {
FEATURE_SET="$1"
REFTYPE="branch"
case "${FEATURE_SET}" in
v4l2-drmprime)
REPO="https://github.com/lrusak/FFmpeg"
REFSPEC="v4l2-drmprime-v5"
;;
v4l2-request)
REPO="https://github.com/Kwiboo/FFmpeg"
REFSPEC="v4l2-request-hwaccel-4.3"
;;
libreelec)
REPO="https://github.com/LibreELEC/FFmpeg"
REFSPEC="4.3-libreelec-misc"
;;
rpi)
REPO="https://github.com/jc-kynesim/rpi-ffmpeg"
REFSPEC="test/4.3/kodi_main"
;;
*)
echo "illegal feature set ${FEATURE_SET}"
exit 1
;;
esac
PATCH_DIR="packages/multimedia/ffmpeg/patches/${FEATURE_SET}"
PATCH_FILE="${PATCH_DIR}/ffmpeg-001-${FEATURE_SET}.patch"
mkdir -p "${LE_ROOT}/${PATCH_DIR}"
git fetch "${REPO}" "${REFSPEC}"
if [ $# -ge 2 ]; then
REV="$2"
else
REV=$(git rev-parse FETCH_HEAD)
fi
BASE_REV=$(git merge-base "${KODI_REV}" "${REV}")
if [ -f "${LE_ROOT}/${PATCH_FILE}" ]; then
ACTION="update"
else
ACTION="create"
fi
if [ "${FEATURE_SET}" = "rpi" ]; then
# branch has non-linear history, format-patch doesn't work
git diff "${BASE_REV}..${REV}" > "${LE_ROOT}/${PATCH_FILE}"
else
git format-patch --stdout --no-signature "${BASE_REV}..${REV}" > "${LE_ROOT}/${PATCH_FILE}"
fi
MSG=$(mktemp)
cat << EOF > "${MSG}"
ffmpeg: ${ACTION} ${FEATURE_SET} patch
Patch created using revisions ${BASE_REV:0:7}..${REV:0:7}
from ${REFTYPE} ${REFSPEC} of ${REPO}
EOF
cd "${LE_ROOT}"
git add "${PATCH_FILE}"
git commit -F "${MSG}" ${GIT_COMMIT_ARGS}
cd "${FFMPEG_ROOT}"
rm "${MSG}"
}
if [ "$1" = "all" ]; then
for SET in ${ALL_FEATURE_SETS}; do
create_patch "${SET}"
done
else
create_patch "$@"
fi