# Flatpak manifest for Riplika. # # Everything the three pipelines need is built here. ffmpeg with libdvdread, # libdvdnav and libdvdcss reads and encodes video; cdparanoia reads audio off a # CD and LAME encodes it to MP3; a game disc needs neither, since it is copied # rather than converted. A missing one of these does not announce itself at # startup, so packaging/check-flatpak.sh asks for each by name. # # Two things the sandbox decides, which are worth stating plainly. # # MakeMKV cannot be bundled, being proprietary, so redistributing it in this # manifest is not ours to do. Calling the host's copy would need # --talk-name=org.freedesktop.Flatpak, which is sandbox escape wearing a hat: # it would let this application run anything at all on the host, and claiming # to be sandboxed afterwards would be a lie. A disc the free reader cannot # manage therefore needs the native build with makemkvcon on PATH, and the # window does not offer the option in here, since it could only sit greyed # out. DVDs, music CDs and game discs all work in the sandbox, because none of # those paths needs anything proprietary. # # --device=all is required and is not a small permission. Flatpak has no # narrower option for an optical drive, since --device=dri is the GPU and # there is nothing for /dev/sr0 alone. Reading a disc means access to devices # generally, and the three permissions below it are each explained where they # are asked for. app-id: com.nsrosenqvist.Riplika runtime: org.gnome.Platform runtime-version: '50' sdk: org.gnome.Sdk sdk-extensions: - org.freedesktop.Sdk.Extension.rust-stable command: riplika-gui build-options: append-path: /usr/lib/sdk/rust-stable/bin env: CARGO_HOME: /run/build/riplika/cargo finish-args: - --socket=wayland - --socket=fallback-x11 - --share=ipc - --device=dri # the optical drive; see the note above - --device=all # catalogue lookups against TVmaze and TMDB - --share=network # Unmounting the disc before opening the tray. # # The kernel will not open a tray under a mounted filesystem, and the # desktop mounts a disc the moment it goes in. Unsandboxed, `eject` unmounts # first and none of this arises; in here the mount belongs to the host's # udisks, is not visible at all, and can only be undone by asking udisks to # undo it. Without this, ejecting a disc that has been looked at reports # "busy" and there is nothing the application can do about it. # # Narrow on purpose: one service, and the only thing asked of it is to # unmount the drive this application was pointed at. It is not # --filesystem=host wearing a different hat - udisks decides for itself # whether the caller may unmount, and asks the session if it is unsure. - --system-talk-name=org.freedesktop.UDisks2 # Where the language data for reading a new disc's lettering was installed. # Tesseract has a compiled-in default and it is not this one, so without it a # disc nobody has a glyph table for gets "Error opening data file". - --env=TESSDATA_PREFIX=/app/share/tessdata # Noticing a disc going in or coming out, so the window follows the tray # rather than waiting to be asked to look again. # # GVolumeMonitor is how a GTK application is told; inside a sandbox it # reaches the desktop's copy through gvfs, and without this it sees no # drives at all and never fires. Read-only in effect: it is told what # happened and asks for nothing. - --talk-name=org.gtk.vfs.* # somewhere to write the library. # # xdg-download is not for the working rip, whatever the comment used to say: # that defaults to the application's own cache directory, which needs no # permission. It is here because a library or a scratch directory configured # under Downloads is a thing people do, and without it that configuration # fails at the end of a rip rather than when it is set. # # One per kind, because they are three different libraries and a disc goes to # the one that matches it. Without the music line a CD rip fails outright: # inside the sandbox ~/Music does not merely refuse to be written, it does # not exist, so the rip stops on a directory it cannot create. # # Games are not an XDG directory - there is no xdg-games - so the folder is # named outright. Somebody who configures a library somewhere else has to # grant that path themselves; flatpak has no way for the application to ask # for it, and --filesystem=home to avoid the question would hand it # everything. - --filesystem=xdg-videos - --filesystem=xdg-music - --filesystem=~/Games - --filesystem=xdg-download # What the builds leave behind that nobody installing this needs. # # Ten libraries are built from source here, and each installs its development # side along with itself: headers, pkg-config files, and static archives beside # the shared ones. Nothing in the sandbox ever compiles anything, so all of it # is dead weight - libtesseract.a alone is 117 MB, more than half of what the # application came to before this list existed. Applied after every module has # been built, so the headers are still there while riplika is compiled against # them. cleanup: - /include - /lib/pkgconfig - /lib/cmake - /share/aclocal - /share/man - /share/doc - /share/gtk-doc - /bin/*-config - '*.a' - '*.la' modules: # --- disc reading ------------------------------------------------------- # VideoLAN moved these three to meson; flatpak-builder assumes autotools. - name: libdvdcss buildsystem: meson # ffmpeg and x264 install to /app/lib, and meson picks its own libdir from # the host it thinks it is on - lib on one builder, lib64 on another. Saying # it means the build does not depend on which builder ran it. config-opts: - --libdir=lib sources: - type: archive url: https://download.videolan.org/pub/videolan/libdvdcss/1.6.0/libdvdcss-1.6.0.tar.xz sha256: 7ea556c846b7bfc32d47b41cae56d1863a6b6d5f706bb162778d6f298490977c - name: libdvdread buildsystem: meson config-opts: # Linked, not dlopened. libdvdread falls back to loading libdvdcss by # name at runtime, which inside a sandbox depends on it being on the # loader path - linking removes the question. - -Dlibdvdcss=enabled - --libdir=lib sources: - type: archive url: https://download.videolan.org/pub/videolan/libdvdread/7.1.1/libdvdread-7.1.1.tar.xz sha256: a0d47876548bec806774bbf8dbf20bb19ba139464383156b32eb8e59915b90a9 - name: libdvdnav buildsystem: meson config-opts: - --libdir=lib sources: - type: archive url: https://download.videolan.org/pub/videolan/libdvdnav/7.0.0/libdvdnav-7.0.0.tar.xz sha256: a2a18f5ad36d133c74bf9106b6445806fa253b09141a46392550394b647b221e # --- the tools the pipeline drives -------------------------------------- # The GNOME SDK carries no x264, and the encoder is not optional here: every # quality tier is an x264 CRF. - name: x264 config-opts: - --enable-shared - --disable-cli sources: - type: git url: https://code.videolan.org/videolan/x264.git # the stable branch, pinned - a branch name would drift commit: b35605ace3ddf7c1a5d67a2eb553f034aef41d55 # LAME, for MP3. ffmpeg has a FLAC encoder of its own and no MP3 one, so # without this a FLAC rip works, an MP3 rip gets as far as encoding and # fails on every track with "Encoder not found", and the settings screen # offers a format that cannot be produced. - name: lame config-opts: - --enable-shared - --disable-static - --disable-frontend sources: - type: archive url: https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz sha256: ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e # 3.100 exports a symbol its own source does not define, and the link # fails on it. Every distribution carries this same one-line removal. - type: shell commands: - sed -i '/lame_init_old/d' include/libmp3lame.sym # ffmpeg must be built --enable-libdvdnav --enable-libdvdread: without them # there is no dvdvideo demuxer and the application cannot read a disc at all. - name: ffmpeg config-opts: # GPL for x264, version3 for nothing in particular yet - but changing # licence terms later is worse than starting permissive enough. - --enable-gpl - --enable-version3 - --enable-shared - --disable-static - --disable-doc - --disable-programs - --enable-ffmpeg - --enable-ffprobe - --enable-libdvdnav - --enable-libdvdread - --enable-libx264 - --enable-libmp3lame sources: - type: archive url: https://ffmpeg.org/releases/ffmpeg-7.1.5.tar.xz sha256: de668509caf9e35e3cd162473441fdb29538c6d96ed080292b3cf9e6fc5d558f # cdparanoia, for reading audio off a CD. # # Not optional and not interchangeable with ffmpeg, which can read a CD # through libcdio and does none of what makes a rip trustworthy: re-reads, # C2 error pointers, jitter correction against a drive that does not report # its position honestly. Without it every track of a music rip fails with # "cdparanoia: No such file or directory", which is exactly what it did. - name: cdparanoia buildsystem: simple build-commands: # Its own config.guess and config.sub are from 2008 and do not recognise # the triplet this is built for; the SDK carries current ones. - cp /usr/share/automake-*/config.sub /usr/share/automake-*/config.guess . - ./configure --prefix=/app # -fPIC because the shared library does not build without it here, and # -j1 because its Makefile is not safe to run in parallel. - make -j1 OPT="$CFLAGS -fPIC" - make install sources: - type: archive url: https://downloads.xiph.org/releases/cdparanoia/cdparanoia-III-10.2.src.tgz sha256: 005db45ef4ee017f5c32ec124f913a0546e77014266c6a1c50df902a55fe64df # Leptonica and Tesseract, for labelling a glyph table on a disc nobody has # one for. Not how subtitles are decoded - that is an exact lookup of shapes # already labelled and stays that way - but how the labels are arrived at # once per release font. Without it a disc from a studio the shipped table # does not cover keeps its subtitles as pictures, which is what The Lion King # did. - name: leptonica buildsystem: autotools config-opts: - --disable-static # Nothing here reads a scanned page: the input is a PNG this application # drew itself, moments earlier, from the shapes it segmented. - --without-jpeg - --without-giflib - --without-libwebp - --without-libopenjpeg sources: - type: archive url: https://github.com/DanBloomberg/leptonica/releases/download/1.85.0/leptonica-1.85.0.tar.gz sha256: 3745ae3bf271a6801a2292eead83ac926e3a9bc1bf622e9cd4dd0f3786e17205 - name: tesseract buildsystem: cmake-ninja # Its CMakeLists refuses to generate in the source directory, and # flatpak-builder builds in-source unless told otherwise. builddir: true config-opts: - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TRAINING_TOOLS=OFF - -DDISABLE_ARCHIVE=ON - -DDISABLE_CURL=ON sources: - type: archive url: https://github.com/tesseract-ocr/tesseract/archive/refs/tags/5.5.0.tar.gz sha256: f2fb34ca035b6d087a42875a35a7a5c4155fa9979c6132365b1e5a28ebc3fc11 # A track is only ever read with its own language's data - reading Icelandic # with English votes `d` and `o` for one shape and `p` and `b` for another, # into the table every track on the disc shares - so a language that is not # here is a language whose subtitles stay pictures. Hence the spread: the # languages a Region 2 disc is actually subtitled in, at two to five # megabytes each. # # The fast models rather than the accurate ones. What they are asked to read # is a line this application rendered from its own segmentation - black on # white, no skew, no noise - and the difference between the two model sets # does not show on that, while the accurate ones are ten times the size. - name: tessdata buildsystem: simple build-commands: - install -Dm644 eng.traineddata /app/share/tessdata/eng.traineddata - install -Dm644 swe.traineddata /app/share/tessdata/swe.traineddata - install -Dm644 deu.traineddata /app/share/tessdata/deu.traineddata - install -Dm644 fra.traineddata /app/share/tessdata/fra.traineddata - install -Dm644 spa.traineddata /app/share/tessdata/spa.traineddata - install -Dm644 ita.traineddata /app/share/tessdata/ita.traineddata - install -Dm644 nld.traineddata /app/share/tessdata/nld.traineddata - install -Dm644 dan.traineddata /app/share/tessdata/dan.traineddata - install -Dm644 nor.traineddata /app/share/tessdata/nor.traineddata - install -Dm644 fin.traineddata /app/share/tessdata/fin.traineddata - install -Dm644 isl.traineddata /app/share/tessdata/isl.traineddata - install -Dm644 por.traineddata /app/share/tessdata/por.traineddata - install -Dm644 pol.traineddata /app/share/tessdata/pol.traineddata - install -Dm644 ces.traineddata /app/share/tessdata/ces.traineddata - install -Dm644 hun.traineddata /app/share/tessdata/hun.traineddata - install -Dm644 ell.traineddata /app/share/tessdata/ell.traineddata - install -Dm644 rus.traineddata /app/share/tessdata/rus.traineddata - install -Dm644 tur.traineddata /app/share/tessdata/tur.traineddata sources: - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/eng.traineddata sha256: 7d4322bd2a7749724879683fc3912cb542f19906c83bcc1a52132556427170b2 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/swe.traineddata sha256: f7304988d41f833efebcc2d529df54b1903ecebbc3da1faabd19a0fddd4fe586 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/deu.traineddata sha256: 19d219bbb6672c869d20a9636c6816a81eb9a71796cb93ebe0cb1530e2cdb22d - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/fra.traineddata sha256: ced037562e8c80c13122dece28dd477d399af80911a28791a66a63ac1e3445ca - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/spa.traineddata sha256: 6f2e04d02774a18f01bed44b1111f2cd7f3ba7ac9dc4373cd3f898a40ea6b464 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/ita.traineddata sha256: b8f89e1e785118dac4d51ae042c029a64edb5c3ee42ef73027a6d412748d8827 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/nld.traineddata sha256: ced0e5e046a84c908a6aa7accbef9a232c4a5d9a8276691b81c6ee64d02963f6 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/dan.traineddata sha256: acb1fd074487a31d1294fcdfd7d7c673467ffd8aeacb2ccd61ebcbf04eb4e2fa - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/nor.traineddata sha256: 0451eb4f8049ae78196806bf878a389a2f40f1386fe038568cf4441226ba6ef2 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/fin.traineddata sha256: 61a04cd62b507c3d9ae0e1cda399e6715ebf49dea9df47897c8acdcd3bd3e13c - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/isl.traineddata sha256: 5ec828c363f3f0062c3caf08216677cf5f3c0c981b05fab445123a16b98f10a9 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/por.traineddata sha256: c4932b937207a9514b7514d518b931a99938c02a28a5a5a553f8599ed58b7deb - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/pol.traineddata sha256: c4476cdbc0e33d898d32345122b7be1cbf85ace15f920f06c7714756e1ef79b2 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/ces.traineddata sha256: 934bcaf97ef3348413263331131c9fa7f55f30db333c711929c124fb635f7e1b - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/hun.traineddata sha256: 35067e7cfe102dcdc953f9a758fdfaa6296b17a1ee6d874ee780fa306430b9fb - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/ell.traineddata sha256: 4fba8a0b461038d51f1c20d043d4f2ac38c4e778f1b90830847f7bd8fa3ba726 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/rus.traineddata sha256: e16e5e036cce1d9ec2b00063cf8b54472625b9e14d893a169e2b0dedeb4df225 - type: file url: https://github.com/tesseract-ocr/tessdata_fast/raw/4.1.0/tur.traineddata sha256: 7393381111e1152420fc4092cb44eef4237580d21b92bf30d7d221aad192c6b7 # No mkvtoolnix: the VobSub track is read out of Matroska directly, because # MKVToolNix wants Qt for every one of its tools and bundling Qt to obtain # `mkvextract` is a poor trade. # --- the application ---------------------------------------------------- - name: riplika buildsystem: simple build-options: env: CARGO_NET_OFFLINE: 'true' build-commands: - cargo --offline build --release - install -Dm755 target/release/riplika-gui /app/bin/riplika-gui - install -Dm755 target/release/riplika /app/bin/riplika - install -Dm644 data/com.nsrosenqvist.Riplika.desktop /app/share/applications/com.nsrosenqvist.Riplika.desktop # The name matters twice over: flatpak exports only icons named after the # app id, and the desktop entry's Icon= is that same name. Anywhere else # or anything else and the launcher shows a blank square. - install -Dm644 data/icons/hicolor/scalable/apps/com.nsrosenqvist.Riplika.svg /app/share/icons/hicolor/scalable/apps/com.nsrosenqvist.Riplika.svg # What a software centre shows. Required for Flathub, and worth having # without it: a bundle installed by hand carries this too, and the # application otherwise appears with no name, description or licence. - install -Dm644 data/com.nsrosenqvist.Riplika.metainfo.xml /app/share/metainfo/com.nsrosenqvist.Riplika.metainfo.xml # the translations, where i18n::init looks inside a sandbox - ./po/install.sh /app/share sources: - type: dir path: .. # generated with flatpak-cargo-generator.py from Cargo.lock - cargo-sources.json