Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snap improvements #4298

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b613c6d
snap: Switch Leptonica source to Git repository
brlin-tw Aug 8, 2024
66afa2c
snap: Fix Leptonica part not build with OpenJPEG support
brlin-tw Aug 8, 2024
0649d0f
snap: Fix missing {build,stage}-packages declaration for the Leptonic…
brlin-tw Aug 8, 2024
7e9dd2d
snap: Ensure Leptonica features we need are built
brlin-tw Aug 8, 2024
064a6b0
snap: Optimize Leptonica part
brlin-tw Aug 8, 2024
8d9174a
snap: Update Leptonica to 1.84.1 version
brlin-tw Aug 9, 2024
b28ab15
snap: Fix missing WebP support in the Leptonica part
brlin-tw Aug 9, 2024
ef199ef
snap: Fix missing stage-packages of the Tesseract part
brlin-tw Aug 9, 2024
8782ee4
snap: Reduce package size by stripping out files not used in runtime
brlin-tw Aug 9, 2024
19270b4
snap: Drop unused training tools build/runtime dependencies
brlin-tw Aug 9, 2024
db818ac
snap: Explicitly declare features we don't want to be build
brlin-tw Aug 9, 2024
7a7a984
snap: Disable unused features to reduce snap size and built time
brlin-tw Aug 9, 2024
7d2ba18
snap: Fix incorrect dependency declaration for the Tesseract part
brlin-tw Aug 9, 2024
23b31c6
snap: Drop incorrect build-packages declaration of the Tesseract part
brlin-tw Aug 9, 2024
d05286d
snap: Add cosmetic blank line separator between the definition of the…
brlin-tw Aug 9, 2024
53f2b00
snap: Improve order of the `after` part property
brlin-tw Aug 9, 2024
89a673c
snap: Incorporate v3.0.6 selective-checkout scriptlet for ease of sta…
brlin-tw Aug 9, 2024
9717555
snap: Fix missing libarchive and libcurl support of the Tesseract part
brlin-tw Aug 9, 2024
0331ab5
snap: Fix libraries under $SNAP/usr/local/lib aren't loaded in runtime
brlin-tw Aug 9, 2024
b8b0fd0
snap: Strip unused icu libraries from snap
brlin-tw Aug 9, 2024
3a2cbc1
fixup! snap: Fix missing libarchive and libcurl support of the Tesser…
brlin-tw Aug 9, 2024
bdccad5
snap: Implement fallback config loading mechanism
brlin-tw Aug 10, 2024
32c4320
snap: Replace deprecated CRAFT_ARCH_TRIPLET Snapcraft part environmen…
brlin-tw Aug 10, 2024
88c3e33
snap: Fix incorrect compiled-in datadir
brlin-tw Aug 11, 2024
ca47315
snap: Avoid hardcoding the TESSDATA_PREFIX environment variable
brlin-tw Aug 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ config_auto.h
/src/training/wordlist2dawg

*.patch
!/snap/local/*.patch

# files generated by libtool
/src/training/combine_lang_model
Expand Down
47 changes: 47 additions & 0 deletions snap/local/implement-fallback-config-loading.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Implement fallback config loading mechanism

This patch fixes configuration files in the readonly snap filesystem
not loadable by Tesseract due to missing datadir fallback logic.

If the config file with the same name doesn't exist in the
user-specified tessdata prefix directory, the one in the compiled-in
directory will be loaded, allows Tesseract to work properly.

Signed-off-by: 林博仁(Buo-ren Lin) <[email protected]>

diff --git a/src/ccmain/tessedit.cpp b/src/ccmain/tessedit.cpp
index c7518883..d0031eb5 100644
--- a/src/ccmain/tessedit.cpp
+++ b/src/ccmain/tessedit.cpp
@@ -37,6 +37,7 @@
# include "reject.h"
#endif
#include "lstmrecognizer.h"
+#include <cstdlib>

namespace tesseract {

@@ -57,7 +58,22 @@ void Tesseract::read_config_file(const char *filename, SetParamConstraint constr
if ((fp = fopen(path.c_str(), "rb")) != nullptr) {
fclose(fp);
} else {
- path = filename;
+ std::string datadir_readonly = TESSDATA_PREFIX "/tessdata/";
+ path = datadir_readonly;
+ path += "configs/";
+ path += filename;
+ if ((fp = fopen(path.c_str(), "rb")) != nullptr) {
+ fclose(fp);
+ } else {
+ path = datadir_readonly;
+ path += "tessconfigs/";
+ path += filename;
+ if ((fp = fopen(path.c_str(), "rb")) != nullptr) {
+ fclose(fp);
+ } else {
+ path = filename;
+ }
+ }
}
}
ParamUtils::ReadParamsFile(path.c_str(), constraint, this->params());
Loading