all: test package
-test:
+test: $(BUILDDIR)/parts/scanbasic.sh
./tests/scanbasic.bats
build: $(PACKAGEDIR)/$(BINDIR)/scantopdf \
################################################################################
$(BUILDDIR)/parts/scanbasic.sh: \
+ $(SRCDIR)/addocr.sh \
$(SRCDIR)/scanbasic.sh
mkdir -p $(@D)
--- /dev/null
+optimize()
+{
+ local input="$1"
+ local output="$input-out"
+
+ [ -n "$input" ] \
+ || errlog "missing input" \
+ || return $?
+
+ qpdf --linearize $input $output \
+ || errlog "could not linearize $input" \
+ || return $?
+ mv $output $input \
+ || errlog "could not rename $output to $input" \
+ || return $?
+}
+
+addocr()
+{
+ local input="$1"
+ local jobs="$2"
+ local output="$input-out"
+ jobs=${jobs:=1}
+
+ [ -n "$input" ] \
+ || errlog "missing input" \
+ || return $?
+
+ echo "ℹ️ INFO: adding ocr on file $input"
+ ocrmypdf --quiet --jobs $(nproc) --language deu $input $output \
+ || errlog "could not add ocr on $input" \
+ || return $?
+
+ [ ! -f $output ] && return 0
+
+ mv $output $input \
+ || errlog "could not rename $output to $input" \
+ || return $?
+ optimize $input \
+ || return $?
+}
+#include "addocr.sh"
errlog()
{
local lastexit=$?
rm $tiff
}
-optimize()
-{
- local input="$1"
- local output="$input-out"
-
- [ -n "$input" ] \
- || errlog "missing input" \
- || return $?
-
- qpdf --linearize $input $output \
- || errlog "could not linearize $input" \
- || return $?
- mv $output $input \
- || errlog "could not rename $output to $input" \
- || return $?
-}
-
-addocr()
-{
- local input="$1"
- local jobs="$2"
- local output="$input-out"
- jobs=${jobs:=1}
-
- [ -n "$input" ] \
- || errlog "missing input" \
- || return $?
-
- echo "ℹ️ INFO: adding ocr on file $input"
- ocrmypdf --quiet --jobs $(nproc) --language deu $input $output \
- || errlog "could not add ocr on $input" \
- || return $?
-
- [ ! -f $output ] && return 0
-
- mv $output $input \
- || errlog "could not rename $output to $input" \
- || return $?
- optimize $input \
- || return $?
-}
-
createonepdf()
{
local output=$1