diff --git a/concat/.SRCINFO b/concat/.SRCINFO index 634d0e7..53b8046 100644 --- a/concat/.SRCINFO +++ b/concat/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = concat pkgdesc = Free and open-source CapCut replacement, a video editor with a Rust engine pkgver = 0.2.4 - pkgrel = 1 + pkgrel = 2 url = https://github.com/jub0t/Concat arch = x86_64 license = AGPL-3.0-or-later @@ -28,11 +28,14 @@ pkgbase = concat depends = glibc depends = hicolor-icon-theme noextract = sherpa-onnx-v1.13.7-linux-x64-static-lib.tar.bz2 + noextract = skia-binaries-a25a0fdb7d90429aa2d1-x86_64-unknown-linux-gnu-gl-jpegd-jpege-pdf-textlayout-vulkan.tar.gz options = !debug options = !lto source = concat-0.2.4.tar.gz::https://github.com/jub0t/Concat/archive/refs/tags/v0.2.4.tar.gz source = https://github.com/k2-fsa/sherpa-onnx/releases/download/v1.13.7/sherpa-onnx-v1.13.7-linux-x64-static-lib.tar.bz2 + source = https://github.com/rust-skia/skia-binaries/releases/download/0.99.0/skia-binaries-a25a0fdb7d90429aa2d1-x86_64-unknown-linux-gnu-gl-jpegd-jpege-pdf-textlayout-vulkan.tar.gz sha256sums = 31d29842832a8f9304cff47722f64ec3f45df7279a484a62037921eca3a7c575 sha256sums = d1be7a69ac2b30120058d8302e624239a3064085383cfa47994a14fdc44c32d6 + sha256sums = 097e78d775c9156dc4b070b9cca7008dbab587513ecb1924baf4cf9620f3119b pkgname = concat diff --git a/concat/PKGBUILD b/concat/PKGBUILD index 0c50d6a..1a18266 100644 --- a/concat/PKGBUILD +++ b/concat/PKGBUILD @@ -4,15 +4,15 @@ pkgname=concat pkgver=0.2.4 -pkgrel=1 +pkgrel=2 pkgdesc="Free and open-source CapCut replacement, a video editor with a Rust engine" arch=('x86_64') url="https://github.com/jub0t/Concat" license=('AGPL-3.0-or-later') -# Nothing is spawned at run time: FFmpeg is linked, whisper.cpp and -# sherpa-onnx are compiled in. alsa-lib is cpal's playback backend; +# Nothing is spawned at run time: FFmpeg is linked, whisper.cpp, sherpa-onnx +# and Skia are compiled in. alsa-lib is cpal's playback backend; # fontconfig and freetype are the font side of the renderer; libglvnd and -# vulkan-icd-loader are the two backends wgpu picks between, and the rest is +# vulkan-icd-loader are the two backends Skia and wgpu draw on, and the rest is # what winit opens by name for whichever session the user is in. dbus is the # XDG portal, which is how the file dialogs and "reveal in file manager" # work without a toolkit. onnxruntime runs the cutout models and is linked @@ -41,10 +41,18 @@ _tag="v0.2.4" # checksums instead of arriving unverified from a build script. The version # follows upstream's Cargo.lock and is synced by pkg.sh. _sherpa="1.13.7" +# skia-bindings, behind Slint's Skia renderer, is the same: it downloads +# prebuilt Skia libraries unless it is handed them. The archive is named by +# the crate version and a key (rust-skia commit, target, Skia features). Both +# are synced by pkg.sh. +_skia="0.99.0" +_skia_key="a25a0fdb7d90429aa2d1-x86_64-unknown-linux-gnu-gl-jpegd-jpege-pdf-textlayout-vulkan" source=("${pkgname}-${pkgver}.tar.gz::https://github.com/jub0t/Concat/archive/refs/tags/${_tag}.tar.gz" - "https://github.com/k2-fsa/sherpa-onnx/releases/download/v${_sherpa}/sherpa-onnx-v${_sherpa}-linux-x64-static-lib.tar.bz2") -noextract=("sherpa-onnx-v${_sherpa}-linux-x64-static-lib.tar.bz2") -sha256sums=('31d29842832a8f9304cff47722f64ec3f45df7279a484a62037921eca3a7c575' 'd1be7a69ac2b30120058d8302e624239a3064085383cfa47994a14fdc44c32d6') + "https://github.com/k2-fsa/sherpa-onnx/releases/download/v${_sherpa}/sherpa-onnx-v${_sherpa}-linux-x64-static-lib.tar.bz2" + "https://github.com/rust-skia/skia-binaries/releases/download/${_skia}/skia-binaries-${_skia_key}.tar.gz") +noextract=("sherpa-onnx-v${_sherpa}-linux-x64-static-lib.tar.bz2" + "skia-binaries-${_skia_key}.tar.gz") +sha256sums=('31d29842832a8f9304cff47722f64ec3f45df7279a484a62037921eca3a7c575' 'd1be7a69ac2b30120058d8302e624239a3064085383cfa47994a14fdc44c32d6' '097e78d775c9156dc4b070b9cca7008dbab587513ecb1924baf4cf9620f3119b') _srcname="Concat-${_tag#v}" @@ -62,6 +70,8 @@ build() { export CARGO_TARGET_DIR=target # the checksummed archive from source[1], instead of a download in build() export SHERPA_ONNX_ARCHIVE_DIR="$srcdir" + # the same for source[2]; {key} is filled in by skia-bindings itself + export SKIA_BINARIES_URL="file://$srcdir/skia-binaries-{key}.tar.gz" # ort, the ONNX Runtime binding behind the cutout models, downloads a # prebuilt runtime from its build script unless it is pointed at one. Arch # has the library, so it is linked against that instead - dynamically, so @@ -78,15 +88,9 @@ build() { # for kernels nobody measured. Off, it compiles to the portable baseline. export GGML_NATIVE=OFF - # --features wgpu: FemtoVG over wgpu instead of the default Skia renderer. - # skia-bindings downloads prebuilt binaries from its build script, which a - # package cannot do; the wgpu renderer is pure Rust. This is the same - # choice, for the same reason, that upstream's flake.nix makes. - # # --profile app: upstream's shipping profile - fat LTO, panic=abort, # stripped. See src/Cargo.toml for what each knob is for. - cargo build --profile app -p concat --frozen \ - --no-default-features --features wgpu + cargo build --profile app -p concat --frozen } package() { diff --git a/concat/pkg.sh b/concat/pkg.sh index 585a49f..b5b52b4 100644 --- a/concat/pkg.sh +++ b/concat/pkg.sh @@ -5,16 +5,22 @@ # the same binary upstream ships in the Linux tarball that concat-bin # repackages. Upstream's flake.nix is the reference for what that needs, and # this follows it: cargo, cmake and clang, the system FFmpeg, and Slint's -# FemtoVG-over-wgpu renderer instead of the default Skia one, because -# skia-bindings downloads its binaries from the build script. +# Skia renderer. (Until 0.2.4 the flake used FemtoVG over wgpu instead; main +# dropped that option.) # -# sherpa-onnx-sys, the text-to-speech backend, ships no C++ build: its build -# script downloads a prebuilt static-lib archive from the sherpa-onnx release -# page. The PKGBUILD lists that archive as a source and points the build -# script at it (SHERPA_ONNX_ARCHIVE_DIR), so the binary is checksummed by -# makepkg rather than fetched unverified mid-build. Its version has to follow -# upstream's Cargo.lock, so refresh_checksums() reads it from the tarball and -# syncs the _sherpa variable in the PKGBUILD. +# Two build scripts download prebuilt static libraries: sherpa-onnx-sys (text +# to speech) and skia-bindings (Skia). The PKGBUILD lists both archives as +# sources and points the build scripts at them (SHERPA_ONNX_ARCHIVE_DIR, +# SKIA_BINARIES_URL), so makepkg checksums them rather than having them +# fetched unverified mid-build. Their names follow upstream's Cargo.lock, so +# refresh_checksums() reads them from the tarball and syncs _sherpa, _skia +# and _skia_key in the PKGBUILD. +# +# The Skia archive's key is --. The +# commit comes from the skia-bindings crate (.cargo_vcs_info.json). The +# features depend on what Slint turns on, which only a cargo build resolves, +# so they are taken from upstream's flake.nix, which has to name the same +# archive (skiaKeyFeatures). If a flake has none, the PKGBUILD's are kept. # # Release/version handling is identical to concat-bin: the release list is # ordered by creation rather than by version, so the newest is picked by @@ -43,7 +49,8 @@ latest_version() { # refresh_checksums refresh_checksums() { local ver="$1" pkgbuild="$2" - local tag tarball sherpa sha_src sha_sherpa + local tag tarball lock flake sherpa skia skia_hash skia_features skia_key + local sha_src sha_sherpa sha_skia archive tag="$(latest_tag)" if [[ "$(tag_to_pkgver <<< "$tag")" != "$ver" ]]; then @@ -51,8 +58,8 @@ refresh_checksums() { return 1 fi - # kept on disk rather than streamed: the tarball is needed twice, once for - # its checksum and once for the Cargo.lock inside it + # kept on disk rather than streamed: the tarball is needed for its checksum + # and for the Cargo.lock and flake.nix inside it tarball="$(mktemp)" if ! curl -sfL -o "$tarball" \ "https://github.com/$UPSTREAM_REPO/archive/refs/tags/$tag.tar.gz"; then @@ -62,25 +69,58 @@ refresh_checksums() { fi sha_src="$(sha256sum "$tarball" | cut -d' ' -f1)" - # `|| true`, so that a tree that has moved the lockfile or dropped the crate - # is reported below instead of ending the run on grep's exit status with + # `|| true`, so that a tree that has moved a file or dropped a crate is + # reported below instead of ending the run on a failed exit status with # nothing printed. - sherpa="$(tar -xOzf "$tarball" --wildcards '*/src/Cargo.lock' \ - | grep -A2 '^name = "sherpa-onnx-sys"' | sed -n 's/^version = "\(.*\)"/\1/p' \ - || true)" + lock="$(tar -xOzf "$tarball" --wildcards '*/src/Cargo.lock' || true)" + flake="$(tar -xOzf "$tarball" --wildcards '*/flake.nix' 2>/dev/null || true)" rm -f "$tarball" - if [[ -z "$sherpa" ]]; then - echo "could not read the sherpa-onnx-sys version from $tag's src/Cargo.lock" >&2 + sherpa="$(grep -A2 '^name = "sherpa-onnx-sys"' <<< "$lock" \ + | sed -n 's/^version = "\(.*\)"/\1/p' || true)" + skia="$(grep -A2 '^name = "skia-bindings"' <<< "$lock" \ + | sed -n 's/^version = "\(.*\)"/\1/p' || true)" + if [[ -z "$sherpa" || -z "$skia" ]]; then + echo "could not read the sherpa-onnx-sys and skia-bindings versions from $tag's src/Cargo.lock" >&2 return 1 fi - sha_sherpa="$(curl -sfL "https://github.com/k2-fsa/sherpa-onnx/releases/download/v$sherpa/sherpa-onnx-v$sherpa-linux-x64-static-lib.tar.bz2" \ - | sha256sum | cut -d' ' -f1)" + skia_hash="$(curl -sfL "https://static.crates.io/crates/skia-bindings/skia-bindings-$skia.crate" \ + | tar -xzO --wildcards '*/.cargo_vcs_info.json' | jq -r '.git.sha1' | cut -c1-20 || true)" + if [[ ! "$skia_hash" =~ ^[0-9a-f]{20}$ ]]; then + echo "could not read the rust-skia commit of skia-bindings $skia from crates.io" >&2 + return 1 + fi + skia_features="$(sed -n 's/^ *skiaKeyFeatures = "\(.*\)";/\1/p' <<< "$flake")" + if [[ -z "$skia_features" ]]; then + skia_features="$(sed -n 's/^_skia_key=".*-x86_64-unknown-linux-gnu-\(.*\)"/\1/p' "$pkgbuild")" + fi + skia_key="$skia_hash-x86_64-unknown-linux-gnu-$skia_features" + + archive="$(mktemp)" + if ! curl -sfL -o "$archive" \ + "https://github.com/k2-fsa/sherpa-onnx/releases/download/v$sherpa/sherpa-onnx-v$sherpa-linux-x64-static-lib.tar.bz2"; then + rm -f "$archive" + echo "could not download the sherpa-onnx $sherpa static-lib archive" >&2 + return 1 + fi + sha_sherpa="$(sha256sum "$archive" | cut -d' ' -f1)" + # a missing archive most likely means the features are wrong: check the + # "TRYING TO DOWNLOAD AND INSTALL SKIA BINARIES" line of a build log + if ! curl -sfL -o "$archive" \ + "https://github.com/rust-skia/skia-binaries/releases/download/$skia/skia-binaries-$skia_key.tar.gz"; then + rm -f "$archive" + echo "rust-skia has no Skia archive $skia/$skia_key" >&2 + return 1 + fi + sha_skia="$(sha256sum "$archive" | cut -d' ' -f1)" + rm -f "$archive" sed -i \ -e "s|^_tag=.*|_tag=\"$tag\"|" \ -e "s|^_sherpa=.*|_sherpa=\"$sherpa\"|" \ - -e "s|^sha256sums=.*|sha256sums=('$sha_src' '$sha_sherpa')|" \ + -e "s|^_skia=.*|_skia=\"$skia\"|" \ + -e "s|^_skia_key=.*|_skia_key=\"$skia_key\"|" \ + -e "s|^sha256sums=.*|sha256sums=('$sha_src' '$sha_sherpa' '$sha_skia')|" \ "$pkgbuild" }