Skip to content

Instantly share code, notes, and snippets.

@beejjorgensen
Created June 15, 2026 21:42
Show Gist options
  • Select an option

  • Save beejjorgensen/e3fdf48b8aac0f90704cadf80d51dd95 to your computer and use it in GitHub Desktop.

Select an option

Save beejjorgensen/e3fdf48b8aac0f90704cadf80d51dd95 to your computer and use it in GitHub Desktop.
PKGBUILD for scantools 1.0.7
# Maintainer: Tobias Bachmann <tobachmann@gmx.de>
pkgname=scantools
pkgver=1.0.7
pkgrel=1
pkgdesc="scantools is a library and a matching set of command line applications for graphics manipulation, written with a view towards the handling of scanned documents and generation of high-quality PDF files."
arch=('x86_64')
url="https://kebekus.gitlab.io/scantools/"
license=('GPL')
depends=('qpdf' 'qt5-imageformats' 'gcc' 'graphviz' 'jbig2dec' 'libjpeg-turbo' 'libtiff' 'openjpeg2' 'tesseract' 'qpdf' 'qt5-base' 'zlib' 'poppler-qt5' 'zopfli')
makedepends=('cmake' 'doxygen' 'git')
optdepends=('jbig2enc-git: Encode PDF files with JBIG2 (recommended)')
source=("https://gitlab.com/kebekus/scantools/-/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('a221ddac4a4b375b530a8480e98206933f668c8d5d1d876886f75fb736c92fe2')
prepare() {
cd ${pkgname}-${pkgver}
# Fix FindLeptonica to find modern library name
sed -i 's/NAMES liblept lept/NAMES liblept lept leptonica libleptonica/' cmake/Modules/FindLeptonica.cmake
# Add missing LEPTONICA_INCLUDE_DIR and fix hardcoded 'lept' library name
sed -i 's|INCLUDE_DIRECTORIES(${ZOPFLI_INCLUDE_DIR}|INCLUDE_DIRECTORIES(${LEPTONICA_INCLUDE_DIR} ${ZOPFLI_INCLUDE_DIR}|' src/libscantools/CMakeLists.txt
sed -i 's|TARGET_LINK_LIBRARIES(scantools Qt5::Concurrent Qt5::Gui ${JPEG_LIBRARIES} ${TESSERACT_LIBRARIES} ${JBIG2DEC_LIBRARIES} ${ZOPFLI_LIBRARIES} lept z)|TARGET_LINK_LIBRARIES(scantools Qt5::Concurrent Qt5::Gui ${JPEG_LIBRARIES} ${TESSERACT_LIBRARIES} ${JBIG2DEC_LIBRARIES} ${ZOPFLI_LIBRARIES} ${LEPTONICA_LIBRARIES} z)|' src/libscantools/CMakeLists.txt
# Update PointerHolder to shared_ptr
sed -i 's/PointerHolder<Buffer> data = new Buffer/std::shared_ptr<Buffer> data = std::make_shared<Buffer>/g' src/apps/ocrPDF/PDFmodifier.cpp
}
build() {
cd ${pkgname}-${pkgver}
mkdir build
cd build
cmake -DCMAKE_CXX_FLAGS="-include leptonica/alltypes.h -include leptonica/pix_internal.h" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib ..
make -j $(nproc)
}
package() {
cd ${pkgname}-${pkgver}/build
make DESTDIR="${pkgdir}/" install
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment