databases/iqdb

This commit is contained in:
edshot99 2024-09-17 18:10:48 -05:00
parent 8c23e8c173
commit 248b03c3fd
7 changed files with 148 additions and 0 deletions

38
databases-iqdb/Makefile Normal file
View File

@ -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 <ed@i2pmail.org>"
# 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 <bsd.port.mk>

2
databases-iqdb/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (e621ng-iqdb-d42a65ba35523eb46152744d68d8ff302c1c9f92.tar.gz) = bTpteTsDGqv+IIqi4UOvjO5MP4JCQEoSfTD9+0dhpTo=
SIZE (e621ng-iqdb-d42a65ba35523eb46152744d68d8ff302c1c9f92.tar.gz) = 36290

View File

@ -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)

View File

@ -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 {

6
databases-iqdb/pkg/DESCR Normal file
View File

@ -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.

13
databases-iqdb/pkg/PLIST Normal file
View File

@ -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

View File

@ -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