blob: 756c39bd441dee3e4b06b6de405c570493c418a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
# Maintainer: Wuxxin <wuxxin@gmail.com>
# Contributor: SteamedFish <steamedfish@hotmail.com>
pkgbase=librefang-git
pkgname=("librefang-git" "librefang-desktop-git" "librefang-whatsapp-gateway-git")
pkgver=2026.7.27.r13.g1b9518fd1
pkgrel=1
pkgdesc='LibreFang is an open-source Agent Operating System written in Rust. (GIT version with patches for local STT,TTS,IMAGE support) '
arch=('x86_64' 'aarch64')
url='https://github.com/librefang/librefang'
license=('MIT' 'Apache-2.0')
makedepends=('rust' 'cargo' 'git' 'webkit2gtk-4.1' 'gtk3' 'libayatana-appindicator' 'nodejs' 'npm' 'pnpm' 'node-gyp' 'python' 'nodejs-addon-api' 'libvips')
source=(
"${pkgbase}::git+https://github.com/librefang/librefang.git"
"librefang.sysusers"
"librefang.tmpfiles"
"librefang.service"
"librefang-desktop.desktop"
"librefang-whatsapp-gateway.service"
"feature-local-stt.patch"
"feature-local-tts.patch"
"feature-local-image.patch"
"feature-local-inference.md"
)
sha256sums=('SKIP'
'72663b7a008dcf86e799df777f52c56ba700849510d3fd0c8f4a9e839702dd6e'
'eb06400136cd6f6e0a57f5ee802c273c3ea05b63946c60bd9e135d079d777f10'
'cf026330b3d4c3c708bd079b15401731e1afef4f3e780c4ad286ad0d961a6d5c'
'a640db0197d001c5ae9348d57cda8092e2c8170fa27ced98d5546557fadb6d17'
'1ddb18ffdd4c4131bf9a35debfb21a61aeda8ca1be90829e0e1b10d7bf19b975'
'aa2df1c379d02a52bf4072f3de2f6c3be0512fc3efcbb141320ba19d8fc3ca46'
'c4fccf730140e3cbe1c694b6f4f3b94c47b998ba76262ce50c63f578822d5918'
'673dc14c22aa89457a2e1684bf075b7e0ae5ecc520830529b6edcfac1e68246b'
'6fa3cb22d68b37cdc9605cc5c02c9095ea4ce47466e415c01dc54c7f7e81bb6a')
pkgver() {
cd "${pkgbase}"
git describe --long --tags --match 'v[0-9]*' | sed 's/^v//; s/-\(beta\|alpha\|rc\)/\1/g; s/\([^-]*-g\)/r\1/; s/-/./g'
}
prepare() {
# Ensure HOME is writable for any git operations triggered by cargo or npm
mkdir -p "${srcdir}/.home"
export HOME="${srcdir}/.home"
cd "${pkgbase}"
# Apply local patches
msg2 "Applying local STT, TTS and image support patches..."
patch -Np1 -i "${srcdir}/feature-local-stt.patch"
patch -Np1 -i "${srcdir}/feature-local-tts.patch"
patch -Np1 -i "${srcdir}/feature-local-image.patch"
export RUSTUP_TOOLCHAIN=stable
cargo fetch --target "$(rustc -vV | sed -n 's/host: //p')"
}
build() {
# Ensure HOME is writable for any git operations triggered by cargo or npm
mkdir -p "${srcdir}/.home"
export HOME="${srcdir}/.home"
# Build React dashboard WebUI so it gets embedded in the API binary at compile-time
cd "${srcdir}/${pkgbase}/crates/librefang-api/dashboard"
pnpm install --frozen-lockfile
pnpm run build
# Build Rust binaries
cd "${srcdir}/${pkgbase}"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
# Remap source paths so binaries don't embed build-specific paths
export RUSTFLAGS="${RUSTFLAGS} --remap-path-prefix=${srcdir}=/build"
export RUSTFLAGS="${RUSTFLAGS} --remap-path-prefix=${CARGO_HOME:-${HOME}/.cargo}=/vendor"
export RUSTFLAGS="${RUSTFLAGS} --remap-path-prefix=${RUSTUP_HOME:-${HOME}/.rustup}=/rustup"
# Remove -flto flags due to sqlite3 GCC compatibility issues with rust-lld
CFLAGS="${CFLAGS//-flto=auto/}"
CFLAGS="${CFLAGS//-flto/}"
CXXFLAGS="${CXXFLAGS//-flto=auto/}"
CXXFLAGS="${CXXFLAGS//-flto/}"
export CFLAGS CXXFLAGS
export CARGO_PROFILE_RELEASE_LTO=false
cargo build --frozen --release --bin librefang --bin librefang-desktop
# Build Node.js whatsapp-gateway.
# baileys depends on libsignal from git. npm >= 12 defaults allow-git to
# "none" and refuses to fetch it; --allow-git=root is not enough because
# libsignal is transitive, not in the gateway's own package.json. The
# lockfile also resolves it over ssh, which has no credentials here, so
# rewrite ssh to https (HOME is confined to ${srcdir}/.home above).
local _gwdir="${srcdir}/${pkgbase}/packages/whatsapp-gateway"
cd "${_gwdir}"
# makepkg pins GIT_CONFIG_GLOBAL to /dev/null, so redirect it at a writable
# path before configuring the rewrite.
export GIT_CONFIG_GLOBAL="${srcdir}/.home/.gitconfig"
git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
npm install --ignore-scripts --omit=dev --legacy-peer-deps --allow-git=all
# Copy system node-addon-api for compiling sharp/better-sqlite3 if needed
cp -r /usr/lib/node_modules/node-addon-api "${_gwdir}/node_modules/node-addon-api"
# Compile better-sqlite3 native addon
cd "${_gwdir}/node_modules/better-sqlite3"
npx node-gyp rebuild
}
check() {
cd "${pkgbase}"
export RUSTUP_TOOLCHAIN=stable
cargo test --frozen --release -p librefang-types --lib 2>/dev/null || true
}
package_librefang-git() {
pkgdesc='terminal interface and daemon for the LibreFang Agent OS'
depends=('glibc' 'openssl' 'libgcc' 'python-librefang-sdk-git')
optdepends=(
'chromium: Browser Hand support'
'yt-dlp: Clip Hand support'
'ffmpeg: Clip Hand support'
)
provides=('librefang' 'openfang')
conflicts=('librefang' 'openfang' 'openfang-cli' 'librefang-cli' 'librefang-cli-git')
replaces=('librefang-cli-git')
backup=('etc/librefang/env')
cd "${pkgbase}"
install -Dm755 "target/release/librefang" "${pkgdir}/usr/bin/librefang"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
install -Dm644 "${srcdir}/feature-local-inference.md" "${pkgdir}/usr/share/doc/${pkgname}/feature-local-inference.md"
# systemd service
install -Dm644 "${srcdir}/librefang.service" "${pkgdir}/usr/lib/systemd/system/librefang.service"
# sysusers and tmpfiles
install -Dm644 "${srcdir}/librefang.sysusers" "${pkgdir}/usr/lib/sysusers.d/librefang.conf"
install -Dm644 "${srcdir}/librefang.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/librefang.conf"
# default environment file (empty, user-editable)
install -Dm644 /dev/null "${pkgdir}/etc/librefang/env"
}
package_librefang-desktop-git() {
pkgdesc='Desktop application for the LibreFang Agent OS'
depends=('glibc' 'openssl' 'libgcc' 'webkit2gtk-4.1' 'gtk3' 'cairo' 'gdk-pixbuf2' 'glib2' 'libsoup3' 'hicolor-icon-theme' 'python-librefang-sdk-git')
optdepends=(
'librefang-git: CLI companion tool'
'chromium: Browser Hand support'
'yt-dlp: Clip Hand support'
'ffmpeg: Clip Hand support'
)
provides=('librefang-desktop' 'openfang-gui' 'librefang-gui' 'librefang-gui-git')
conflicts=('librefang-desktop' 'openfang-gui' 'librefang-gui' 'librefang-gui-git')
replaces=('librefang-gui-git')
cd "${pkgbase}"
install -Dm755 "target/release/librefang-desktop" "${pkgdir}/usr/bin/librefang-desktop"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
install -Dm644 "${srcdir}/feature-local-inference.md" \
"${pkgdir}/usr/share/doc/${pkgname}/feature-local-inference.md"
# .desktop file
install -Dm644 "${srcdir}/librefang-desktop.desktop" \
"${pkgdir}/usr/share/applications/librefang-desktop.desktop"
# icons
install -Dm644 "crates/librefang-desktop/icons/128x128.png" \
"${pkgdir}/usr/share/icons/hicolor/128x128/apps/librefang-desktop.png"
install -Dm644 "crates/librefang-desktop/icons/32x32.png" \
"${pkgdir}/usr/share/icons/hicolor/32x32/apps/librefang-desktop.png"
install -Dm644 "crates/librefang-desktop/icons/icon.png" \
"${pkgdir}/usr/share/icons/hicolor/512x512/apps/librefang-desktop.png"
}
package_librefang-whatsapp-gateway-git() {
pkgdesc='librefang WhatsApp gateway — QR login and bidirectional messaging'
depends=('nodejs' 'libvips' 'glibc' 'glib2' 'bash' 'libstdc++' 'libgcc')
optdepends=('librefang-git: connect gateway to the local librefang agent')
provides=('librefang-whatsapp-gateway' 'openfang-whatsapp-gateway')
conflicts=('librefang-whatsapp-gateway' 'openfang-whatsapp-gateway' 'librefang-whatsapp-gateway-git')
local _gatewaydir="${pkgdir}/usr/lib/librefang-whatsapp-gateway"
cd "${srcdir}/${pkgbase}/packages/whatsapp-gateway"
# Install package sources and vendored node_modules
install -dm755 "${_gatewaydir}"
cp -r index.js package.json node_modules lib "${_gatewaydir}/"
# Remove intermediate build folders/artifacts from better-sqlite3 and sharp to keep packages small
local _sqlitebuild="${_gatewaydir}/node_modules/better-sqlite3/build"
local _sqlitebin
_sqlitebin=$(find "${_sqlitebuild}/Release" -maxdepth 1 -name 'better_sqlite3.node' 2>/dev/null | head -1)
if [[ -n "${_sqlitebin}" ]]; then
cp "${_sqlitebin}" "${srcdir}/_better_sqlite3_tmp.node"
rm -rf "${_sqlitebuild}"
install -dm755 "${_sqlitebuild}/Release"
mv "${srcdir}/_better_sqlite3_tmp.node" "${_sqlitebuild}/Release/better_sqlite3.node"
fi
# Wrapper script
install -dm755 "${pkgdir}/usr/bin"
cat >"${pkgdir}/usr/bin/librefang-whatsapp-gateway" <<'EOF'
#!/bin/sh
exec node /usr/lib/librefang-whatsapp-gateway/index.js "$@"
EOF
chmod 755 "${pkgdir}/usr/bin/librefang-whatsapp-gateway"
# systemd service
install -Dm644 "${srcdir}/librefang-whatsapp-gateway.service" \
"${pkgdir}/usr/lib/systemd/system/librefang-whatsapp-gateway.service"
install -Dm644 "${srcdir}/${pkgbase}/LICENSE" \
"${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
|