add project versioning

This commit is contained in:
2025-08-09 16:04:36 -05:00
parent 390d50e8cb
commit 96ae2fd553
3 changed files with 63 additions and 10 deletions

View File

@@ -281,6 +281,10 @@ do_build() {
local build="${1:-''}"
download_release "${build}" || return 1
get_build_conf "${build}" || return 1
# add build configuration to FFMPEG_BUILDER_INFO
FFMPEG_BUILDER_INFO+=("${build}=${ver}")
set_compile_opts || return 1
for dep in "${deps[@]}"; do
do_build "${dep}" || return 1
@@ -315,6 +319,9 @@ build() {
fi
test -f "${testfile}" && ${SUDO_MODIFY} rm "${testfile}"
# embed this project's enables/versions
# into ffmpeg with this variable
FFMPEG_BUILDER_INFO=("ffmpeg-builder=$(cd "${REPO_DIR}" && git rev-parse HEAD)")
for build in "${FFMPEG_ENABLES[@]}"; do
do_build "${build}" || return 1
done
@@ -464,11 +471,47 @@ build_libopus() {
${SUDO_MODIFY} make -j"${JOBS}" install || return 1
return 0
}
add_project_versioning_to_ffmpeg() {
local optFile
optFile="$(command ls ./**/ffmpeg_opt.c)"
if [[ ! $? -eq 0 || ${optFile} == '' || ! -f ${optFile} ]]; then
echo_fail "could not find ffmpeg_opt.c to add project versioning"
fi
local lineNum=0
local searchFor='Universal media converter\n'
local foundUsageStart=0
while read -r line; do
lineNum=$((lineNum + 1))
if line_contains "${line}" "${searchFor}"; then
foundUsageStart=1
continue
fi
if [[ ${foundUsageStart} -eq 1 ]]; then
if line_starts_with "${line}" '}'; then
break
fi
fi
done <"${optFile}"
echo_info "found ${line} on ${lineNum}"
for info in "${FFMPEG_BUILDER_INFO[@]}"; do
local newline="\ av_log(NULL, AV_LOG_INFO, \"${info}\\\n\");"
sed -i "${lineNum}i ${newline}" "${optFile}" || return 1
lineNum=$((lineNum + 1))
done
local newline="\ av_log(NULL, AV_LOG_INFO, \"\\\n\");"
sed -i "${lineNum}i ${newline}" "${optFile}" || return 1
return 0
}
build_ffmpeg() {
for enable in "${FFMPEG_ENABLES[@]}"; do
test "${enable}" == 'libsvtav1_psy' && enable='libsvtav1'
CONFIGURE_FLAGS+=("--enable-${enable}")
done
add_project_versioning_to_ffmpeg || return 1
./configure \
"${CONFIGURE_FLAGS[@]}" \
"${FFMPEG_EXTRA_FLAGS[@]}" \

View File

@@ -148,3 +148,13 @@ line_contains() {
return 1
fi
}
line_starts_with() {
local line="$1"
local substr="$2"
if [[ $line == "${substr}"* ]]; then
return 0
else
return 1
fi
}

View File

@@ -198,16 +198,6 @@ docker_run_image() {
for distro in "${DISTROS[@]}"; do
image_tag="$(set_distro_image_tag "${distro}")"
# if a docker registry is defined, pull from it
if [[ ${DOCKER_REGISTRY} != '' ]]; then
docker_login || return 1
docker pull \
"${DOCKER_REGISTRY}/${image_tag}"
docker tag "${DOCKER_REGISTRY}/${image_tag}" "${image_tag}"
fi
echo_info "running ffmpeg build for ${image_tag}"
# TODO REMOVE
if is_root_owned "${IGN_DIR}"; then
docker run \
@@ -229,6 +219,16 @@ docker_run_image() {
rm -rf "${DOCKER_WORKDIR}"/gitignore
fi
# if a docker registry is defined, pull from it
if [[ ${DOCKER_REGISTRY} != '' ]]; then
docker_login || return 1
docker pull \
"${DOCKER_REGISTRY}/${image_tag}"
docker tag "${DOCKER_REGISTRY}/${image_tag}" "${image_tag}"
fi
echo_info "running ffmpeg build for ${image_tag}"
docker run \
"${DOCKER_RUN_FLAGS[@]}" \
-u "$(id -u):$(id -g)" \