mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-28 16:41:52 +08:00
refactor: 升级依赖版本并优化构建系统
- 升级核心依赖 (axum 0.8, tower-http 0.6, alsa 0.11 等) - 简化交叉编译配置,切换至 Debian 11 提高兼容性 - 新增 Debian 包打包支持 (debuerreotype 模板) - 移除独立的 mjpeg 解码器,简化视频模块 - 静态链接 libx264/libx265/libopus 到二进制
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Cross-compilation image for ARM64 based on Debian 12
|
||||
# Uses multiarch to install ARM64 libraries on x86_64 host
|
||||
# Cross-compilation image for ARM64 based on Debian 11
|
||||
# Build on Debian 11 (GLIBC 2.31) for maximum runtime compatibility
|
||||
|
||||
FROM debian:12
|
||||
FROM debian:11
|
||||
|
||||
# Set Rustup mirrors (Aliyun)
|
||||
ENV RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup \
|
||||
@@ -28,7 +28,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
libclang-dev \
|
||||
llvm \
|
||||
mold \
|
||||
meson \
|
||||
ninja-build \
|
||||
wget \
|
||||
@@ -36,6 +35,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc-aarch64-linux-gnu \
|
||||
g++-aarch64-linux-gnu \
|
||||
libc6-dev-arm64-cross \
|
||||
# Autotools for libopus (requires autoreconf)
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install ARM64 development libraries (without VAAPI/X11 for ARM)
|
||||
@@ -44,24 +47,22 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libv4l-dev:arm64 \
|
||||
libudev-dev:arm64 \
|
||||
zlib1g-dev:arm64 \
|
||||
# Note: libjpeg-turbo, libyuv, libvpx are built from source below for static linking
|
||||
libx264-dev:arm64 \
|
||||
libx265-dev:arm64 \
|
||||
libopus-dev:arm64 \
|
||||
# Note: libjpeg-turbo, libyuv, libvpx, libx264, libx265, libopus are built from source below for static linking
|
||||
libdrm-dev:arm64 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Build static libjpeg-turbo from source (cross-compile for ARM64)
|
||||
RUN git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo /tmp/libjpeg-turbo \
|
||||
&& cd /tmp/libjpeg-turbo \
|
||||
&& cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/aarch64-linux-gnu \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
|
||||
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/aarch64-linux-gnu \
|
||||
-DENABLE_SHARED=OFF -DENABLE_STATIC=ON \
|
||||
&& cmake --build build -j$(nproc) \
|
||||
&& cmake --install build \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libjpeg-turbo
|
||||
|
||||
# Build static libyuv from source (cross-compile for ARM64)
|
||||
@@ -69,16 +70,13 @@ RUN git clone --depth 1 https://github.com/lemenkov/libyuv /tmp/libyuv \
|
||||
&& cd /tmp/libyuv \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/aarch64-linux-gnu \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
|
||||
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
|
||||
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
|
||||
-DCMAKE_PREFIX_PATH=/opt/one-kvm-libs/aarch64-linux-gnu \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/aarch64-linux-gnu \
|
||||
&& make -j$(nproc) \
|
||||
&& mkdir -p /opt/one-kvm-libs/aarch64-linux-gnu/lib \
|
||||
&& cp libyuv.a /opt/one-kvm-libs/aarch64-linux-gnu/lib/ \
|
||||
&& cp -r ../include /opt/one-kvm-libs/aarch64-linux-gnu/ \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libyuv
|
||||
|
||||
# Build static libvpx from source (cross-compile for ARM64)
|
||||
@@ -91,7 +89,8 @@ RUN git clone --depth 1 https://github.com/webmproject/libvpx /tmp/libvpx \
|
||||
&& export LD=aarch64-linux-gnu-ld \
|
||||
&& export AR=aarch64-linux-gnu-ar \
|
||||
&& export CROSS=aarch64-linux-gnu- \
|
||||
&& ./configure --prefix=/opt/one-kvm-libs/aarch64-linux-gnu \
|
||||
&& ./configure \
|
||||
--prefix=/usr/aarch64-linux-gnu \
|
||||
--target=arm64-linux-gcc \
|
||||
--enable-static --disable-shared --enable-pic \
|
||||
--disable-examples --disable-tools --disable-docs \
|
||||
@@ -102,9 +101,79 @@ RUN git clone --depth 1 https://github.com/webmproject/libvpx /tmp/libvpx \
|
||||
&& file libvpx.a \
|
||||
&& make install \
|
||||
&& echo "=== libvpx: Verifying installed library ===" \
|
||||
&& file /opt/one-kvm-libs/aarch64-linux-gnu/lib/libvpx.a \
|
||||
&& file /usr/aarch64-linux-gnu/lib/libvpx.a \
|
||||
&& rm -rf /tmp/libvpx
|
||||
|
||||
# Build static libx264 from source (cross-compile for ARM64)
|
||||
RUN git clone --depth 1 https://code.videolan.org/videolan/x264.git /tmp/x264 \
|
||||
&& cd /tmp/x264 \
|
||||
&& export CC=aarch64-linux-gnu-gcc \
|
||||
&& export AR=aarch64-linux-gnu-ar \
|
||||
&& export RANLIB=aarch64-linux-gnu-ranlib \
|
||||
&& ./configure \
|
||||
--prefix=/usr/aarch64-linux-gnu \
|
||||
--host=aarch64-linux-gnu \
|
||||
--enable-static \
|
||||
--enable-pic \
|
||||
--disable-cli \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x264
|
||||
|
||||
# Build static libx265 from source (cross-compile for ARM64)
|
||||
RUN git clone --depth 1 https://bitbucket.org/multicoreware/x265_git /tmp/x265 \
|
||||
&& cd /tmp/x265 \
|
||||
&& cd source \
|
||||
&& mkdir -p build \
|
||||
&& cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/aarch64-linux-gnu \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=aarch64 \
|
||||
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc \
|
||||
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ \
|
||||
-DENABLE_SHARED=OFF \
|
||||
-DENABLE_CLI=OFF \
|
||||
-DENABLE_NEON_DOTPROD=OFF \
|
||||
-DENABLE_NEON_I8MM=OFF \
|
||||
-DENABLE_SVE=OFF \
|
||||
-DENABLE_SVE2=OFF \
|
||||
-DENABLE_SVE2_BITPERM=OFF \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x265
|
||||
|
||||
# Create pkg-config file for x265 (required by FFmpeg)
|
||||
RUN mkdir -p /usr/aarch64-linux-gnu/lib/pkgconfig && \
|
||||
cat > /usr/aarch64-linux-gnu/lib/pkgconfig/x265.pc <<EOF
|
||||
prefix=/usr/aarch64-linux-gnu
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${exec_prefix}/lib
|
||||
includedir=\${prefix}/include
|
||||
|
||||
Name: x265
|
||||
Description: H.265/HEVC video encoder
|
||||
Version: 199
|
||||
Libs: -L\${libdir} -lx265 -lstdc++ -lm -ldl -lpthread
|
||||
Cflags: -I\${includedir}
|
||||
EOF
|
||||
|
||||
# Build static libopus from source (cross-compile for ARM64)
|
||||
RUN git clone --depth 1 https://github.com/xiph/opus /tmp/opus \
|
||||
&& cd /tmp/opus \
|
||||
&& export CC=aarch64-linux-gnu-gcc \
|
||||
&& export AR=aarch64-linux-gnu-ar \
|
||||
&& export RANLIB=aarch64-linux-gnu-ranlib \
|
||||
&& ./autogen.sh \
|
||||
&& ./configure \
|
||||
--host=aarch64-linux-gnu \
|
||||
--enable-static --disable-shared \
|
||||
--disable-doc \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/opus
|
||||
|
||||
# Download and build FFmpeg with RKMPP support
|
||||
RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
&& wget -q https://files.mofeng.run/src/image/other/ffmpeg.tar.gz \
|
||||
@@ -123,6 +192,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
-DBUILD_TEST=OFF \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/aarch64-linux-gnu/lib/pkgconfig/rockchip_mpp.pc \
|
||||
&& cd ../.. \
|
||||
# Build RKRGA - create cross file for meson
|
||||
&& echo '[binaries]' > /tmp/aarch64-cross.txt \
|
||||
@@ -146,10 +216,11 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
-Dlibrga_demo=false \
|
||||
&& ninja -C build \
|
||||
&& ninja -C build install \
|
||||
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/aarch64-linux-gnu/lib/pkgconfig/librga.pc \
|
||||
&& cd .. \
|
||||
# Create pkg-config wrapper for cross-compilation
|
||||
&& echo '#!/bin/sh' > /tmp/aarch64-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_LIBDIR=/opt/one-kvm-libs/aarch64-linux-gnu/lib/pkgconfig:/usr/aarch64-linux-gnu/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig' >> /tmp/aarch64-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_LIBDIR=/usr/aarch64-linux-gnu/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig' >> /tmp/aarch64-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_PATH=""' >> /tmp/aarch64-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_SYSROOT_DIR=""' >> /tmp/aarch64-pkg-config \
|
||||
&& echo 'exec pkg-config "$@"' >> /tmp/aarch64-pkg-config \
|
||||
@@ -157,7 +228,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
# Build FFmpeg with RKMPP (minimal build for encoding only)
|
||||
&& cd ffmpeg-rockchip \
|
||||
&& ./configure \
|
||||
--prefix=/opt/one-kvm-libs/aarch64-linux-gnu \
|
||||
--prefix=/usr/aarch64-linux-gnu \
|
||||
--cross-prefix=aarch64-linux-gnu- \
|
||||
--arch=aarch64 \
|
||||
--target-os=linux \
|
||||
@@ -235,25 +306,14 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
# Add Rust target
|
||||
RUN rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
# Create symlink for mold to work with cross-compiler
|
||||
RUN ln -s /usr/bin/mold /usr/bin/aarch64-linux-gnu-ld.mold
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY build/cross/entrypoint.sh /usr/local/bin/cross-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/cross-entrypoint.sh
|
||||
|
||||
# Configure environment for cross-compilation
|
||||
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
|
||||
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \
|
||||
AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar \
|
||||
PKG_CONFIG_LIBDIR=/opt/one-kvm-libs/aarch64-linux-gnu/lib/pkgconfig:/usr/aarch64-linux-gnu/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig \
|
||||
PKG_CONFIG_LIBDIR=/usr/aarch64-linux-gnu/lib/pkgconfig:/usr/lib/aarch64-linux-gnu/pkgconfig \
|
||||
PKG_CONFIG_PATH="" \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
LIBRARY_PATH="/opt/one-kvm-libs/aarch64-linux-gnu/lib" \
|
||||
CPATH="/opt/one-kvm-libs/aarch64-linux-gnu/include" \
|
||||
FFMPEG_STATIC=1 \
|
||||
LIBYUV_STATIC=1 \
|
||||
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-fuse-ld=mold"
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/cross-entrypoint.sh"]
|
||||
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc"
|
||||
@@ -1,7 +1,7 @@
|
||||
# Cross-compilation image for ARMv7 based on Debian 12
|
||||
# Uses multiarch to install ARMv7 libraries on x86_64 host
|
||||
# Cross-compilation image for ARMv7 based on Debian 11
|
||||
# Build on Debian 11 (GLIBC 2.31) for maximum runtime compatibility
|
||||
|
||||
FROM debian:12
|
||||
FROM debian:11
|
||||
|
||||
# Set Rustup mirrors (Aliyun)
|
||||
ENV RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup \
|
||||
@@ -28,7 +28,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
libclang-dev \
|
||||
llvm \
|
||||
mold \
|
||||
meson \
|
||||
ninja-build \
|
||||
wget \
|
||||
@@ -36,6 +35,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
gcc-arm-linux-gnueabihf \
|
||||
g++-arm-linux-gnueabihf \
|
||||
libc6-dev-armhf-cross \
|
||||
# Autotools for libopus (requires autoreconf)
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install ARMv7 development libraries (without VAAPI/X11 for ARM)
|
||||
@@ -44,24 +47,21 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libv4l-dev:armhf \
|
||||
libudev-dev:armhf \
|
||||
zlib1g-dev:armhf \
|
||||
# Note: libjpeg-turbo, libyuv, libvpx are built from source below for static linking
|
||||
libx264-dev:armhf \
|
||||
libx265-dev:armhf \
|
||||
libopus-dev:armhf \
|
||||
libdrm-dev:armhf \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Build static libjpeg-turbo from source (cross-compile for ARMv7)
|
||||
RUN git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo /tmp/libjpeg-turbo \
|
||||
&& cd /tmp/libjpeg-turbo \
|
||||
&& cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/arm-linux-gnueabihf \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=arm \
|
||||
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/armv7-linux-gnueabihf \
|
||||
-DENABLE_SHARED=OFF -DENABLE_STATIC=ON \
|
||||
&& cmake --build build -j$(nproc) \
|
||||
&& cmake --install build \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libjpeg-turbo
|
||||
|
||||
# Build static libyuv from source (cross-compile for ARMv7)
|
||||
@@ -69,20 +69,16 @@ RUN git clone --depth 1 https://github.com/lemenkov/libyuv /tmp/libyuv \
|
||||
&& cd /tmp/libyuv \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/arm-linux-gnueabihf \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=arm \
|
||||
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
|
||||
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
|
||||
-DCMAKE_PREFIX_PATH=/opt/one-kvm-libs/armv7-linux-gnueabihf \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/armv7-linux-gnueabihf \
|
||||
&& make -j$(nproc) \
|
||||
&& mkdir -p /opt/one-kvm-libs/armv7-linux-gnueabihf/lib \
|
||||
&& cp libyuv.a /opt/one-kvm-libs/armv7-linux-gnueabihf/lib/ \
|
||||
&& cp -r ../include /opt/one-kvm-libs/armv7-linux-gnueabihf/ \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libyuv
|
||||
|
||||
# Build static libvpx from source (cross-compile for ARMv7)
|
||||
# CC/CXX/LD/AR must be environment variables, not configure arguments
|
||||
RUN git clone --depth 1 https://github.com/webmproject/libvpx /tmp/libvpx \
|
||||
&& cd /tmp/libvpx \
|
||||
&& export CC=arm-linux-gnueabihf-gcc \
|
||||
@@ -90,17 +86,83 @@ RUN git clone --depth 1 https://github.com/webmproject/libvpx /tmp/libvpx \
|
||||
&& export LD=arm-linux-gnueabihf-ld \
|
||||
&& export AR=arm-linux-gnueabihf-ar \
|
||||
&& export CROSS=arm-linux-gnueabihf- \
|
||||
&& ./configure --prefix=/opt/one-kvm-libs/armv7-linux-gnueabihf \
|
||||
&& ./configure \
|
||||
--prefix=/usr/arm-linux-gnueabihf \
|
||||
--target=armv7-linux-gcc \
|
||||
--enable-static --disable-shared --enable-pic \
|
||||
--disable-examples --disable-tools --disable-docs \
|
||||
--disable-unit-tests \
|
||||
&& make -j$(nproc) \
|
||||
&& echo "=== libvpx: Checking architecture ===" \
|
||||
&& file libvpx.a \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libvpx
|
||||
|
||||
# Build static libx264 from source (cross-compile for ARMv7)
|
||||
RUN git clone --depth 1 https://code.videolan.org/videolan/x264.git /tmp/x264 \
|
||||
&& cd /tmp/x264 \
|
||||
&& export CC=arm-linux-gnueabihf-gcc \
|
||||
&& export AR=arm-linux-gnueabihf-ar \
|
||||
&& export RANLIB=arm-linux-gnueabihf-ranlib \
|
||||
&& ./configure \
|
||||
--prefix=/usr/arm-linux-gnueabihf \
|
||||
--host=arm-linux-gnueabihf \
|
||||
--cross-prefix=arm-linux-gnueabihf- \
|
||||
--enable-static --disable-shared \
|
||||
--enable-pic \
|
||||
--disable-cli \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x264
|
||||
|
||||
# Build static libx265 from source (cross-compile for ARMv7)
|
||||
RUN git clone --depth 1 https://bitbucket.org/multicoreware/x265_git /tmp/x265 \
|
||||
&& cd /tmp/x265 \
|
||||
&& cd source \
|
||||
&& mkdir -p build \
|
||||
&& cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=/usr/arm-linux-gnueabihf \
|
||||
-DCMAKE_SYSTEM_NAME=Linux \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=arm \
|
||||
-DCMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
|
||||
-DCMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
|
||||
-DENABLE_SHARED=OFF \
|
||||
-DENABLE_CLI=OFF \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x265
|
||||
|
||||
# Create pkg-config file for x265 (required by FFmpeg)
|
||||
RUN mkdir -p /usr/arm-linux-gnueabihf/lib/pkgconfig && \
|
||||
cat > /usr/arm-linux-gnueabihf/lib/pkgconfig/x265.pc <<EOF
|
||||
prefix=/usr/arm-linux-gnueabihf
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${exec_prefix}/lib
|
||||
includedir=\${prefix}/include
|
||||
|
||||
Name: x265
|
||||
Description: H.265/HEVC video encoder
|
||||
Version: 199
|
||||
Libs: -L\${libdir} -lx265 -lstdc++ -lm -ldl -lpthread
|
||||
Cflags: -I\${includedir}
|
||||
EOF
|
||||
|
||||
# Build static libopus from source (cross-compile for ARMv7)
|
||||
RUN git clone --depth 1 https://github.com/xiph/opus /tmp/opus \
|
||||
&& cd /tmp/opus \
|
||||
&& export CC=arm-linux-gnueabihf-gcc \
|
||||
&& export AR=arm-linux-gnueabihf-ar \
|
||||
&& export RANLIB=arm-linux-gnueabihf-ranlib \
|
||||
&& ./autogen.sh \
|
||||
&& ./configure \
|
||||
--host=arm-linux-gnueabihf \
|
||||
--enable-static --disable-shared \
|
||||
--disable-doc \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/opus
|
||||
|
||||
# Download and build FFmpeg with RKMPP support
|
||||
RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
&& wget -q https://files.mofeng.run/src/image/other/ffmpeg.tar.gz \
|
||||
@@ -119,6 +181,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
-DBUILD_TEST=OFF \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/arm-linux-gnueabihf/lib/pkgconfig/rockchip_mpp.pc \
|
||||
&& cd ../.. \
|
||||
# Build RKRGA - create cross file for meson
|
||||
&& echo '[binaries]' > /tmp/armhf-cross.txt \
|
||||
@@ -142,10 +205,11 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
-Dlibrga_demo=false \
|
||||
&& ninja -C build \
|
||||
&& ninja -C build install \
|
||||
&& sed -i 's/^Libs:.*$/& -lstdc++ -lm -lpthread/' /usr/arm-linux-gnueabihf/lib/pkgconfig/librga.pc \
|
||||
&& cd .. \
|
||||
# Create pkg-config wrapper for cross-compilation
|
||||
&& echo '#!/bin/sh' > /tmp/armhf-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_LIBDIR=/opt/one-kvm-libs/armv7-linux-gnueabihf/lib/pkgconfig:/usr/arm-linux-gnueabihf/lib/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig' >> /tmp/armhf-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabihf/lib/pkgconfig:/usr/arm-linux-gnueabihf/lib/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig' >> /tmp/armhf-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_PATH=""' >> /tmp/armhf-pkg-config \
|
||||
&& echo 'export PKG_CONFIG_SYSROOT_DIR=""' >> /tmp/armhf-pkg-config \
|
||||
&& echo 'exec pkg-config "$@"' >> /tmp/armhf-pkg-config \
|
||||
@@ -153,7 +217,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
# Build FFmpeg with RKMPP (minimal build for encoding only)
|
||||
&& cd ffmpeg-rockchip \
|
||||
&& ./configure \
|
||||
--prefix=/opt/one-kvm-libs/armv7-linux-gnueabihf \
|
||||
--prefix=/usr/arm-linux-gnueabihf \
|
||||
--cross-prefix=arm-linux-gnueabihf- \
|
||||
--arch=arm \
|
||||
--target-os=linux \
|
||||
@@ -231,25 +295,17 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
# Add Rust target
|
||||
RUN rustup target add armv7-unknown-linux-gnueabihf
|
||||
|
||||
# Create symlink for mold to work with cross-compiler
|
||||
RUN ln -s /usr/bin/mold /usr/bin/arm-linux-gnueabihf-ld.mold
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY build/cross/entrypoint.sh /usr/local/bin/cross-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/cross-entrypoint.sh
|
||||
|
||||
# Configure environment for cross-compilation
|
||||
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
|
||||
CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
|
||||
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
|
||||
AR_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-ar \
|
||||
PKG_CONFIG_LIBDIR=/opt/one-kvm-libs/armv7-linux-gnueabihf/lib/pkgconfig:/usr/arm-linux-gnueabihf/lib/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig \
|
||||
PKG_CONFIG_LIBDIR=/usr/arm-linux-gnueabihf/lib/pkgconfig:/usr/lib/arm-linux-gnueabihf/pkgconfig \
|
||||
PKG_CONFIG_PATH="" \
|
||||
PKG_CONFIG_ALLOW_CROSS=1 \
|
||||
LIBRARY_PATH="/opt/one-kvm-libs/armv7-linux-gnueabihf/lib" \
|
||||
CPATH="/opt/one-kvm-libs/armv7-linux-gnueabihf/include" \
|
||||
FFMPEG_STATIC=1 \
|
||||
LIBYUV_STATIC=1 \
|
||||
RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc -C link-arg=-fuse-ld=mold"
|
||||
RUSTFLAGS="-C linker=arm-linux-gnueabihf-gcc"
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/cross-entrypoint.sh"]
|
||||
# Default command
|
||||
CMD ["bash"]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Cross-compilation image for x86_64 based on Debian 12
|
||||
# Matches the runtime environment exactly
|
||||
# Cross-compilation image for x86_64 based on Debian 11
|
||||
# Build on Debian 11 (GLIBC 2.31) for maximum runtime compatibility
|
||||
|
||||
FROM debian:12
|
||||
FROM debian:11
|
||||
|
||||
# Set Rustup mirrors (Aliyun)
|
||||
ENV RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup \
|
||||
@@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ENV PATH="/root/.cargo/bin:${PATH}"
|
||||
|
||||
# Install build dependencies
|
||||
# Note: libyuv, libvpx are built from source below for static linking
|
||||
# Note: libyuv, libvpx, libx264, libx265, libopus are built from source below for static linking
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# Build tools
|
||||
build-essential \
|
||||
@@ -28,20 +28,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
libclang-dev \
|
||||
llvm \
|
||||
mold \
|
||||
wget \
|
||||
# Autotools for libopus (requires autoreconf)
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
# Core system libraries
|
||||
libasound2-dev \
|
||||
libv4l-dev \
|
||||
libudev-dev \
|
||||
zlib1g-dev \
|
||||
# Note: libjpeg-turbo is built from source below for static linking
|
||||
# Video codec libraries (dynamic, for software fallback)
|
||||
libx264-dev \
|
||||
libx265-dev \
|
||||
# Audio codec
|
||||
libopus-dev \
|
||||
# Hardware acceleration
|
||||
# Note: libjpeg-turbo, libx264, libx265, libopus are built from source below for static linking
|
||||
libva-dev \
|
||||
libdrm-dev \
|
||||
libmfx-dev \
|
||||
@@ -55,11 +52,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# Build static libjpeg-turbo from source (needed by libyuv)
|
||||
RUN git clone --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo /tmp/libjpeg-turbo \
|
||||
&& cd /tmp/libjpeg-turbo \
|
||||
&& cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/x86_64-linux-gnu \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DENABLE_SHARED=OFF -DENABLE_STATIC=ON \
|
||||
&& cmake --build build -j$(nproc) \
|
||||
&& cmake --install build \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libjpeg-turbo
|
||||
|
||||
# Build static libyuv from source (uses libjpeg-turbo headers)
|
||||
@@ -67,32 +64,75 @@ RUN git clone --depth 1 https://github.com/lemenkov/libyuv /tmp/libyuv \
|
||||
&& cd /tmp/libyuv \
|
||||
&& mkdir build && cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
|
||||
-DCMAKE_PREFIX_PATH=/opt/one-kvm-libs/x86_64-linux-gnu \
|
||||
-DCMAKE_INSTALL_PREFIX=/opt/one-kvm-libs/x86_64-linux-gnu \
|
||||
&& make -j$(nproc) \
|
||||
&& mkdir -p /opt/one-kvm-libs/x86_64-linux-gnu/lib \
|
||||
&& cp libyuv.a /opt/one-kvm-libs/x86_64-linux-gnu/lib/ \
|
||||
&& cp -r ../include /opt/one-kvm-libs/x86_64-linux-gnu/ \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libyuv
|
||||
|
||||
# Build static libvpx from source
|
||||
RUN git clone --depth 1 https://github.com/webmproject/libvpx /tmp/libvpx \
|
||||
&& cd /tmp/libvpx \
|
||||
&& ./configure --prefix=/opt/one-kvm-libs/x86_64-linux-gnu \
|
||||
&& ./configure \
|
||||
--enable-static --disable-shared --enable-pic \
|
||||
--disable-examples --disable-tools --disable-docs \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/libvpx
|
||||
|
||||
# Build static libx264 from source
|
||||
RUN git clone --depth 1 https://code.videolan.org/videolan/x264.git /tmp/x264 \
|
||||
&& cd /tmp/x264 \
|
||||
&& ./configure --enable-static --disable-cli \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x264
|
||||
|
||||
# Build static libx265 from source
|
||||
RUN git clone --depth 1 https://bitbucket.org/multicoreware/x265_git /tmp/x265 \
|
||||
&& cd /tmp/x265 \
|
||||
&& cd source \
|
||||
&& mkdir -p build \
|
||||
&& cd build \
|
||||
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
|
||||
-DENABLE_SHARED=OFF \
|
||||
-DENABLE_CLI=OFF \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/x265
|
||||
|
||||
# Create pkg-config file for x265 (required by FFmpeg)
|
||||
# Fix: Added -lstdc++ -lm -ldl -lpthread to Libs for static linking compatibility
|
||||
RUN mkdir -p /usr/local/lib/pkgconfig && \
|
||||
cat > /usr/local/lib/pkgconfig/x265.pc <<EOF
|
||||
prefix=/usr/local
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${exec_prefix}/lib
|
||||
includedir=\${prefix}/include
|
||||
|
||||
Name: x265
|
||||
Description: H.265/HEVC video encoder
|
||||
Version: 199
|
||||
Libs: -L\${libdir} -lx265 -lstdc++ -lm -ldl -lpthread
|
||||
Cflags: -I\${includedir}
|
||||
EOF
|
||||
|
||||
# Build static libopus from source
|
||||
RUN git clone --depth 1 https://github.com/xiph/opus /tmp/opus \
|
||||
&& cd /tmp/opus \
|
||||
&& ./autogen.sh \
|
||||
&& ./configure \
|
||||
--enable-static --disable-shared \
|
||||
--disable-doc \
|
||||
&& make -j$(nproc) \
|
||||
&& make install \
|
||||
&& rm -rf /tmp/opus
|
||||
|
||||
# Download and build FFmpeg with minimal configuration for encoding only
|
||||
RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
&& wget -q https://files.mofeng.run/src/image/other/ffmpeg.tar.gz \
|
||||
&& tar -xzf ffmpeg.tar.gz \
|
||||
&& cd ffmpeg/ffmpeg-rockchip \
|
||||
&& export PKG_CONFIG_PATH="/opt/one-kvm-libs/x86_64-linux-gnu/lib/pkgconfig:$PKG_CONFIG_PATH" \
|
||||
&& ./configure \
|
||||
--prefix=/opt/one-kvm-libs/x86_64-linux-gnu \
|
||||
--enable-gpl \
|
||||
--enable-version3 \
|
||||
--disable-shared \
|
||||
@@ -165,16 +205,7 @@ RUN mkdir -p /tmp/ffmpeg-build && cd /tmp/ffmpeg-build \
|
||||
# Add Rust target
|
||||
RUN rustup target add x86_64-unknown-linux-gnu
|
||||
|
||||
# Copy entrypoint script
|
||||
COPY build/cross/entrypoint.sh /usr/local/bin/cross-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/cross-entrypoint.sh
|
||||
|
||||
# Configure environment for static linking
|
||||
ENV RUSTFLAGS="-C link-arg=-fuse-ld=mold" \
|
||||
PKG_CONFIG_PATH="/opt/one-kvm-libs/x86_64-linux-gnu/lib/pkgconfig" \
|
||||
LIBRARY_PATH="/opt/one-kvm-libs/x86_64-linux-gnu/lib" \
|
||||
CPATH="/opt/one-kvm-libs/x86_64-linux-gnu/include" \
|
||||
ENV PKG_CONFIG_ALLOW_CROSS=1\
|
||||
FFMPEG_STATIC=1 \
|
||||
LIBYUV_STATIC=1
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/cross-entrypoint.sh"]
|
||||
LIBYUV_STATIC=1
|
||||
Reference in New Issue
Block a user