Implement build logic
This commit is contained in:
		
							parent
							
								
									57ca78ac1d
								
							
						
					
					
						commit
						c024aa01d6
					
				
					 10 changed files with 65 additions and 60 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1 +1,3 @@
 | 
				
			||||||
/Dockerfile
 | 
					/Dockerfile
 | 
				
			||||||
 | 
					/ffbuild/
 | 
				
			||||||
 | 
					/artifacts/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										52
									
								
								build.sh
									
										
									
									
									
								
							
							
						
						
									
										52
									
								
								build.sh
									
										
									
									
									
								
							| 
						 | 
					@ -1,32 +1,19 @@
 | 
				
			||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
set -xe
 | 
					set -xe
 | 
				
			||||||
 | 
					 | 
				
			||||||
cd "$(dirname "$0")"
 | 
					cd "$(dirname "$0")"
 | 
				
			||||||
 | 
					source util/vars.sh
 | 
				
			||||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
 | 
					 | 
				
			||||||
    echo "Invalid Arguments"
 | 
					 | 
				
			||||||
    exit -1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TARGET="$1"
 | 
					 | 
				
			||||||
VARIANT="${2:-gpl}"
 | 
					 | 
				
			||||||
REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
					 | 
				
			||||||
REPO="${REPO,,}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
IMAGE="$REPO/$TARGET-$VARIANT:latest"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
get_output() {
 | 
					get_output() {
 | 
				
			||||||
    (
 | 
					    (
 | 
				
			||||||
        SELF="$1"
 | 
					        SELF="$1"
 | 
				
			||||||
        source $1
 | 
					        source $1
 | 
				
			||||||
        ffbuild_enabled || exit 0
 | 
					        ffbuild_enabled || exit 0
 | 
				
			||||||
        ffbuild_$2 || exit -1
 | 
					        ffbuild_$2 || exit 0
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
CONFIGURE=""
 | 
					source "variants/${VARIANT}.sh"
 | 
				
			||||||
CFLAGS=""
 | 
					source "variants/${TARGET}-${VARIANT}.sh"
 | 
				
			||||||
LDFLAGS=""
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
for script in scripts.d/*.sh; do
 | 
					for script in scripts.d/*.sh; do
 | 
				
			||||||
    CONFIGURE+=" $(get_output $script configure)"
 | 
					    CONFIGURE+=" $(get_output $script configure)"
 | 
				
			||||||
| 
						 | 
					@ -34,25 +21,28 @@ for script in scripts.d/*.sh; do
 | 
				
			||||||
    LDFLAGS+=" $(get_output $script ldflags)"
 | 
					    LDFLAGS+=" $(get_output $script ldflags)"
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ $VARIANT == gpl ]]; then
 | 
					rm -rf ffbuild
 | 
				
			||||||
    VARIANT_FLAGS="--enable-gpl --enable-version3"
 | 
					mkdir ffbuild
 | 
				
			||||||
elif [[ $VARIANT == lgpl ]]; then
 | 
					 | 
				
			||||||
    VARIANT_FLAGS="--enable-version3"
 | 
					 | 
				
			||||||
else
 | 
					 | 
				
			||||||
    echo "Unknown variant"
 | 
					 | 
				
			||||||
    exit -1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
BUILD_CONTAINER="ffbuild"
 | 
					docker run --rm -i -u "$(id -u):$(id -g)" -v $PWD/ffbuild:/ffbuild "$IMAGE" bash -s <<EOF
 | 
				
			||||||
 | 
					 | 
				
			||||||
docker rm "$BUILD_CONTAINER" 2>/dev/null || true
 | 
					 | 
				
			||||||
docker run -i --name "$BUILD_CONTAINER" "$IMAGE" bash -s <<EOF
 | 
					 | 
				
			||||||
    set -xe
 | 
					    set -xe
 | 
				
			||||||
 | 
					    cd /ffbuild
 | 
				
			||||||
 | 
					    rm -rf ffmpeg prefix
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    git clone https://git.videolan.org/git/ffmpeg.git ffmpeg
 | 
					    git clone https://git.videolan.org/git/ffmpeg.git ffmpeg
 | 
				
			||||||
    cd ffmpeg
 | 
					    cd ffmpeg
 | 
				
			||||||
 | 
					    git switch $GIT_BRANCH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ./configure \$FFBUILD_TARGET_FLAGS $VARIANT_FLAGS $CONFIGURE --extra-cflags="$CFLAGS" --extra-ldflags="$LDFLAGS"
 | 
					    ./configure --prefix=/ffbuild/prefix \$FFBUILD_TARGET_FLAGS $CONFIGURE --extra-cflags="$CFLAGS" --extra-ldflags="$LDFLAGS"
 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    make -j\$(nproc)
 | 
					    make -j\$(nproc)
 | 
				
			||||||
 | 
					    make install    
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mkdir ffbuild/pkgroot
 | 
				
			||||||
 | 
					package_variant ffbuild/prefix ffbuild/pkgroot
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mkdir -p artifacts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					BUILD_NAME="ffmpeg-$(git --git-dir=ffbuild/ffmpeg/.git describe)-${TARGET}-${VARIANT}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					tar cJf artifacts/"${BUILD_NAME}.tar.xz" -C ffbuild/pkgroot .
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								generate.sh
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								generate.sh
									
										
									
									
									
								
							| 
						 | 
					@ -1,19 +1,10 @@
 | 
				
			||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
set -e
 | 
					set -xe
 | 
				
			||||||
 | 
					 | 
				
			||||||
cd "$(dirname "$0")"
 | 
					cd "$(dirname "$0")"
 | 
				
			||||||
 | 
					source util/vars.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rm -f Dockerfile
 | 
					rm -f Dockerfile
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
 | 
					 | 
				
			||||||
    echo "Invalid Arguments"
 | 
					 | 
				
			||||||
    exit -1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TARGET="$1"
 | 
					 | 
				
			||||||
VARIANT="${2:-gpl}"
 | 
					 | 
				
			||||||
REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
					 | 
				
			||||||
REPO="${REPO,,}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
to_df() {
 | 
					to_df() {
 | 
				
			||||||
    printf "$@" >> Dockerfile
 | 
					    printf "$@" >> Dockerfile
 | 
				
			||||||
    echo >> Dockerfile
 | 
					    echo >> Dockerfile
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										14
									
								
								makeimage.sh
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								makeimage.sh
									
										
									
									
									
								
							| 
						 | 
					@ -1,17 +1,7 @@
 | 
				
			||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
set -e
 | 
					set -xe
 | 
				
			||||||
 | 
					 | 
				
			||||||
cd "$(dirname "$0")"
 | 
					cd "$(dirname "$0")"
 | 
				
			||||||
 | 
					source util/vars.sh
 | 
				
			||||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
 | 
					 | 
				
			||||||
    echo "Invalid Arguments"
 | 
					 | 
				
			||||||
    exit -1
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TARGET="$1"
 | 
					 | 
				
			||||||
VARIANT="${2:-gpl}"
 | 
					 | 
				
			||||||
REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
					 | 
				
			||||||
REPO="${REPO,,}"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
./generate.sh "$TARGET" "$VARIANT"
 | 
					./generate.sh "$TARGET" "$VARIANT"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,7 +4,7 @@ X264_REPO="https://code.videolan.org/videolan/x264.git"
 | 
				
			||||||
X264_COMMIT="db0d417728460c647ed4a847222a535b00d3dbcb"
 | 
					X264_COMMIT="db0d417728460c647ed4a847222a535b00d3dbcb"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ffbuild_enabled() {
 | 
					ffbuild_enabled() {
 | 
				
			||||||
    [[ $VARIANT == gpl ]] || return -1
 | 
					    [[ $VARIANT == gpl* ]] || return -1
 | 
				
			||||||
    return 0
 | 
					    return 0
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										13
									
								
								util/vars.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								util/vars.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ $# -lt 1 || $# -gt 2 ]]; then
 | 
				
			||||||
 | 
					    echo "Invalid Arguments"
 | 
				
			||||||
 | 
					    exit -1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TARGET="$1"
 | 
				
			||||||
 | 
					VARIANT="${2:-gpl}"
 | 
				
			||||||
 | 
					REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
 | 
				
			||||||
 | 
					REPO="${REPO,,}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IMAGE="$REPO/$TARGET-$VARIANT:latest"
 | 
				
			||||||
							
								
								
									
										4
									
								
								variants/gpl.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								variants/gpl.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					CONFIGURE="--enable-gpl --enable-version3"
 | 
				
			||||||
 | 
					CFLAGS=""
 | 
				
			||||||
 | 
					LDFLAGS=""
 | 
				
			||||||
 | 
					GIT_BRANCH="master"
 | 
				
			||||||
							
								
								
									
										4
									
								
								variants/lgpl.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								variants/lgpl.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					CONFIGURE="--enable-version3"
 | 
				
			||||||
 | 
					CFLAGS=""
 | 
				
			||||||
 | 
					LDFLAGS=""
 | 
				
			||||||
 | 
					GIT_BRANCH="master"
 | 
				
			||||||
							
								
								
									
										9
									
								
								variants/win64-gpl.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								variants/win64-gpl.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package_variant() {
 | 
				
			||||||
 | 
					    IN="$1"
 | 
				
			||||||
 | 
					    OUT="$2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    mkdir -p "$OUT/bin"
 | 
				
			||||||
 | 
					    cp "$IN"/bin/* "$OUT"/bin
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								variants/win64-lgpl.sh
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								variants/win64-lgpl.sh
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					source "$(dirname "$BASH_SOURCE")/win64-gpl.sh"
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue