From ee81f3968f20f51f2b5ec3de957dc9b151ed43e8 Mon Sep 17 00:00:00 2001
From: Alexander Langanke <alexlanganke@gmail.com>
Date: Wed, 8 Jun 2022 01:22:18 -0700
Subject: [PATCH] Add snapcraft.yaml

---
 snapcraft.yaml | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 snapcraft.yaml

diff --git a/snapcraft.yaml b/snapcraft.yaml
new file mode 100644
index 000000000..cfa569a36
--- /dev/null
+++ b/snapcraft.yaml
@@ -0,0 +1,70 @@
+name: ocrmypdf
+title: OCRmyPDF
+base: core20
+version: git
+summary: OCRmyPDF adds optical character recognition (OCR) to PDFs
+description: OCRmyPDF packaged for snap
+grade: stable
+confinement: strict
+
+architectures: [amd64]
+
+environment:
+  TESSDATA_PREFIX: $SNAP/usr/share/tesseract-ocr/4.00/tessdata
+  GS_LIB: $SNAP/usr/share/ghostscript/9.50/Resource/Init
+  GS_FONTPATH: $SNAP/usr/share/ghostscript/9.50/Resource/Font
+  LD_LIBRARY_PATH: $SNAP/usr/lib/x86_64-linux-gnu
+
+apps:
+  ocrmypdf:
+    command: usr/bin/snapcraft-preload python3 -m ocrmypdf
+    plugs:
+      - desktop
+      - desktop-legacy
+      - wayland
+      - x11
+      - home
+      - removable-media
+
+parts:
+  snapcraft-preload:
+    source: https://github.com/sergiusens/snapcraft-preload.git
+    plugin: cmake
+    cmake-parameters:
+      - -DCMAKE_INSTALL_PREFIX=/usr -DLIBPATH=/usr/lib
+    build-packages:
+      - on amd64:
+          - gcc-multilib
+          - g++-multilib
+    stage-packages:
+      - lib32stdc++6
+
+  ocrmypdf:
+    plugin: python
+    source: https://github.com/ocrmypdf/OCRmyPDF.git
+
+    stage-packages:
+      - ghostscript
+      - icc-profiles-free
+      - liblept5
+      - libxml2
+      - pngquant
+      - tesseract-ocr-all
+      - unpaper
+      - qpdf
+      - zlib1g
+
+    python-packages:
+      - cffi
+      - pdfminer.six
+      - pikepdf
+      - Pillow
+      - pluggy
+      - reportlab
+      - setuptools
+      - tqdm
+      - pipe
+
+    override-build: |
+      snapcraftctl build
+      ln -sf ../usr/lib/libsnapcraft-preload.so $SNAPCRAFT_PART_INSTALL/lib/libsnapcraft-preload.so