mirror of
https://github.com/kmein/niveum
synced 2026-03-18 11:01:07 +01:00
use lib.getExe and lib.getExe' in packaged scripts
Replace all ${pkg}/bin/name patterns with:
- lib.getExe pkg (for main executables: curl, jq, gnused, ffmpeg, etc.)
- lib.getExe' pkg "name" (for specific binaries: coreutils, util-linux, etc.)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# OCR a PDF file to text using tesseract
|
||||
{
|
||||
lib,
|
||||
writers,
|
||||
poppler_utils,
|
||||
tesseract,
|
||||
@@ -8,21 +9,21 @@
|
||||
writers.writeDashBin "pdf-ocr" ''
|
||||
set -efu
|
||||
|
||||
pdf_path="$(${coreutils}/bin/realpath "$1")"
|
||||
pdf_path="$(${lib.getExe' coreutils "realpath"} "$1")"
|
||||
|
||||
[ -f "$pdf_path" ] || {
|
||||
echo "Usage: pdf-ocr FILE.pdf" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
tmpdir="$(${coreutils}/bin/mktemp -d)"
|
||||
tmpdir="$(${lib.getExe' coreutils "mktemp"} -d)"
|
||||
trap 'rm -rf $tmpdir' EXIT
|
||||
|
||||
cd "$tmpdir"
|
||||
|
||||
${poppler_utils}/bin/pdftoppm -png "$pdf_path" pdf-ocr
|
||||
${lib.getExe' poppler_utils "pdftoppm"} -png "$pdf_path" pdf-ocr
|
||||
for png in pdf-ocr*.png; do
|
||||
${tesseract}/bin/tesseract "$png" "$png.txt" 2>/dev/null
|
||||
${lib.getExe tesseract} "$png" "$png.txt" 2>/dev/null
|
||||
done
|
||||
|
||||
cat pdf-ocr-*.txt
|
||||
|
||||
Reference in New Issue
Block a user