diff --git a/packages/k2pdfopt/0001-CMakeLists.txt-bugs.patch b/packages/k2pdfopt/0001-CMakeLists.txt-bugs.patch new file mode 100644 index 000000000..c2c82b35a --- /dev/null +++ b/packages/k2pdfopt/0001-CMakeLists.txt-bugs.patch @@ -0,0 +1,32 @@ +From c3854782865bb2f59fbc63fcde69f44d699329ef Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:47:43 +0800 +Subject: [PATCH 1/7] CMakeLists.txt: bugs + +--- + CMakeLists.txt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4a2378b..fbc6430 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -105,6 +105,7 @@ configure_file ( + "${PROJECT_SOURCE_DIR}/config.h.in" + "${PROJECT_BINARY_DIR}/config.h" + ) ++include_directories(${PROJECT_BINARY_DIR}) + + add_subdirectory(willuslib) + add_subdirectory(k2pdfoptlib) +@@ -113,6 +114,7 @@ add_subdirectory(k2pdfoptlib) + add_executable(k2pdfopt k2pdfopt.c) + target_link_libraries (k2pdfopt k2pdfoptlib willuslib ${K2PDFOPT_LIB}) + ++install(TARGETS k2pdfopt RUNTIME DESTINATION bin) + + message("") + message("-- Summary --") +-- +2.20.1 + diff --git a/packages/k2pdfopt/0002-CMakeLists.txt-no-mupdf.patch b/packages/k2pdfopt/0002-CMakeLists.txt-no-mupdf.patch new file mode 100644 index 000000000..fef9cee6f --- /dev/null +++ b/packages/k2pdfopt/0002-CMakeLists.txt-no-mupdf.patch @@ -0,0 +1,33 @@ +From 1efc9391753d9bcab233dd90fbf48d3f9f9b99af Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:48:24 +0800 +Subject: [PATCH 2/7] CMakeLists.txt: no mupdf + +--- + CMakeLists.txt | 10 ---------- + 1 file changed, 10 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fbc6430..ac01ed0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -73,16 +73,6 @@ endif(GHOSTSCRIPT_EXECUTABLE) + # libfreetype6 (>= 2.3.9), libjbig2dec0, libjpeg8 (>= 8c), libx11-6, libxext6, zlib1g (>= 1:1.2.0) + # MUPDF_STATIC_LDFLAGS misses mupdf-js-none, and doubles libs ... + +-pkg_check_modules(MUPDF mupdf) +-if(MUPDF_FOUND) +- set(HAVE_MUPDF_LIB 1) +- # (includes jbig2dec, openjpeg, freetype) +- include_directories(SYSTEM ${MUPDF_INCLUDEDIR}) +- message(STATUS "mupdf libraries: ${MUPDF_LDFLAGS}") +- set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${MUPDF_LDFLAGS} +- -lmupdf-js-none -lopenjpeg -ljbig2dec -ljpeg -lfreetype +- ) +-endif(MUPDF_FOUND) + + pkg_check_modules(DJVU ddjvuapi) + if(DJVU_FOUND) +-- +2.20.1 + diff --git a/packages/k2pdfopt/0003-CMakeLists.txt-no-detect-ghostscript-at-compile-time.patch b/packages/k2pdfopt/0003-CMakeLists.txt-no-detect-ghostscript-at-compile-time.patch new file mode 100644 index 000000000..14f2d6df6 --- /dev/null +++ b/packages/k2pdfopt/0003-CMakeLists.txt-no-detect-ghostscript-at-compile-time.patch @@ -0,0 +1,35 @@ +From 474bb51fb6fa9abbcfc9f1016ba90d893cd5a9ec Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:48:40 +0800 +Subject: [PATCH 3/7] CMakeLists.txt: no detect ghostscript at compile time + +--- + CMakeLists.txt | 12 +----------- + 1 file changed, 1 insertion(+), 11 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ac01ed0..ecba1c3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -54,17 +54,7 @@ if(JASPER_FOUND) + set(HAVE_JASPER_LIB 1) + endif(JASPER_FOUND) + +-# paths from willuslib/wgs.c +-find_program(GHOSTSCRIPT_EXECUTABLE gs +-# PATHS /usr/bin /usr/share/gs /usr/local/gs /opt/gs +-# /usr/share/gs* /usr/local/gs* /opt/gs* +-) +-if(GHOSTSCRIPT_EXECUTABLE) +- set(HAVE_GHOSTSCRIPT 1) +- message(STATUS "Found ghostscript executable") +-else() +- message(STATUS "Could NOT find ghostscript executable") +-endif(GHOSTSCRIPT_EXECUTABLE) ++set(HAVE_GHOSTSCRIPT 1) + + # willus.h + # HAVE_GSL_LIB +-- +2.20.1 + diff --git a/packages/k2pdfopt/0004-willuslib-CMakeLists.txt-typo.patch b/packages/k2pdfopt/0004-willuslib-CMakeLists.txt-typo.patch new file mode 100644 index 000000000..35cc9a2a6 --- /dev/null +++ b/packages/k2pdfopt/0004-willuslib-CMakeLists.txt-typo.patch @@ -0,0 +1,33 @@ +From 4bde754a3fab11b4c7d0e966dca2ba7a3cee7666 Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:49:10 +0800 +Subject: [PATCH 4/7] willuslib/CMakeLists.txt: typo + +--- + willuslib/CMakeLists.txt | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/willuslib/CMakeLists.txt b/willuslib/CMakeLists.txt +index 463bbc9..500c926 100644 +--- a/willuslib/CMakeLists.txt ++++ b/willuslib/CMakeLists.txt +@@ -6,7 +6,7 @@ include_directories(..) + set(WILLUSLIB_SRC + ansi.c array.c bmp.c bmpdjvu.c bmpmupdf.c dtcompress.c filelist.c + fontdata.c fontrender.c gslpolyfit.c linux.c math.c mem.c ocr.c +- ocrjocr.c ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c ++ ocrgocr.c ocrtess.c pdfwrite.c point2d.c render.c strbuf.c string.c + token.c wfile.c wgs.c wgui.c willusversion.c win.c winbmp.c + wincomdlg.c winmbox.c winshell.c wmupdf.c wmupdfinfo.c wpdf.c wsys.c + wzfile.c wleptonica.c +@@ -26,6 +26,6 @@ message("-- Willuslib sources: ${WILLUSLIB_SRC}") + + add_library(willuslib ${WILLUSLIB_SRC}) + +-# HAVE_GOCR_LIB: ocrjocr.c ++# HAVE_GOCR_LIB: ocrgocr.c + # HAVE_TESSERACT_LIB: ocrtess.c + +-- +2.20.1 + diff --git a/packages/k2pdfopt/0005-willuslib-ocrtess.c-use-system-leptonica.patch b/packages/k2pdfopt/0005-willuslib-ocrtess.c-use-system-leptonica.patch new file mode 100644 index 000000000..aaaa365c8 --- /dev/null +++ b/packages/k2pdfopt/0005-willuslib-ocrtess.c-use-system-leptonica.patch @@ -0,0 +1,49 @@ +From 3ad840c8df25ac73df7ede81f4025a1e781a9e5b Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:51:09 +0800 +Subject: [PATCH 5/7] willuslib/ocrtess.c: use system leptonica + +--- + willuslib/ocrtess.c | 3 +-- + willuslib/wleptonica.c | 4 ++-- + 2 files changed, 3 insertions(+), 4 deletions(-) + +diff --git a/willuslib/ocrtess.c b/willuslib/ocrtess.c +index e1366e1..58aaf97 100644 +--- a/willuslib/ocrtess.c ++++ b/willuslib/ocrtess.c +@@ -24,8 +24,7 @@ + #include + #include + #include +-#include +-#include ++#include + #include "willus.h" + + +diff --git a/willuslib/wleptonica.c b/willuslib/wleptonica.c +index a4e3cfd..a85be09 100644 +--- a/willuslib/wleptonica.c ++++ b/willuslib/wleptonica.c +@@ -23,7 +23,7 @@ + #include "willus.h" + + #ifdef HAVE_LEPTONICA_LIB +-#include ++#include + + static void wlept_pix_from_bmp(PIX **pixptr,WILLUSBITMAP *bmp); + static void wlept_bmp_from_pix(WILLUSBITMAP *bmp,PIX *pix); +@@ -135,7 +135,7 @@ pixWrite("pixb.png",pixb,IFF_PNG); + dew1=dewarpCreate(pixb,1); + pixDestroy(&pixb); + dewarpaInsertDewarp(dewa,dew1); +- dewarpBuildPageModel_ex(dew1,debug,fit_order); ++ dewarpBuildPageModel(dew1,debug); + if (bmp1!=NULL) + { + PIX *pix2,*pix2d; +-- +2.20.1 + diff --git a/packages/k2pdfopt/0006-k2pdfopt.h-dst_ocr_visibility_flags-workaround.patch b/packages/k2pdfopt/0006-k2pdfopt.h-dst_ocr_visibility_flags-workaround.patch new file mode 100644 index 000000000..0317d2fb3 --- /dev/null +++ b/packages/k2pdfopt/0006-k2pdfopt.h-dst_ocr_visibility_flags-workaround.patch @@ -0,0 +1,32 @@ +From b365ecd574645c7fdb0ebe5b63cf465e134b4404 Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 16:52:13 +0800 +Subject: [PATCH 6/7] k2pdfopt.h: dst_ocr_visibility_flags workaround + +--- + k2pdfoptlib/k2pdfopt.h | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/k2pdfoptlib/k2pdfopt.h b/k2pdfoptlib/k2pdfopt.h +index 13d1802..0605405 100644 +--- a/k2pdfoptlib/k2pdfopt.h ++++ b/k2pdfoptlib/k2pdfopt.h +@@ -259,7 +259,6 @@ typedef struct + int text_only; /* Do not send figures to output file */ + + /* OCR */ +-#ifdef HAVE_OCR_LIB + char ocrout[128]; + int dst_ocr; + int ocr_detection_type; /* New in v2.50, 'w', 'l', or 'p' */ +@@ -284,7 +283,6 @@ typedef struct + double ocr_max_height_inches; + OCRWORDS dst_ocrwords; + int sort_ocr_text; +-#endif + + int dst_userdpi; /* Specified device DPI, not including magnification */ + int dst_dpi; /* Device virtual DPI--takes magnification/fontsize into account */ +-- +2.20.1 + diff --git a/packages/k2pdfopt/0007-CMakeLists.txt-fix-leptonica.patch b/packages/k2pdfopt/0007-CMakeLists.txt-fix-leptonica.patch new file mode 100644 index 000000000..fb8f84487 --- /dev/null +++ b/packages/k2pdfopt/0007-CMakeLists.txt-fix-leptonica.patch @@ -0,0 +1,41 @@ +From 294bc0b6ca59c37c8691255a1ef401e023b00cfa Mon Sep 17 00:00:00 2001 +From: yangfl +Date: Mon, 7 Jan 2019 19:42:41 +0800 +Subject: [PATCH 7/7] CMakeLists.txt: fix leptonica + +--- + CMakeLists.txt | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ecba1c3..bd0dd34 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -10,7 +10,7 @@ set(K2PDFOPT_LIB "-lm") + # cmake -DCMAKE_BUILD_TYPE=Debug + + # TODO: configure flavour with opions +-## ++## + ## option (USE_MUPDF + ## "Use muPDF libraries" OFF) + ## option (USE_GHOSTSCRIPT +@@ -72,7 +72,14 @@ if(DJVU_FOUND) + endif(DJVU_FOUND) + + # HAVE_GOCR_LIB +-# HAVE_LEPTONICA_LIB ++ ++pkg_check_modules(LEPTONICA lept) ++if(LEPTONICA_FOUND) ++ set(HAVE_LEPTONICA_LIB 1) ++ include_directories(SYSTEM ${LEPTONICA_INCLUDEDIR}) ++ set(K2PDFOPT_LIB ${K2PDFOPT_LIB} ${LEPTONICA_LDFLAGS}) ++endif(LEPTONICA_FOUND) ++ + # HAVE_TESSERACT_LIB + + # ---- Describe project +-- +2.20.1 + diff --git a/packages/k2pdfopt/build.sh b/packages/k2pdfopt/build.sh new file mode 100644 index 000000000..37218ea95 --- /dev/null +++ b/packages/k2pdfopt/build.sh @@ -0,0 +1,12 @@ +TERMUX_PKG_HOMEPAGE=http://www.willus.com/k2pdfopt/ +TERMUX_PKG_DESCRIPTION="A tool that optimizes PDF files for viewing on mobile readers" +TERMUX_PKG_LICENSE="GPL-3.0" +TERMUX_PKG_VERSION=2.51 +TERMUX_PKG_SRCURL=http://www.willus.com/k2pdfopt/src/k2pdfopt_v${TERMUX_PKG_VERSION}_src.zip +TERMUX_PKG_SHA256=3e6e4d7aac9c9bed4c7854888a6a91213be10121be76e17f83e080e829ac5fde +TERMUX_PKG_DEPENDS="leptonica, libjasper, libjpeg-turbo, libpng, mupdf, netpbm, zlib" +TERMUX_PKG_BUILD_IN_SRC=true + +termux_step_pre_configure() { + LDFLAGS+=" -llog" +} diff --git a/packages/k2pdfopt/fix-implicit-decls.patch b/packages/k2pdfopt/fix-implicit-decls.patch new file mode 100644 index 000000000..7485db83c --- /dev/null +++ b/packages/k2pdfopt/fix-implicit-decls.patch @@ -0,0 +1,120 @@ +diff -uNr k2pdfopt_v2.51/willuslib/ocrtess.c k2pdfopt_v2.51.mod/willuslib/ocrtess.c +--- k2pdfopt_v2.51/willuslib/ocrtess.c 2020-01-01 21:00:39.794259355 +0200 ++++ k2pdfopt_v2.51.mod/willuslib/ocrtess.c 2020-01-01 21:11:30.131964011 +0200 +@@ -38,35 +38,39 @@ + static void endian_flip(char *x,int n); + + /* +-** Returns 0 for success, NZ for failure. ++** Determine OCR path. Check both TESSDATA_PREFIX\tessdata AND TESSDATA_PREFIX + */ +-void *ocrtess_init(char *datadir,char *tesspath,int maxtesspathlen, +- char *lang,FILE *out,char *initstr,int maxlen,int *status) ++void ocrtess_datapath(char *datapath,char *suggested,int maxlen) + + { +- char langdef[16]; +- void *api; +- char tesspath0[MAXFILENAMELEN]; ++ char path1[MAXFILENAMELEN-12]; ++ char path[MAXFILENAMELEN]; ++ char *p; + +- ocrtess_datapath(tesspath0,datadir,MAXFILENAMELEN-1); +- if (tesspath!=NULL) ++ if (suggested!=NULL) + { +- strncpy(tesspath,tesspath0,maxtesspathlen-1); +- tesspath[maxtesspathlen-1]='\0'; ++ strncpy(datapath,suggested,maxlen-1); ++ datapath[maxlen-1]='\0'; ++ return; + } +- if (lang==NULL || lang[0]=='\0') +- ocrtess_lang_default(tesspath0,NULL,0,langdef,16,NULL,0,0); +- else ++ if ((p=getenv("TESSDATA_PREFIX"))==NULL) + { +- strncpy(langdef,lang,15); +- langdef[15]='\0'; ++ datapath[0]='\0'; ++ return; + } +- /* Tess v4.00 needs only one attempt with ocrtype=0 */ +- api=tess_capi_init(tesspath0,langdef,0,out,initstr,maxlen,status); +- return(api); ++ strncpy(path1,p,MAXFILENAMELEN-13); ++ path1[MAXFILENAMELEN-13]='\0'; ++ wfile_fullname(path,path1,"tessdata"); ++ if (wfile_status(path)==2) ++ { ++ strncpy(datapath,path,maxlen-1); ++ datapath[maxlen-1]='\0'; ++ return; ++ } ++ strncpy(datapath,p,maxlen-1); ++ datapath[maxlen-1]='\0'; + } + +- + void ocrtess_lang_default(char *datadir,char *tesspath,int maxtesspathlen, + char *langdef,int maxlen,char *tessdebug,int maxdebug,int use_ansi) + +@@ -170,39 +174,33 @@ + filelist_free(fl); + } + +- + /* +-** Determine OCR path. Check both TESSDATA_PREFIX\tessdata AND TESSDATA_PREFIX ++** Returns 0 for success, NZ for failure. + */ +-void ocrtess_datapath(char *datapath,char *suggested,int maxlen) ++void *ocrtess_init(char *datadir,char *tesspath,int maxtesspathlen, ++ char *lang,FILE *out,char *initstr,int maxlen,int *status) + + { +- char path1[MAXFILENAMELEN-12]; +- char path[MAXFILENAMELEN]; +- char *p; ++ char langdef[16]; ++ void *api; ++ char tesspath0[MAXFILENAMELEN]; + +- if (suggested!=NULL) +- { +- strncpy(datapath,suggested,maxlen-1); +- datapath[maxlen-1]='\0'; +- return; +- } +- if ((p=getenv("TESSDATA_PREFIX"))==NULL) ++ ocrtess_datapath(tesspath0,datadir,MAXFILENAMELEN-1); ++ if (tesspath!=NULL) + { +- datapath[0]='\0'; +- return; ++ strncpy(tesspath,tesspath0,maxtesspathlen-1); ++ tesspath[maxtesspathlen-1]='\0'; + } +- strncpy(path1,p,MAXFILENAMELEN-13); +- path1[MAXFILENAMELEN-13]='\0'; +- wfile_fullname(path,path1,"tessdata"); +- if (wfile_status(path)==2) ++ if (lang==NULL || lang[0]=='\0') ++ ocrtess_lang_default(tesspath0,NULL,0,langdef,16,NULL,0,0); ++ else + { +- strncpy(datapath,path,maxlen-1); +- datapath[maxlen-1]='\0'; +- return; ++ strncpy(langdef,lang,15); ++ langdef[15]='\0'; + } +- strncpy(datapath,p,maxlen-1); +- datapath[maxlen-1]='\0'; ++ /* Tess v4.00 needs only one attempt with ocrtype=0 */ ++ api=tess_capi_init(tesspath0,langdef,0,out,initstr,maxlen,status); ++ return(api); + } + + diff --git a/packages/k2pdfopt/jasper-fix.patch b/packages/k2pdfopt/jasper-fix.patch new file mode 100644 index 000000000..858a4c926 --- /dev/null +++ b/packages/k2pdfopt/jasper-fix.patch @@ -0,0 +1,24 @@ +diff -aur src.orig/k2pdfopt_v2.51/CMakeLists.txt src/k2pdfopt_v2.51/CMakeLists.txt +--- a/CMakeLists.txt 2019-03-24 21:45:17.683484849 +0100 ++++ b/CMakeLists.txt 2019-03-24 21:46:17.443514984 +0100 +@@ -5,7 +5,7 @@ + + include(FindPkgConfig) + +-set(K2PDFOPT_LIB "-lm") ++set(K2PDFOPT_LIB "-lm -ljasper") + + # cmake -DCMAKE_BUILD_TYPE=Debug + +diff -aur src.orig/k2pdfopt_v2.51/willuslib/bmp.c src/k2pdfopt_v2.51/willuslib/bmp.c +--- a/willuslib/bmp.c 2019-01-01 00:21:16.000000000 +0100 ++++ b/willuslib/bmp.c 2019-03-24 21:45:48.713500408 +0100 +@@ -37,7 +37,7 @@ + #include + #endif + #ifdef HAVE_JASPER_LIB +-#include ++#include + #endif + + #define BOUND(x,xmin,xmax) if ((x)<(xmin)) (x)=(xmin); else { if ((x)>(xmax)) (x)=(xmax); }