From 908def1016ca81b746b89dc2839d232aceaef0ce Mon Sep 17 00:00:00 2001 From: simon987 Date: Wed, 5 May 2021 14:13:46 -0400 Subject: [PATCH] Fix build, update dockerfile --- .dockerignore | 23 +++++++++++++++++++++++ CMakeLists.txt | 12 +++++++----- DockerArm64/Dockerfile | 22 ---------------------- DockerArm64/build.sh | 13 ------------- Docker/Dockerfile => Dockerfile | 14 +++++++++++--- Dockerfile.arm64 | 1 + src/cli.c | 1 + src/cli.h | 1 + src/main.c | 5 ++++- src/static/search.html | 2 +- src/static/stats.html | 2 +- src/web/serve.c | 2 +- 12 files changed, 51 insertions(+), 47 deletions(-) create mode 100644 .dockerignore delete mode 100644 DockerArm64/Dockerfile delete mode 100755 DockerArm64/build.sh rename Docker/Dockerfile => Dockerfile (76%) create mode 100644 Dockerfile.arm64 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..571043a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +.idea +*/thumbs +*.cbp +CMakeCache.txt +CMakeFiles +cmake-build-debug +cmake_install.cmake +Makefile +*.out +LOG +sist2* +index.sist2/ +bundle*.css +bundle.js +**/*.a +**/vgcore.* +build/ +.git/ +third-party/libscan/libscan-test-files/ +**/ext_ffmpeg +**/ext_libmobi +**/scan_a_test +Dockerfile \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a02c37..34516e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ project(sist2 C) option(SIST_DEBUG "Build a debug executable" on) -set(BUILD_TESTS off) +set(BUILD_TESTS on) add_subdirectory(third-party/libscan) set(ARGPARSE_SHARED off) add_subdirectory(third-party/argparse) @@ -36,14 +36,15 @@ add_executable(sist2 target_link_directories(sist2 PRIVATE BEFORE ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/) set(CMAKE_FIND_LIBRARY_SUFFIXES .a .lib) +find_package(PkgConfig REQUIRED) + +pkg_search_module(GLIB REQUIRED glib-2.0) + find_package(lmdb CONFIG REQUIRED) find_package(cJSON CONFIG REQUIRED) -find_package(unofficial-glib CONFIG REQUIRED) find_package(unofficial-mongoose CONFIG REQUIRED) find_package(CURL CONFIG REQUIRED) -#find_package(OpenSSL REQUIRED) - target_include_directories( sist2 PUBLIC @@ -51,6 +52,7 @@ target_include_directories( ${CMAKE_SOURCE_DIR}/third-party/utf8.h/ ${CMAKE_SOURCE_DIR}/third-party/libscan/ ${CMAKE_SOURCE_DIR}/ + ${GLIB_INCLUDE_DIRS} ) target_compile_options( @@ -103,7 +105,7 @@ target_link_libraries( lmdb cjson argparse - unofficial::glib::glib + ${GLIB_LDFLAGS} unofficial::mongoose::mongoose CURL::libcurl diff --git a/DockerArm64/Dockerfile b/DockerArm64/Dockerfile deleted file mode 100644 index bb910ec..0000000 --- a/DockerArm64/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:19.10 -MAINTAINER simon987 - -RUN apt update -RUN apt install -y libglib2.0-0 libcurl4 libmagic1 libharfbuzz-bin libopenjp2-7 libarchive13 liblzma5 libzstd1 liblz4-1 \ - curl libtiff5 libpng16-16 libpcre3 - -RUN mkdir -p /usr/share/tessdata && \ - cd /usr/share/tessdata/ && \ - curl -o /usr/share/tessdata/hin.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/hin.traineddata &&\ - curl -o /usr/share/tessdata/jpn.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/jpn.traineddata &&\ - curl -o /usr/share/tessdata/eng.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/eng.traineddata &&\ - curl -o /usr/share/tessdata/fra.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/fra.traineddata &&\ - curl -o /usr/share/tessdata/rus.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/rus.traineddata &&\ - curl -o /usr/share/tessdata/spa.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/spa.traineddata && ls -lh - -ADD sist2_arm64 /root/sist2 - -ENV LANG C.UTF-8 -ENV LC_ALL C.UTF-8 - -ENTRYPOINT ["/root/sist2"] diff --git a/DockerArm64/build.sh b/DockerArm64/build.sh deleted file mode 100755 index 55d30ab..0000000 --- a/DockerArm64/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -rm ./sist2_arm64 -cp ../sist2_arm64.gz . -gzip -d sist2_arm64.gz - -version=$(./sist2_arm64 --version) - -echo "Version ${version}" -docker build . -t simon987/sist2-arm64:"${version}" -t simon987/sist2-arm64:latest - -docker push simon987/sist2-arm64:"${version}" -docker push simon987/sist2-arm64:latest - -docker run --rm simon987/sist2-arm64 -v \ No newline at end of file diff --git a/Docker/Dockerfile b/Dockerfile similarity index 76% rename from Docker/Dockerfile rename to Dockerfile index 08f6e12..4b525cd 100644 --- a/Docker/Dockerfile +++ b/Dockerfile @@ -1,6 +1,14 @@ -FROM ubuntu:20.04 +FROM simon987/sist2-build as build MAINTAINER simon987 +WORKDIR /build/ +ADD . /build/ +RUN cmake -DSIST_DEBUG=off -DBUILD_TESTS=off -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake . +RUN make -j$(nproc) +RUN strip sist2 + +FROM ubuntu:20.10 + RUN apt update RUN apt install -y libglib2.0-0 libcurl4 libmagic1 libharfbuzz-bin libopenjp2-7 libarchive13 liblzma5 libzstd1 liblz4-1 \ curl libtiff5 libpng16-16 libpcre3 @@ -12,9 +20,9 @@ RUN mkdir -p /usr/share/tessdata && \ curl -o /usr/share/tessdata/eng.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/eng.traineddata &&\ curl -o /usr/share/tessdata/fra.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/fra.traineddata &&\ curl -o /usr/share/tessdata/rus.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/rus.traineddata &&\ - curl -o /usr/share/tessdata/spa.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/spa.traineddata && ls -lh + curl -o /usr/share/tessdata/spa.traineddata https://raw.githubusercontent.com/tesseract-ocr/tessdata/master/spa.traineddata -ADD sist2 /root/sist2 +COPY --from=build /build/sist2 /root/sist2 ENV LANG C.UTF-8 ENV LC_ALL C.UTF-8 diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..f87f5c1 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1 @@ +# TODO \ No newline at end of file diff --git a/src/cli.c b/src/cli.c index 1cd8f2c..2aa3c54 100644 --- a/src/cli.c +++ b/src/cli.c @@ -227,6 +227,7 @@ int scan_args_validate(scan_args_t *args, int argc, const char **argv) { LOG_DEBUGF("cli.c", "arg depth=%d", args->depth) LOG_DEBUGF("cli.c", "arg path=%s", args->path) LOG_DEBUGF("cli.c", "arg archive=%s", args->archive) + LOG_DEBUGF("cli.c", "arg archive_passphrase=%s", args->archive_passphrase) LOG_DEBUGF("cli.c", "arg tesseract_lang=%s", args->tesseract_lang) LOG_DEBUGF("cli.c", "arg tesseract_path=%s", args->tesseract_path) LOG_DEBUGF("cli.c", "arg exclude=%s", args->exclude_regex) diff --git a/src/cli.h b/src/cli.h index 90242aa..085807b 100644 --- a/src/cli.h +++ b/src/cli.h @@ -18,6 +18,7 @@ typedef struct scan_args { char *path; char *archive; archive_mode_t archive_mode; + char *archive_passphrase; char *tesseract_lang; const char *tesseract_path; char *exclude_regex; diff --git a/src/main.c b/src/main.c index 54d8b14..b3e2bdb 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ #define EPILOG "Made by simon987 . Released under GPL-3.0" -static const char *const Version = "2.9.0"; +static const char *const Version = "2.9.1"; static const char *const usage[] = { "sist2 scan [OPTION]... PATH", "sist2 index [OPTION]... INDEX", @@ -99,6 +99,7 @@ void initialize_scan_context(scan_args_t *args) { ScanCtx.arc_ctx.log = _log; ScanCtx.arc_ctx.logf = _logf; ScanCtx.arc_ctx.parse = (parse_callback_t) parse; + memset(ScanCtx.arc_ctx.passphrase, 0, sizeof(ScanCtx.arc_ctx.passphrase)); // Comic ScanCtx.comic_ctx.log = _log; @@ -440,6 +441,8 @@ int main(int argc, const char *argv[]) { OPT_STRING(0, "archive", &scan_args->archive, "Archive file mode (skip|list|shallow|recurse). " "skip: Don't parse, list: only get file names as text, " "shallow: Don't parse archives inside archives. DEFAULT: recurse"), + OPT_STRING(0, "archive-passphrase", &scan_args->archive_passphrase, "Passphrase for encrypted archive files"), + OPT_STRING(0, "ocr", &scan_args->tesseract_lang, "Tesseract language (use tesseract --list-langs to see " "which are installed on your machine)"), OPT_STRING('e', "exclude", &scan_args->exclude_regex, "Files that match this regex will not be scanned"), diff --git a/src/static/search.html b/src/static/search.html index d55a765..b675a76 100644 --- a/src/static/search.html +++ b/src/static/search.html @@ -12,7 +12,7 @@