Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Apr 5, 2024
2 parents a09b5cd + 0ee6cfa commit 845f514
Show file tree
Hide file tree
Showing 141 changed files with 908 additions and 978 deletions.
62 changes: 38 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkit.toml
buildkitd-config: .github/buildkit.toml
- name: Login to Docker
uses: docker/login-action@v3
with:
Expand All @@ -34,11 +34,8 @@ jobs:
id: imagename
run: |
IMG="${GITHUB_REPOSITORY,,}/base"
DLIMG="${GITHUB_REPOSITORY,,}/dl_cache"
echo "name=ghcr.io/${IMG/ /-}" >> $GITHUB_OUTPUT
echo "rawname=${IMG/ /-}" >> $GITHUB_OUTPUT
echo "dlname=ghcr.io/${DLIMG/ /-}" >> $GITHUB_OUTPUT
echo "dlrawname=${DLIMG/ /-}" >> $GITHUB_OUTPUT
- name: Stop Commands
run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
- name: Build target base image
Expand All @@ -51,23 +48,22 @@ jobs:
tags: ${{ steps.imagename.outputs.name }}:latest
cache-to: type=registry,mode=max,ref=${{ steps.imagename.outputs.name }}:cache
cache-from: type=registry,ref=${{ steps.imagename.outputs.name }}:cache
- name: Generate download cache Dockerfile
- name: Get download cache key
id: dl_cache
run: |
./generate.sh dl only
echo "dltagname=$(./util/get_dl_cache_tag.sh)" >> $GITHUB_OUTPUT
cat Dockerfile.dl
- name: Build download cache image
uses: docker/build-push-action@v5
- name: Cache
uses: actions/cache@v4
with:
context: .
file: Dockerfile.dl
pull: true
push: true
provenance: false
tags: ${{ steps.imagename.outputs.dlname }}:${{ steps.dl_cache.outputs.dltagname }}
cache-to: type=registry,mode=max,ref=${{ steps.imagename.outputs.dlname }}:cache
cache-from: type=registry,ref=${{ steps.imagename.outputs.dlname }}:cache
path: .cache/downloads
key: download-cache-${{ steps.dl_cache.outputs.dltagname }}
restore-keys: |
download-cache-
- name: Update Cache
run: |
set -e
./download.sh
./util/clean_cache.sh
build_target_bases:
name: Build target base image
needs: build_base
Expand All @@ -88,7 +84,7 @@ jobs:
- name: Install buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkit.toml
buildkitd-config: .github/buildkit.toml
- name: Login to Docker
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -138,23 +134,33 @@ jobs:
- name: Install buildx
uses: docker/setup-buildx-action@v3
with:
config: .github/buildkit.toml
buildkitd-config: .github/buildkit.toml
- name: Login to Docker
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Generate Dockerfile
run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Image Name
id: imagename
run: |
IMG="${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
echo "name=ghcr.io/${IMG/ /-}" >> $GITHUB_OUTPUT
echo "rawname=${IMG/ /-}" >> $GITHUB_OUTPUT
- name: Get download cache key
id: dl_cache
run: |
echo "dltagname=$(./util/get_dl_cache_tag.sh)" >> $GITHUB_OUTPUT
- name: Stop Commands
run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
- name: Generate Dockerfile
run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Cache
uses: actions/cache/restore@v4
with:
path: .cache/downloads
key: download-cache-${{ steps.dl_cache.outputs.dltagname }}
fail-on-cache-miss: true
- name: Build target base image
uses: docker/build-push-action@v5
with:
Expand Down Expand Up @@ -194,10 +200,16 @@ jobs:
run: |
T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
./build.sh ${{ matrix.target }} ${{ matrix.variant }}
- name: Replace spaces in string
id: strs
run: |
SLUG="${{ matrix.target }}-${{ matrix.variant }}"
echo "artifact_slug=${SLUG// /-}" >> $GITHUB_OUTPUT
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ffmpeg-${{ matrix.target }}
name: ffmpeg-${{ steps.strs.outputs.artifact_slug }}
overwrite: true
path: artifacts/*
publish_release:
name: Publish release
Expand All @@ -212,8 +224,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
pattern: ffmpeg-*
merge-multiple: true
path: artifacts
- name: Deploy
run: ./deploy.sh ./artifacts/**/*
Expand Down
2 changes: 2 additions & 0 deletions addins/7.0.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
GIT_BRANCH="release/7.0"
40 changes: 6 additions & 34 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,19 @@ shopt -s globstar
cd "$(dirname "$0")"
source util/vars.sh

get_output() {
(
SELF="$1"
source $1
if ffbuild_enabled; then
ffbuild_$2 || exit 0
else
ffbuild_un$2 || exit 0
fi
)
}

source "variants/${TARGET}-${VARIANT}.sh"

for addin in ${ADDINS[*]}; do
source "addins/${addin}.sh"
done

export FFBUILD_PREFIX="$(docker run --rm "$IMAGE" bash -c 'echo $FFBUILD_PREFIX')"

for script in scripts.d/**/*.sh; do
FF_CONFIGURE+=" $(get_output $script configure)"
FF_CFLAGS+=" $(get_output $script cflags)"
FF_CXXFLAGS+=" $(get_output $script cxxflags)"
FF_LDFLAGS+=" $(get_output $script ldflags)"
FF_LDEXEFLAGS+=" $(get_output $script ldexeflags)"
FF_LIBS+=" $(get_output $script libs)"
done

