Skip to content

Commit 57874e8

Browse files
committed
Merge branch 'master' of github.com:jessp01/zaje
2 parents aeab88c + d76b52e commit 57874e8

5 files changed

Lines changed: 85 additions & 14 deletions

File tree

.github/workflows/go.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ jobs:
4242
pre-commit run --all-files
4343
go test -v
4444
sudo ./install_zaje.sh
45+
- name: Test super-zaje
46+
env:
47+
TERM: term-256color
48+
run: |
49+
sudo bash -x ./cmd/super-zaje/static_build_debian.sh

cmd/super-zaje/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ For example, try:
5353
$ ~/go/bin/super-zaje "https://github.com/jessp01/zaje/blob/master/testimg/go1.png?raw=true"
5454
```
5555

56+
##### Static Build
57+
58+
See this [doc](./static_build.md).
59+
5660
### PDF inputs
5761

5862
PDF files are also supported. For example:

cmd/super-zaje/static_build.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,47 @@
33
The below will produce a rather chubby binary (29M on my Debian box) but it should run correctly on all modern Linux distros.
44
If you don't need a static binary, simply follow the relevant install procedure [here](./README.md)
55

6+
For your convenience, a [build script](./static_build_debian.sh) with all of these is also available.
7+
68
- Install deps:
79
```sh
8-
# apt-get install libdeflate-dev libtiff-dev libsharpyuv-dev libwebp-dev liblerc-dev liblzma-dev libjbig-dev libpng-dev libzstd-dev libjpeg-dev
10+
apt-get -U -y -q install libdeflate-dev libtiff-dev libsharpyuv-dev libwebp-dev git libgif-dev \
11+
liblerc-dev liblzma-dev libjbig-dev libpng-dev libzstd-dev libjpeg-dev build-essential
912
```
1013

11-
Note: Debian/Ubuntu do provide static archives for both `libleptonica` and `libtesseract` but these are compiled with additional options that `super-zaje` does not need and statically linking against these archives would require the installation of several more `dev` packages.
14+
**Note: Debian/Ubuntu do provide static archives for both `libleptonica` and `libtesseract` but these are compiled with additional options that `super-zaje` does not need and statically linking against them would require the installation of several more `dev` packages.
15+
The below commands clone from head, obviously, you can use specific versions instead (always best).**
1216

1317
- Build a statically linked version of libleptonica:
1418

1519
```sh
16-
$ git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
17-
$ ./autogen.sh
18-
$ ./configure --with-pic --disable-shared 'CFLAGS=-D DEFAULT_SEVERITY=L_SEVERITY_ERROR -g0 -O3'
19-
$ make
20-
# make install
20+
git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
21+
cd leptonica
22+
./autogen.sh
23+
./configure --with-pic --disable-shared 'CFLAGS=-D DEFAULT_SEVERITY=L_SEVERITY_ERROR -g0 -O3'
24+
make
25+
make install
2126
```
2227

2328
- Build a statically linked version of libtesseract:
2429
```sh
25-
$ git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git
26-
$ ./autogen.sh
27-
$ ./configure --with-pic --disable-shared --disable-legacy --disable-graphics --disable-openmp --without-curl --without-archive --disable-doc 'CXXFLAGS=-DTESS_EXPORTS -g0 -O3 -ffast-math'
28-
$ make
29-
# make install
30+
git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git
31+
cd tesseract
32+
./autogen.sh
33+
./configure --with-pic --disable-shared --disable-legacy --disable-graphics \
34+
--disable-openmp --without-curl --without-archive --disable-doc \
35+
'CXXFLAGS=-DTESS_EXPORTS -g0 -O3 -ffast-math'
36+
make
37+
make install
3038
```
3139

3240
- Build super-zaje:
3341
```sh
3442
git clone https://github.com/jessp01/zaje.git
3543
cd zaje/cmd/super-zaje
36-
CGO_ENABLED=1 GOOS=linux go build -a -tags netgo -ldflags '-extldflags "-static -ldeflate -ltiff -L/usr/local/lib -ldeflate -lsharpyuv -lwebp -lLerc -llzma -ljbig -ltesseract -lleptonica -lpng -lzstd -ljpeg -lz -lgif -lsharpyuv -lwebp"' super-zaje.go
44+
CGO_ENABLED=1 GOOS=linux go build -a -tags netgo -ldflags \
45+
'-extldflags "-static -ldeflate -ltiff -L/usr/local/lib -ldeflate -lsharpyuv -lwebp -lLerc -llzma -ljbig -ltesseract -lleptonica -lpng -lzstd -ljpeg -lz -lgif -lsharpyuv -lwebp"' super-zaje.go
46+
```
3747

48+
**Note: to run `super-zaje` on your target machines, you will need to copy [eng.traineddata](https://github.com/tesseract-ocr/tessdata/raw/refs/heads/main/eng.traineddata) to `/usr/local/share/tessdata`.
49+
You can also set the `TESSDATA_PREFIX` ENV dir if you wish to copy it to a different location.**
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh -e
2+
3+
if [ "$(id -u)" != 0 ];then
4+
echo "You need super user privileges to run this script."
5+
exit 1
6+
fi
7+
8+
apt-get -U -y -q install libdeflate-dev libtiff-dev libsharpyuv-dev libwebp-dev libgif-dev \
9+
liblerc-dev liblzma-dev libjbig-dev libpng-dev libzstd-dev libjpeg-dev build-essential strace
10+
11+
TMPDIR=$(mktemp -d --suffix=_super-zaje)
12+
13+
cd "$TMPDIR"
14+
15+
git clone --depth 1 https://github.com/DanBloomberg/leptonica.git
16+
cd leptonica
17+
./autogen.sh
18+
./configure --with-pic --disable-shared 'CFLAGS=-D DEFAULT_SEVERITY=L_SEVERITY_ERROR -g0 -O3'
19+
make && make install
20+
21+
cd "$TMPDIR"
22+
23+
git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git
24+
cd tesseract
25+
./autogen.sh
26+
./configure --with-pic --disable-shared --disable-legacy --disable-graphics \
27+
--disable-openmp --without-curl --without-archive --disable-doc \
28+
'CXXFLAGS=-DTESS_EXPORTS -g0 -O3 -ffast-math'
29+
make && make install
30+
wget -q https://github.com/tesseract-ocr/tessdata/raw/refs/heads/main/eng.traineddata -P /usr/local/share/tessdata
31+
32+
33+
cd "$TMPDIR"
34+
35+
BIN_NAME=super-zaje
36+
git clone https://github.com/jessp01/zaje.git --recursive
37+
mkdir -p ~/.config/zaje
38+
ln -s ~/zaje/highlight/syntax_files ~/.config/zaje/syntax_files
39+
cd zaje/cmd/super-zaje
40+
CGO_ENABLED=1 GOOS=linux go build -a -tags netgo -ldflags \
41+
'-extldflags "-static -ldeflate -ltiff -L/usr/local/lib -ldeflate -lsharpyuv -lwebp -lLerc -llzma -ljbig -ltesseract -lleptonica -lpng -lzstd -ljpeg -lz -lgif -lsharpyuv -lwebp"' super-zaje.go
42+
43+
set +e
44+
echo "Let's make sure we got a static binary..."
45+
ldd $BIN_NAME
46+
47+
echo "Okay, now let's test it..."
48+
strace ./$BIN_NAME "https://github.com/jessp01/zaje/blob/master/testimg/go1.png?raw=true"
49+
echo $?
50+
echo "Great. Remember to copy /usr/local/share/tessdata to your target machine."

highlight

0 commit comments

Comments
 (0)