diff --git a/.github/workflows/build_snap.yml b/.github/workflows/build_snap.yml new file mode 100644 index 000000000..757123794 --- /dev/null +++ b/.github/workflows/build_snap.yml @@ -0,0 +1,51 @@ +name: Build CCExtractor Snap + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build_snap: + name: Build Snap package + runs-on: ubuntu-22.04 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Install snapd + run: | + sudo apt update + sudo apt install -y snapd + + - name: Start snapd + run: | + sudo systemctl start snapd.socket + sudo systemctl start snapd + + - name: Install Snapcraft + run: | + sudo snap install core22 + sudo snap install snapcraft --classic + + - name: Show Snapcraft version + run: snapcraft --version + + - name: Build snap + run: sudo snapcraft --destructive-mode + + - name: List generated snap + run: ls -lh *.snap + + - name: Upload snap as workflow artifact + uses: actions/upload-artifact@v6 + with: + name: CCExtractor Snap + path: "*.snap" + + - name: Upload snap to GitHub Release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v2 + with: + files: "*.snap" diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index 5bb6bedad..053b01d26 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -1,5 +1,6 @@ 0.96.6 (unreleased) ------------------- +- New: Add Snap packaging support with Snapcraft configuration and GitHub Actions CI workflow. - Fix: Clear status line output on Linux/WSL to prevent text artifacts (#2017) - Fix: Prevent infinite loop on truncated MKV files - Fix: Various memory safety and stability fixes in demuxers (MP4, PS, MKV, DVB) diff --git a/snap/local/run-ccextractor.sh b/snap/local/run-ccextractor.sh new file mode 100755 index 000000000..e318a16b2 --- /dev/null +++ b/snap/local/run-ccextractor.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -e +# Default fallback +LIB_TRIPLET="x86_64-linux-gnu" +# Detect multiarch directory if present +for d in "$SNAP/usr/lib/"*-linux-gnu; do + if [ -d "$d" ]; then + LIB_TRIPLET=$(basename "$d") + break + fi +done +export LD_LIBRARY_PATH="$SNAP/usr/lib:\ +$SNAP/usr/lib/$LIB_TRIPLET:\ +$SNAP/usr/lib/$LIB_TRIPLET/blas:\ +$SNAP/usr/lib/$LIB_TRIPLET/lapack:\ +$SNAP/usr/lib/$LIB_TRIPLET/pulseaudio:\ +${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" +shift +exec "$SNAP/usr/local/bin/ccextractor" "$@" diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 000000000..f124e1226 --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,104 @@ +name: ccextractor +base: core22 +version: '0.96.5' +summary: Closed Caption Extractor +description: | + CCExtractor is a tool for extracting closed captions from video files. +website: https://www.ccextractor.org +source-code: https://github.com/CCExtractor/ccextractor +confinement: classic + +apps: + ccextractor: + command: usr/local/bin/ccextractor + command-chain: + - local/run-ccextractor.sh + plugs: + - home + +parts: + gpac: + plugin: make + source: https://github.com/gpac/gpac.git + source-tag: abi-16.4 + build-packages: + - build-essential + - pkg-config + - zlib1g-dev + - libssl-dev + - libfreetype6-dev + - libjpeg-dev + - libpng-dev + override-build: | + set -eux + ./configure --prefix=/usr + make -j$(nproc) + make DESTDIR=$SNAPCRAFT_PART_INSTALL install-lib + sed -i "s|^prefix=.*|prefix=$SNAPCRAFT_STAGE/usr|" $SNAPCRAFT_PART_INSTALL/usr/lib/pkgconfig/gpac.pc + stage: + - usr/lib/libgpac* + - usr/lib/pkgconfig/gpac.pc + - usr/include/gpac + + ccextractor: + after: [gpac] + plugin: cmake + source: . + source-subdir: src + build-environment: + - PKG_CONFIG_PATH: "$SNAPCRAFT_STAGE/usr/lib/pkgconfig:$PKG_CONFIG_PATH" + build-snaps: + - cmake/latest/stable + - rustup/latest/stable + build-packages: + - build-essential + - pkg-config + - clang + - llvm-dev + - libclang-dev + - libzvbi-dev + - libtesseract-dev + - libavcodec-dev + - libavformat-dev + - libavdevice-dev + - libavfilter-dev + - libswscale-dev + - libx11-dev + - libxcb1-dev + - libxcb-shm0-dev + - libpng-dev + - zlib1g-dev + - libblas3 + - liblapack3 + stage-packages: + - libzvbi0 + - libfreetype6 + - libpng16-16 + - libprotobuf-c1 + - libutf8proc2 + - libgl1 + - libglu1-mesa + - libavcodec58 + - libavformat58 + - libavutil56 + - libavdevice58 + - libavfilter7 + - libswscale5 + - libjpeg-turbo8 + - libvorbis0a + - libtheora0 + - libxvidcore4 + - libfaad2 + - libmad0 + - liba52-0.7.4 + - libpulse0 + - pulseaudio-utils + override-build: | + set -eux + rustup toolchain install stable + rustup default stable + export PATH="$HOME/.cargo/bin:$PATH" + snapcraftctl build + install -D -m 0755 \ + $SNAPCRAFT_PROJECT_DIR/snap/local/run-ccextractor.sh \ + $SNAPCRAFT_PART_INSTALL/local/run-ccextractor.sh