FF_CONFIGURE="$(xargs <<< "$FF_CONFIGURE")"
FF_CFLAGS="$(xargs <<< "$FF_CFLAGS")"
FF_CXXFLAGS="$(xargs <<< "$FF_CXXFLAGS")"
FF_LDFLAGS="$(xargs <<< "$FF_LDFLAGS")"
FF_LDEXEFLAGS="$(xargs <<< "$FF_LDEXEFLAGS")"
FF_LIBS="$(xargs <<< "$FF_LIBS")"

TESTFILE="uidtestfile"
rm -f "$TESTFILE"
docker run --rm -v "$PWD:/uidtestdir" "$IMAGE" touch "/uidtestdir/$TESTFILE"
DOCKERUID="$(stat -c "%u" "$TESTFILE")"
rm -f "$TESTFILE"
[[ "$DOCKERUID" != "$(id -u)" ]] && UIDARGS=( -u "$(id -u):$(id -g)" ) || UIDARGS=()
unset TESTFILE

rm -rf ffbuild
mkdir ffbuild
Expand All @@ -66,17 +37,18 @@ cat <<EOF >"$BUILD_SCRIPT"
git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg
cd ffmpeg
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS $FF_CONFIGURE \
--extra-cflags='$FF_CFLAGS' --extra-cxxflags='$FF_CXXFLAGS' \
--extra-ldflags='$FF_LDFLAGS' --extra-ldexeflags='$FF_LDEXEFLAGS' --extra-libs='$FF_LIBS' \
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS \$FF_CONFIGURE \
--extra-cflags="\$FF_CFLAGS" --extra-cxxflags="\$FF_CXXFLAGS" --extra-libs="\$FF_LIBS" \
--extra-ldflags="\$FF_LDFLAGS" --extra-ldexeflags="\$FF_LDEXEFLAGS" \
--cc="\$CC" --cxx="\$CXX" --ar="\$AR" --ranlib="\$RANLIB" --nm="\$NM" \
--extra-version="\$(date +%Y%m%d)"
make -j\$(nproc) V=1
make install install-doc
EOF

[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""

docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v $PWD/ffbuild:/ffbuild -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh
docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v "$PWD/ffbuild":/ffbuild -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh

mkdir -p artifacts
ARTIFACTS_PATH="$PWD/artifacts"
Expand Down
65 changes: 65 additions & 0 deletions download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash
set -xe
cd "$(dirname "$0")"
source util/vars.sh dl only

TESTFILE="uidtestfile"
rm -f "$TESTFILE"
docker run --rm -v "$PWD:/uidtestdir" "${REGISTRY}/${REPO}/base:latest" touch "/uidtestdir/$TESTFILE"
DOCKERUID="$(stat -c "%u" "$TESTFILE")"
rm -f "$TESTFILE"
[[ "$DOCKERUID" != "$(id -u)" ]] && UIDARGS=( -u "$(id -u):$(id -g)" ) || UIDARGS=()
unset TESTFILE

[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""

DL_SCRIPT_DIR="$(mktemp -d)"
trap "rm -rf -- '$DL_SCRIPT_DIR'" EXIT

mkdir -p "${PWD}"/.cache/downloads

for STAGE in scripts.d/*.sh scripts.d/*/*.sh; do
STAGENAME="$(basename "$STAGE" | sed 's/.sh$//')"

cat <<-EOF >"${DL_SCRIPT_DIR}/${STAGENAME}.sh"
set -xe -o pipefail
shopt -s dotglob
source /dl_functions.sh
source "/$STAGE"
STG="\$(ffbuild_dockerdl)"
if [[ -z "\$STG" ]]; then
exit 0
fi
DLHASH="\$(sha256sum <<<"\$STG" | cut -d" " -f1)"
DLNAME="$STAGENAME"
if [[ "$1" == "hashonly" ]]; then
echo "\$DLHASH"
exit 0
fi
TGT="/dldir/\${DLNAME}_\${DLHASH}.tar.xz"
if [[ -f "\$TGT" ]]; then
rm -f "/dldir/\${DLNAME}.tar.xz"
ln -s "\${DLNAME}_\${DLHASH}.tar.xz" "/dldir/\${DLNAME}.tar.xz"
exit 0
fi
WORKDIR="\$(mktemp -d)"
trap "rm -rf -- '\$WORKDIR'" EXIT
cd "\$WORKDIR"
eval "\$STG"
tar cpJf "\$TGT.tmp" .
mv "\$TGT.tmp" "\$TGT"
rm -f "/dldir/\${DLNAME}.tar.xz"
ln -s "\${DLNAME}_\${DLHASH}.tar.xz" "/dldir/\${DLNAME}.tar.xz"
EOF
done

docker run -i $TTY_ARG --rm "${UIDARGS[@]}" -v "${DL_SCRIPT_DIR}":/stages -v "${PWD}/.cache/downloads":/dldir -v "${PWD}/scripts.d":/scripts.d -v "${PWD}/util/dl_functions.sh":/dl_functions.sh "${REGISTRY}/${REPO}/base:latest" \
bash -c 'set -xe && for STAGE in /stages/*.sh; do bash $STAGE; done'
Loading

0 comments on commit 845f514

Please sign in to comment.