gnu: tesseract-ocr: Use standard TESSDATA_PREFIX.

* gnu/packages/ocr.scm (tesseract-ocr-tessdata-fast): Install data to
'share/tessdata' prefix rather than 'share/tesseract-ocr/tessdata'.
(tesseract-ocr) [arguments]: Delete adjust-TESSDATA_PREFIX-macro.
Adjust installation prefix in install-minimal-tessdata phase.
[native-search-paths]: Search for files under share/tessdata directly.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
Simon South 2023-02-27 17:48:04 -05:00 committed by Maxim Cournoyer
parent 34e4761a0f
commit e19d215ec9
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -88,7 +88,7 @@ (define-public tesseract-ocr-tessdata-fast
(base32
"1m310cpb87xx8l8q7jy9fvzf6a0m8rm0dmjpbiwhc2mi6w4gn084"))))
(build-system copy-build-system)
(arguments (list #:install-plan #~'(("." "share/tesseract-ocr/tessdata"))
(arguments (list #:install-plan #~'(("." "share/tessdata"))
#:phases #~(modify-phases %standard-phases
(add-after 'unpack 'delete-broken-links
(lambda _
@ -131,15 +131,6 @@ (define-public tesseract-ocr
(substitute* "configure.ac"
(("AC_SUBST\\(\\[XML_CATALOG_FILES])")
""))))
(add-after 'unpack 'adjust-TESSDATA_PREFIX-macro
(lambda _
;; Use a deeper TESSDATA_PREFIX hierarchy so that a more
;; specific search-path than '/share' can be specified. The
;; build system uses CPPFLAGS for itself, so we can't simply set
;; a make flag.
(substitute* "Makefile.am"
(("-DTESSDATA_PREFIX='\"@datadir@\"'")
"-DTESSDATA_PREFIX='\"@datadir@/tesseract-ocr\"'"))))
(add-after 'build 'build-training
(lambda* (#:key parallel-build? #:allow-other-keys)
(define n (if parallel-build? (number->string
@ -155,7 +146,7 @@ (define n (if parallel-build? (number->string
;; extended via TESSDATA_PREFIX.
(lambda* (#:key native-inputs inputs #:allow-other-keys)
(define eng.traineddata
"/share/tesseract-ocr/tessdata/eng.traineddata")
"/share/tessdata/eng.traineddata")
(install-file (search-input-file (or native-inputs inputs)
eng.traineddata)
(dirname (string-append #$output
@ -183,7 +174,7 @@ (define eng.traineddata
(list leptonica))
(native-search-paths (list (search-path-specification
(variable "TESSDATA_PREFIX")
(files (list "share/tesseract-ocr/tessdata"))
(files (list "share/tessdata"))
(separator #f)))) ;single value
(home-page "https://github.com/tesseract-ocr/tesseract")
(synopsis "Optical character recognition engine")