diff --git a/srcpkgs/omniroute/files/OmniRoute.desktop b/srcpkgs/omniroute/files/OmniRoute.desktop new file mode 100644 index 00000000000000..76955b761ca59a --- /dev/null +++ b/srcpkgs/omniroute/files/OmniRoute.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Version=1.0 +Name=OmniRoute +# Only KDE 4 seems to use GenericName +GenericName=LLM endpoint +# Gnome and KDE 3 uses Comment. +Comment=LLM endpoint + +Exec=/usr/bin/omniroute --mcp +StartupNotify=true +Terminal=false +Icon=omniroute +Type=Application +Categories=Network;LLM;AI; +MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/chromium; diff --git a/srcpkgs/omniroute/files/omniroute b/srcpkgs/omniroute/files/omniroute new file mode 100644 index 00000000000000..2dab9174d4a355 --- /dev/null +++ b/srcpkgs/omniroute/files/omniroute @@ -0,0 +1,6 @@ +#!/bin/sh +export PORT="${PORT:-20128}" +export DATA_DIR="${DATA_DIR:-${XDG_DATA_HOME:-${HOME}/.local/share}/omniroute}" +export LOG_TO_FILE="${LOG_TO_FILE:-false}" +mkdir -p "${DATA_DIR}" +exec node /usr/lib/omniroute/.next/standalone/server.js "$@" diff --git a/srcpkgs/omniroute/template b/srcpkgs/omniroute/template new file mode 100644 index 00000000000000..3474670de36030 --- /dev/null +++ b/srcpkgs/omniroute/template @@ -0,0 +1,94 @@ +# Template file for 'omniroute' +pkgname=omniroute +version=3.3.1 +revision=1 +archs="~i686" +hostmakedepends="nodejs python3 make" +depends="openssl" +short_desc="Universal AI gateway with smart routing for multiple LLM providers" +maintainer="zenobit " +license="MIT" +homepage="https://github.com/diegosouzapw/OmniRoute" +distfiles="https://github.com/diegosouzapw/OmniRoute/archive/refs/tags/v${version}.tar.gz" +checksum=b5eaa436c797c1ac77bf76c6c5e73a5f62409d7bf54c043c55f5afecdab5c6e4 +system_accounts="_omniroute" +omniroute_homedir="/var/lib/omniroute" +export NODE_ENV=production +export npm_config_engine_strict=false +export npm_config_loglevel=error +export npm_config_fund=false +export npm_config_audit=false + +do_build() { + # Determine target CPU arch for node-gyp + local _gyp_arch + case "$XBPS_TARGET_MACHINE" in + aarch64*) _gyp_arch=arm64 ;; + armv7*|armv6*) _gyp_arch=arm ;; + i686*) _gyp_arch=ia32 ;; + *) _gyp_arch=x64 ;; + esac + + # 1) Install all deps – skip scripts (no network in do_build, native modules + # compiled separately below; better-sqlite3 is serverExternalPackage so + # Next.js does not execute it during next build) + NODE_ENV=development npm ci --ignore-scripts + + # 2) Build the Next.js standalone bundle + npm run build + + # 3) Copy static assets into standalone + cp -r .next/static .next/standalone/.next/static + [ -d public ] && cp -r public .next/standalone/public || true + + # 4) Compile better-sqlite3 native binding for the target architecture. + # Use node-gyp directly so CC/CXX from xbps-src cross-toolchain are used + # without npm altering them. + local _node_gyp=/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js + (cd node_modules/better-sqlite3 && node "$_node_gyp" rebuild --arch="$_gyp_arch") + + # 5) Place the compiled binding into the standalone bundle + local _bs3_release=.next/standalone/node_modules/better-sqlite3/build/Release + mkdir -p "$_bs3_release" + cp node_modules/better-sqlite3/build/Release/better_sqlite3.node "$_bs3_release/" + + # 6) Remove arch-specific sharp bundles – upstream sets images.unoptimized=true + # so sharp is not used at runtime; x64 .so files would break aarch64 strip + rm -rf .next/standalone/node_modules/@img + + # 7) Copy pino runtime deps omitted by Next.js static analysis: + # pino-abstract-transport – required by pino's worker thread + # split2 – dep of pino-abstract-transport + # process-warning – dep of pino itself + for _mod in pino-abstract-transport split2 process-warning; do + cp -r "node_modules/$_mod" .next/standalone/node_modules/ + done +} + +do_check() { + npm run test:unit +} + +do_install() { + vmkdir usr/lib/omniroute/.next + + vcopy .next/standalone/. usr/lib/omniroute/.next/standalone + + # Prevent removal of empty Next.js app router dirs by the post-install hook + for _d in \ + .next/standalone/.next/server/app/dashboard \ + .next/standalone/.next/server/app/dashboard/settings \ + .next/standalone/.next/server/app/dashboard/providers; do + touch "${DESTDIR}/usr/lib/omniroute/${_d}/.keep" + done + + vbin "${FILESDIR}/omniroute" +} + +post_install() { + vlicense LICENSE + vmkdir usr/share/applications + vcopy "${FILESDIR}/OmniRoute.desktop" usr/share/applications + vmkdir usr/share/icons/hicolor/scalable/apps + vcopy "public/icon-192.svg" usr/share/icons/hicolor/scalable/apps/OmniRoute.svg +}