diff --git a/.gitignore b/.gitignore index bbd57cd..6489038 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/src +**/tmp diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0eabf9f..eaab87f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -43,7 +43,8 @@ "minisatip", "nut", "custom-firmware", - "rflink" + "rflink", + "meilisearch" ], }, ] diff --git a/Readme.md b/Readme.md index 79990a1..352a0f0 100644 --- a/Readme.md +++ b/Readme.md @@ -7,6 +7,7 @@ | custom-firmware-mn88472 | Panasonic MN88472 firmware for Xbox One tuner | | rflink | rflink port for raspberrypi https://github.com/seahu/rflink | | nut | Forked of the community repo version with CGI components enabled | +| meilisearch | A lightning-fast search engine (Forked of the community repo for v3.21) | # How to build packages ## Initial Setup diff --git a/meilisearch/APKBUILD b/meilisearch/APKBUILD new file mode 100644 index 0000000..76b36e1 --- /dev/null +++ b/meilisearch/APKBUILD @@ -0,0 +1,66 @@ +# Contributor: Jakub Jirutka +# Contributor: Bram Prieshof +# Maintainer: Bram Prieshof +pkgname=meilisearch +pkgver=1.53.1 +pkgrel=1 +pkgdesc="A lightning-fast search engine that fits into your apps, websites and workflow" +url="https://www.meilisearch.com/" +# ppc64le, riscv64, s390x, loongarch64: fails to build ring crate +# armhf, armv7, x86: unsupported by upstream +#arch="all !armhf !armv7 !ppc64le !riscv64 !s390x !x86 !loongarch64" +arch="x86_64" +license="MIT" +depends="ca-certificates" +makedepends=" + cargo + cargo-auditable + mimalloc2-dev + zstd-dev + " +pkgusers="meilisearch" +pkggroups="meilisearch" +install="$pkgname.pre-install $pkgname.post-upgrade" +subpackages="$pkgname-openrc" +source="https://github.com/meilisearch/meilisearch/archive/v$pkgver/meilisearch-$pkgver.tar.gz + $pkgname.initd + $pkgname.confd + config.patch + " + +# Disable analytics (telemetry / data collection), mini-dashboard (JS project) +# and specialized tokenizers (they are huge). +_cargo_opts="--frozen --no-default-features --locked --bins --tests" +_cargo_treads=1 + +export CARGO_PROFILE_RELEASE_OPT_LEVEL=2 + +prepare() { + cargo fetch --target="$CTARGET" + default_prepare +} + +build() { + cargo auditable build $_cargo_opts --release -j $_cargo_treads --package meilisearch +} + +check() { + ulimit -n 8192 + export ZSTD_SYS_USE_PKG_CONFIG=1 + cargo test --release --locked --package meilisearch -j $_cargo_treads +} + +package() { + install -D -m755 target/release/$pkgname -t "$pkgdir"/usr/bin/ + install -D -m640 -g "$pkggroups" config.toml "$pkgdir"/etc/meilisearch/config.toml + install -D -m755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname + install -D -m644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname + install -d -m755 -o "$pkgusers" -g "$pkggroups" "$pkgdir"/var/lib/$pkgname +} + +sha512sums=" +84e76f3063c169b761c51d84230f41a51552525436d7228899705df7a7440d41ab97fb7abea97b1e52e24fc7f3c5788759086662a3d057f9c54644ba38856062 meilisearch-1.53.1.tar.gz +cc2ca5cc2d7baa3d17bb2d0798211599264d11017e2f8139bec07e719b6bf99de2bb0e2eb64ba99f74ed0c299c30f12a7867c76abfe57279a714a14c030e8543 meilisearch.initd +eb07af5c10c7e5e47059d40b5d939ef0cc4ea262109e9986e78f3a461bd1982f0cd29c18d201a2904eafacfd3b650b5a691583e887e701a88bcc994e076e84c3 meilisearch.confd +abd93d3dbcfa5e62abc82e9d95e0fe572ee0fea399330f8ceaf1410ee62d6ed3226455e2aa716e3298275c306b2b56efc7562a80e85f4f63c743ca05c3b34c65 config.patch +" diff --git a/meilisearch/config.patch b/meilisearch/config.patch new file mode 100644 index 0000000..09e82e5 --- /dev/null +++ b/meilisearch/config.patch @@ -0,0 +1,93 @@ +From: brammp +Date: Sat, 22 Aug 2026 19:59:29 +0200 +Subject: [PATCH] Adjust default config + +diff --git a/a/config.toml b/b/config.toml +index bbd70a6..3cd188e 100644 +--- a/config.toml ++++ b/config.toml +@@ -3,24 +3,28 @@ + + # Designates the location where database files will be created and retrieved. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#database-path +-db_path = "./data.ms" ++db_path = "/var/lib/meilisearch/data.ms" + + # Configures the instance's environment. Value must be either `production` or `development`. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#environment +-env = "development" ++env = "production" + + # The address on which the HTTP server will listen. +-http_addr = "localhost:7700" ++http_addr = "127.0.0.1:7700" + + # Sets the instance's master key, automatically protecting all routes except GET /health. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#master-key ++# ++# NOTE: If this option is not set, the init script writes a random key to file ++# /etc/meilisearch/master_key, if it doesn't already exist, and loads it into ++# env. variable MEILI_MASTER_KEY at each start. + # master_key = "YOUR_MASTER_KEY_VALUE" + + # Deactivates Meilisearch's built-in telemetry when provided. + # Meilisearch automatically collects data from all instances that do not opt out using this flag. + # All gathered data is used solely for the purpose of improving Meilisearch, and can be deleted at any time. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#disable-analytics +-# no_analytics = true ++no_analytics = true + + # Sets the maximum size of accepted payloads. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#payload-limit-size +@@ -45,11 +49,11 @@ log_level = "INFO" + + # Sets the directory where Meilisearch will create dump files. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#dump-directory +-dump_dir = "dumps/" ++dump_dir = "/var/lib/meilisearch/dumps/" + + # Imports the dump file located at the specified path. Path must point to a .dump file. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#import-dump +-# import_dump = "./path/to/my/file.dump" ++# import_dump = "/var/lib/meilisearch/dumps/file.dump" + + # Prevents Meilisearch from throwing an error when `import_dump` does not point to a valid dump file. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ignore-missing-dump +@@ -72,11 +76,11 @@ schedule_snapshot = false + + # Sets the directory where Meilisearch will store snapshots. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#snapshot-destination +-snapshot_dir = "snapshots/" ++snapshot_dir = "/var/lib/meilisearch/snapshots/" + + # Launches Meilisearch after importing a previously-generated snapshot at the given filepath. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#import-snapshot +-# import_snapshot = "./path/to/my/snapshot" ++# import_snapshot = "/var/lib/meilisearch/snapshots/my-snapshot" + + # Prevents a Meilisearch instance from throwing an error when `import_snapshot` does not point to a valid snapshot file. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ignore-missing-snapshot +@@ -93,19 +97,19 @@ ignore_snapshot_if_db_exists = false + + # Enables client authentication in the specified path. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ssl-authentication-path +-# ssl_auth_path = "./path/to/root" ++# ssl_auth_path = "/etc/meilisearch/client-ca.crt" + + # Sets the server's SSL certificates. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ssl-certificates-path +-# ssl_cert_path = "./path/to/certfile" ++# ssl_cert_path = "/etc/meilisearch/server.crt" + + # Sets the server's SSL key files. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ssl-key-path +-# ssl_key_path = "./path/to/private-key" ++# ssl_key_path = "/etc/meilisearch/server.key" + + # Sets the server's OCSP file. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ssl-ocsp-path +-# ssl_ocsp_path = "./path/to/ocsp-file" ++# ssl_ocsp_path = "/etc/meilisearch/server.ocsp" + + # Makes SSL authentication mandatory. + # https://www.meilisearch.com/docs/learn/configuration/instance_options#ssl-require-auth \ No newline at end of file diff --git a/meilisearch/meilisearch.confd b/meilisearch/meilisearch.confd new file mode 100644 index 0000000..364f6e2 --- /dev/null +++ b/meilisearch/meilisearch.confd @@ -0,0 +1,23 @@ +# Configuration for /etc/init.d/meilisearch + +# Path to a configuration file that should be used to setup the engine. +#cfgfile="/etc/meilisearch/config.toml" + +# Path to a file to read the master key from. If it doesn't exist, it will +# be generated with a random key. It is ignored if the 'master_key' option is +# set in the $cfgfile or if MEILI_MASTER_KEY is exported. +#master_key_file="/etc/meilisearch/master_key" + +# Path to the base directory for storing Meilisearch data (database, dumps, +# snapshots...). This will be set as the working directory for the meilisearch +# process, so all relative paths will be resolved against this directory. +#datadir="/var/lib/meilisearch" + +# User (and group) to run meilisearch as. +#command_user="meilisearch" + +# Use log to a file instead of syslog. +logfile="/var/log/meilisearch.log" + +# Comment out to run without process supervisor. +supervisor=supervise-daemon diff --git a/meilisearch/meilisearch.initd b/meilisearch/meilisearch.initd new file mode 100644 index 0000000..3df5754 --- /dev/null +++ b/meilisearch/meilisearch.initd @@ -0,0 +1,71 @@ +#!/sbin/openrc-run + +name="Meilisearch" +description="A lightning-fast search engine" + +: ${command_user:="meilisearch"} +: ${cfgfile:="/etc/meilisearch/config.toml"} +: ${master_key_file:="/etc/meilisearch/master_key"} +: ${datadir:="/var/lib/meilisearch"} +: ${start_wait:=50} # milliseconds +: ${healthcheck_timer:=30} +: ${respawn_delay:=5} + +command="/usr/bin/meilisearch" +command_args="--config-file-path $cfgfile $command_args" +command_background="yes" +directory="$datadir" +pidfile="/run/$RC_SVCNAME.pid" + +start_stop_daemon_args="--wait $start_wait $start_stop_daemon_args" +# The leading space is to avoid fallback to $start_stop_daemon_args when this +# is empty (supervise-daemon doesn't support --wait). +supervise_daemon_args=" $supervise_daemon_args" + +depend() { + need localmount net + after firewall +} + +start_pre() { + # This variable is not supported in Meilisearch >1.0, so we can use it + # to detect old config. + if [ "${MEILI_MAX_INDEX_SIZE-}" ]; then + eerror "You are using an outdated configuration; remove environment variables from" + eerror "/etc/conf.d/meilisearch and use $cfgfile instead." + return 1 + fi + + if [ -z "${MEILI_MASTER_KEY-}" ] && ! config_get 'master_key' >/dev/null; then + if ! [ -f "$master_key_file" ]; then + einfo "Generating random master_key in $master_key_file" + { head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32; echo ''; } \ + | install -D -m 640 -g meilisearch /dev/stdin "$master_key_file" + fi + + export MEILI_MASTER_KEY="$(cat "$master_key_file")" + fi + + if [ "${logfile-}" ]; then + error_log="$logfile" + checkpath -f -m 640 -o "$command_user" "$logfile" || return 1 + else + command_args="$command_args --syslog" + fi + + return 0 +} + +healthcheck() { + local http_addr + + [ -x /usr/bin/curl ] || return 0 + http_addr="$(config_get 'http_addr')" || return 0 + + /usr/bin/curl -fq "$http_addr/health" +} + +config_get() { + local key="$1" + sed -En 's/^'"$key"'\s*=\s*("([^"]+)"|([^ #]+)).*/\2\3/p' "$cfgfile" | grep -m1 . +} diff --git a/meilisearch/meilisearch.post-upgrade b/meilisearch/meilisearch.post-upgrade new file mode 100644 index 0000000..6f2f909 --- /dev/null +++ b/meilisearch/meilisearch.post-upgrade @@ -0,0 +1,13 @@ +#!/bin/sh + +if [ "$(apk version -t "$2" '1.1.1-r0')" = '<' ]; then + cat >&2 <<-EOF + * + * Meilisearch configuration has been moved from /etc/conf.d/meilisearch + * to /etc/meilisearch/config.toml. Remove all env variables from the former + * and adjust the latter. + * + EOF +fi + +exit 0 diff --git a/meilisearch/meilisearch.pre-install b/meilisearch/meilisearch.pre-install new file mode 100644 index 0000000..afde815 --- /dev/null +++ b/meilisearch/meilisearch.pre-install @@ -0,0 +1,6 @@ +#!/bin/sh + +addgroup -S meilisearch 2>/dev/null +adduser -S -D -H -h /var/lib/meilisearch -s /sbin/nologin -G meilisearch -g "added by apk for meilisearch" meilisearch 2>/dev/null + +exit 0