summaryrefslogtreecommitdiff
path: root/roles/devami/tasks/tesseract.yml
blob: 7ad7da32e87e3a1f3e64e7b3e828eb326f0d607d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
# Installs tesseract

- name: Install tesseract dependencies
  package: name={{ item }} state=present
  with_items:
    - gcc-c++
    - make
    - autoconf
    - automake
    - libtool
    - pkgconfig
    - libpng12-devel
    - libjpeg-turbo-devel
    - libtiff-devel
    - zlib-devel

- name: Install tesseract training dependencies
  package: name={{ item }} state=present
  with_items:
    - libicu-devel
    - pango-devel
    - cairo-devel

- name: Install extra tesseract development dependencies
  package: name={{ item }} state=present
  with_items:
    - git

- name: Clone leptonica repository
  git:
    repo: https://github.com/DanBloomberg/leptonica
    dest: /home/ec2-user/leptonica
    version: 1.77.0
    depth: 1

- name: Configure leptonica environ.h
  lineinfile:
    dest: /home/ec2-user/leptonica/src/environ.h
    line: {{ item }}
    insertbefore: "^#endif * LEPTONICA_ENVIRON_H"
  with_items:
    - "#define HAVE_FMEMOPEN 1"
    - "#define HAVE_FSTATAT 1"

- name: Build leptonica
  make:
    chdir: /home/ec2-user/leptonica/src
    target: "-f makefile.static shared"
    params: SHARED=yes

# TODO: in due course replace this with our repo and branch
- name: Clone tesseract repository
  git:
    repo: https://github.com/tesseract-ocr/tesseract
    dest: /home/ec2-user/tesseract
    version: 4.0.0
    depth: 1

- name: Run autogen.sh for tesseract
  command: /home/ec2-user/tesseract/autogen.sh
  args:
    chdir: /home/ec2-user/tesseract
    creates: /home/ec2-user/tesseract/configure

# NOTE: lept headers and libs dirs are probably incorrect
# TODO: split the shell line if possible
- name: Run configure for tesseract
  shell: LIBLEPT_HEADERSDIR=$HOME/leptonica/src/ /home/ec2-user/tesseract/configure --prefix=$HOME/tessinstall/ --with-extra-libraries=$HOME/leptonica/src
  args:
    chdir: /home/ec2-user/tesseract
    creates: /home/ec2-user/tesseract/makefile

- name: Build and install tesseract
  make: chdir=/home/ec2-user/tesseract target=install

- name: Build and install tesseract training tools
  make: chdir=/home/ec2-user/tesseract target=training-install