diff --git a/databases-iqdb/Makefile b/databases-iqdb/Makefile new file mode 100644 index 0000000..789c130 --- /dev/null +++ b/databases-iqdb/Makefile @@ -0,0 +1,38 @@ +COMMENT = Image Query Database System + +PKGNAME = iqdb-0.1 + +DIST_TUPLE += github e621ng iqdb d42a65ba35523eb46152744d68d8ff302c1c9f92 . + +CATEGORIES = databases + +HOMEPAGE = https://github.com/e621ng/iqdb + +MAINTAINER = "Ed " + +# GPLv2+ +PERMIT_PACKAGE = Yes + +WANTLIB = ${COMPILER_LIBCXX} sqlite3 fmt c m z +WANTLIB += brotlicommon brotlidec brotlienc + +COMPILER = base-clang ports-gcc + +MODULES = devel/cmake + +BUILD_DEPENDS = devel/cmake \ + devel/cpp-httplib \ + devel/sqlite-orm \ + textproc/nlohmann-json + +RUN_DEPENDS = archivers/brotli + +LIB_DEPENDS = databases/sqlite3 \ + devel/fmt + +TEST_DEPENDS = devel/catch2 + +# Missing CMakeLists.txt for test/ +NO_TEST = Yes + +.include diff --git a/databases-iqdb/distinfo b/databases-iqdb/distinfo new file mode 100644 index 0000000..bd7d0a8 --- /dev/null +++ b/databases-iqdb/distinfo @@ -0,0 +1,2 @@ +SHA256 (e621ng-iqdb-d42a65ba35523eb46152744d68d8ff302c1c9f92.tar.gz) = bTpteTsDGqv+IIqi4UOvjO5MP4JCQEoSfTD9+0dhpTo= +SIZE (e621ng-iqdb-d42a65ba35523eb46152744d68d8ff302c1c9f92.tar.gz) = 36290 diff --git a/databases-iqdb/patches/patch-CMakeLists_txt b/databases-iqdb/patches/patch-CMakeLists_txt new file mode 100644 index 0000000..9928cb3 --- /dev/null +++ b/databases-iqdb/patches/patch-CMakeLists_txt @@ -0,0 +1,56 @@ +Index: CMakeLists.txt +--- CMakeLists.txt.orig Mon Sep 16 15:48:16 2024 ++++ CMakeLists.txt Tue Sep 17 16:31:51 2024 +@@ -25,45 +25,15 @@ if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) + endif() + +-include(FetchContent) +- +-FetchContent_Declare( +- httplib +- GIT_REPOSITORY https://github.com/yhirose/cpp-httplib +- GIT_TAG v0.15.3 +-) +- +-FetchContent_Declare( +- json +- URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz +-) +- +-FetchContent_Declare( +- Catch2 +- GIT_REPOSITORY https://github.com/catchorg/Catch2.git +- GIT_TAG v3.6.0 +-) +- +-FetchContent_Declare( +- fmt +- GIT_REPOSITORY https://github.com/fmtlib/fmt +- GIT_TAG 10.2.1 +-) +- +-FetchContent_Declare( +- sqliteOrm +- GIT_REPOSITORY https://github.com/fnc12/sqlite_orm +- GIT_TAG v1.8.2 +-) +- +-FetchContent_MakeAvailable(httplib) +-FetchContent_MakeAvailable(json) +-FetchContent_MakeAvailable(Catch2) +-FetchContent_MakeAvailable(fmt) +-FetchContent_MakeAvailable(sqliteOrm) +- + find_package(SQLite3 REQUIRED) + find_package(Threads REQUIRED) + find_package(PkgConfig REQUIRED) ++find_package(httplib REQUIRED) ++find_package(nlohmann_json REQUIRED) ++find_package(Catch2) ++find_package(fmt REQUIRED) ++find_package(SqliteOrm REQUIRED) + + add_subdirectory(src) ++ ++install(TARGETS iqdb RUNTIME) diff --git a/databases-iqdb/patches/patch-src_iqdb_cpp b/databases-iqdb/patches/patch-src_iqdb_cpp new file mode 100644 index 0000000..14c0084 --- /dev/null +++ b/databases-iqdb/patches/patch-src_iqdb_cpp @@ -0,0 +1,18 @@ +fix segmentation fault when using no parameters with ./iqdb http + +Index: src/iqdb.cpp +--- src/iqdb.cpp.orig Mon Sep 16 16:01:50 2024 ++++ src/iqdb.cpp Mon Sep 16 16:01:47 2024 +@@ -42,9 +42,9 @@ int main(int argc, char **argv) { + } + + if (!strcasecmp(argv[1], "http")) { +- const std::string host = argc >= 2 ? argv[2] : "localhost"; +- const int port = argc >= 3 ? std::stoi(argv[3]) : 8000; +- const std::string filename = argc >= 4 ? argv[4] : "iqdb.db"; ++ const std::string host = argc > 2 ? argv[2] : "localhost"; ++ const int port = argc > 3 ? std::stoi(argv[3]) : 8000; ++ const std::string filename = argc > 4 ? argv[4] : "iqdb.db"; + + http_server(host, port, filename); + } else { diff --git a/databases-iqdb/pkg/DESCR b/databases-iqdb/pkg/DESCR new file mode 100644 index 0000000..3a09e22 --- /dev/null +++ b/databases-iqdb/pkg/DESCR @@ -0,0 +1,6 @@ +IQDB is a reverse image search system. +It lets you search a database of images to find images that are visually similar to a given image. + +This version of IQDB is a fork of the original IQDB used by https://iqdb.org. +This version powers the reverse image search for E621. + diff --git a/databases-iqdb/pkg/PLIST b/databases-iqdb/pkg/PLIST new file mode 100644 index 0000000..61648af --- /dev/null +++ b/databases-iqdb/pkg/PLIST @@ -0,0 +1,13 @@ +@newgroup _iqdb:898 +@newuser _iqdb:898:898:default:iqdb daemon:/var/empty:/sbin/nologin +@rcscript ${RCDIR}/iqdb +@bin bin/iqdb +@mode 750 +@owner _iqdb +@group _iqdb +@sample ${LOCALSTATEDIR}/db/iqdb/ +@group wheel +@sample ${LOCALSTATEDIR}/log/iqdb/ +@mode +@owner +@group diff --git a/databases-iqdb/pkg/iqdb.rc b/databases-iqdb/pkg/iqdb.rc new file mode 100644 index 0000000..ac0eb98 --- /dev/null +++ b/databases-iqdb/pkg/iqdb.rc @@ -0,0 +1,15 @@ +#!/bin/ksh + +daemon="${TRUEPREFIX}/bin/iqdb" +daemon_flags="127.0.0.1 5588 /var/db/iqdb/e621_v2.db" +daemon_user=_iqdb + +. /etc/rc.d/rc.subr + +pexp="$(eval echo ${daemon} http ${daemon_flags:+ ${daemon_flags}})" + +rc_start() { + rc_exec "${daemon} http ${daemon_flags} >/var/log/iqdb/iqdb.log 2>&1 &" +} + +rc_cmd $1