From f463237e3cda7cba5af2f062eb44a2798daf7b49 Mon Sep 17 00:00:00 2001 From: Nick White Date: Tue, 9 Apr 2024 00:56:06 +0100 Subject: Fix flatpak tessdata sourcing to ensure all files are available to it --- cmd/rescribe/embed_other.go | 5 ++--- cmd/rescribe/embed_other2.go | 11 +++++++++++ cmd/rescribe/embed_tessdata.go | 2 +- cmd/rescribe/xyz.rescribe.rescribe.yml | 10 +++------- 4 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 cmd/rescribe/embed_other2.go (limited to 'cmd') diff --git a/cmd/rescribe/embed_other.go b/cmd/rescribe/embed_other.go index ac9ce3a..190a051 100644 --- a/cmd/rescribe/embed_other.go +++ b/cmd/rescribe/embed_other.go @@ -6,8 +6,7 @@ package main -// if not one of the above platforms, we won't embed anything, so -// just create empty byte slices +// if not one of the above platforms, we won't embed tesseract +// or getgbook, so just create empty byte slices var tesszip []byte var gbookzip []byte -var tessdatazip []byte diff --git a/cmd/rescribe/embed_other2.go b/cmd/rescribe/embed_other2.go new file mode 100644 index 0000000..5749008 --- /dev/null +++ b/cmd/rescribe/embed_other2.go @@ -0,0 +1,11 @@ +// Copyright 2021 Nick White. +// Use of this source code is governed by the GPLv3 +// license that can be found in the LICENSE file. + +//go:build (!darwin && !linux && !windows) || (!embed && !flatpak) + +package main + +// if not one of the above platforms, we won't embed tessdata, so +// just create an empty byte slice +var tessdatazip []byte diff --git a/cmd/rescribe/embed_tessdata.go b/cmd/rescribe/embed_tessdata.go index ea9ce8f..dbd5f06 100644 --- a/cmd/rescribe/embed_tessdata.go +++ b/cmd/rescribe/embed_tessdata.go @@ -2,7 +2,7 @@ // Use of this source code is governed by the GPLv3 // license that can be found in the LICENSE file. -//go:build embed +//go:build embed || flatpak package main diff --git a/cmd/rescribe/xyz.rescribe.rescribe.yml b/cmd/rescribe/xyz.rescribe.rescribe.yml index 0e647b5..e579e99 100644 --- a/cmd/rescribe/xyz.rescribe.rescribe.yml +++ b/cmd/rescribe/xyz.rescribe.rescribe.yml @@ -18,17 +18,15 @@ modules: buildsystem: simple build-commands: - cd cmd/rescribe && go build . - - cd cmd/rescribe && go build -tags wayland -o rescribe-wayland . + - cd cmd/rescribe && go build -tags flatpak,wayland -o rescribe-wayland . - install -Dm00755 cmd/rescribe/rescribe $FLATPAK_DEST/bin/rescribe-bin - install -Dm00755 cmd/rescribe/rescribe-wayland $FLATPAK_DEST/bin/rescribe-bin-wayland - install -Dm00644 cmd/rescribe/icon.256.png $FLATPAK_DEST/share/icons/hicolor/256x256/apps/xyz.rescribe.rescribe.png - install -Dm00644 cmd/rescribe/icon.svg $FLATPAK_DEST/share/icons/hicolor/scalable/apps/xyz.rescribe.rescribe.svg - install -Dm00644 cmd/rescribe/xyz.rescribe.rescribe.desktop $FLATPAK_DEST/share/applications/xyz.rescribe.rescribe.desktop - install -Dm00644 cmd/rescribe/xyz.rescribe.rescribe.appdata.xml $FLATPAK_DEST/share/appdata/xyz.rescribe.rescribe.appdata.xml - - printf '#!/bin/sh\nexport TMPDIR=$XDG_RUNTIME_DIR\nbin=rescribe-bin\ntest -n "$WAYLAND_DISPLAY" && bin=rescribe-bin-wayland\n"$bin" -gbookcmd "/app/bin/getgbook" -tesscmd "/app/bin/tesseract" -t "/app/share/tessdata/rescribev9_fast.traineddata"\n' > $FLATPAK_DEST/bin/rescribe + - printf '#!/bin/sh\nexport TMPDIR=$XDG_RUNTIME_DIR\nbin=rescribe-bin\ntest -n "$WAYLAND_DISPLAY" && bin=rescribe-bin-wayland\n"$bin" -gbookcmd "/app/bin/getgbook" -tesscmd "/app/bin/tesseract"\n' > $FLATPAK_DEST/bin/rescribe - chmod 755 $FLATPAK_DEST/bin/rescribe - - mkdir -p $FLATPAK_DEST/share/tessdata - - cp -r tessdata/* $FLATPAK_DEST/share/tessdata/ sources: - type: git url: https://github.com/rescribe/bookpipeline @@ -38,11 +36,9 @@ modules: url: https://rescribe.xyz/rescribe/modules-20240206-d2399a.tar.xz sha256: 682820d4cb6129c564cf8df494dc12d35ab059ed99dba34c0b3d6260f7fc30fb strip-components: 0 - - type: archive + - type: file url: https://rescribe.xyz/rescribe/embeds/tessdata.20220322.zip sha256: 725fd570a3c3dc0eba9463248ce47a8646db8bafb198d428d6bb8f0be18540ee - strip-components: 0 - dest: tessdata - name: leptonica sources: - type: git -- cgit v1.2.1-24-ge1ad