summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: bb07f3829367fee284737a2e988b5a92c31557a4 (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
# Maintainer: Aseem Athale <athaleaseem@gmail.com>

_pkgname=open-webui
pkgname=${_pkgname}-no-venv
pkgver=0.6.5
pkgrel=1
pkgdesc="Web UI and OpenAI API for various LLM runners, including Ollama, built without creating virtualenv"
arch=('any')
url="https://github.com/open-webui/open-webui"
license=('MIT')
depends=(python
        python-accelerate
        python-aiocache
        python-aiofiles
        python-aiohttp
        python-alembic
        python-authlib
        python-asgiref
        python-azure-core
        python-azure-identity
        python-azure-storage-blob
        python-beautifulsoup4
        python-black
        python-boto3
        python-botocore
        python-certifi
        python-chromadb
        python-colbert-ai
        python-datasets
        python-dotenv
        python-duckduckgo-search
        python-elasticsearch
        python-fastapi
        python-faster-whisper
        python-fpdf2
        python-ftfy
        python-google-cloud-storage
        python-huggingface-hub
        python-importlib-metadata
        python-pyjwt
        python-langchain
        python-langchain-community
        python-langchain-core
        python-ldap3
        python-loguru
        python-markdown
        python-numpy
        python-opensearch
        python-opentelemetry-api
        python-opentelemetry-exporter-otlp-proto-grpc
        python-opentelemetry-instrumentation
        python-opentelemetry-instrumentation-httpx
        python-opentelemetry-instrumentation-logging
        python-opentelemetry-instrumentation-redis
        python-opentelemetry-instrumentation-requests
        python-opentelemetry-instrumentation-sqlalchemy
        python-opentelemetry-instrumentation-aiohttp-client
        python-opentelemetry-sdk
        python-opentelemetry-semantic-conventions
        python-passlib
        python-peewee
        python-peewee-migrate
        python-playwright
        python-pgvector
        python-pydantic
        python-pydub
        python-pymilvus
        python-python-multipart
        python-pytz
        python-qdrant-client
        python-redis
        python-requests
        python-sentence-transformers
        python-socketio
        python-soundfile
        python-sqlalchemy
        python-starlette
        python-tiktoken
        python-pytorch
        python-transformers
        python-typer
        python-typing_extensions
        uvicorn
        python-urllib3
        python-validators
        python-websocket-client
        python-websockets
        python-yaml
        python-yarl
        python-youtube-transcript-api
        tencentcloud-sdk-python
        )
makedepends=('npm' 'nvm' 'python-setuptools' 'python-build' 'python-installer' 'python-wheel' 'python-hatch')
optdepends=('ollama' 'tika-server')
conflicts=('open-webui-git' 'open-webui')
source=("${pkgname}-${pkgver}.tar.gz"::"${url}/archive/refs/tags/v${pkgver}.tar.gz"
        "build-only-backend.patch"
        "open-webui.service"
        "open-webui.conf")
b2sums=('020a91a41699a6bd58fd83c70389cc3fd49c9d61bc3877abdf57cd389243dced3806af6936ef1d8d56c4d6cafd545c67b43fade33930130caa0ce04697d3633b'
        '36ee27927719cd6cf761a62cd89404129326595f9cde35555f5fe5e2a616bac55346eba2a2882dd883f0d6b1a77e6da64c22521f7a7a18ca0d0b2eeac4781814'
        'f5dd97d4809160f3cc183a8c86ad5ead33163ba009fde2bb92935f766b6688f86bedecff9f1c805393d7e77736dd481d3da1d22cef6941a22bb0ef3856aee484'
        '9e9935cec52386c2397d53a02adf0befd82d9f6e7b95997abe75c156f7d2c0e29e67c9fe550da7e42c54faf97800de7501226b4ee6305530c5ced286dfed86a3')
options=(!strip !debug)
install="$_pkgname.install"

_ensure_local_nvm() {
    # let's be sure we are starting clean
    which nvm >/dev/null 2>&1 && nvm deactivate && nvm unload
    export NVM_DIR="${srcdir}/.nvm"

    # The init script returns 3 if version specified
    # in ./.nvrc is not (yet) installed in $NVM_DIR
    # but nvm itself still gets loaded ok
    source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
}

prepare() {
    # Frontend part
    _ensure_local_nvm
    nvm install lts/iron

    # Backend part
    cd "${_pkgname}-${pkgver}"
    patch -i ../build-only-backend.patch
}

build() {
    _ensure_local_nvm
    cd "${_pkgname}-${pkgver}"

    # Backend part
    python -m build --wheel --no-isolation

    # Frontend part
    export NODE_OPTIONS="--max_old_space_size=4096"
    npm install
    npm run format
    npm run i18n:parse
    npm run build
}

package() {
    # Install systemd service
    install -Dm644 "./$_pkgname.service" "$pkgdir/usr/lib/systemd/system/$_pkgname.service"

    # Install license
    install -Dm 644 "$srcdir/${_pkgname}-${pkgver}"/LICENSE -t "${pkgdir}/usr/share/licenses/${_pkgname}"

    # Install the default config file to /usr/share/$_pkgname/open-webui.conf
    install -d "$pkgdir/usr/share/$_pkgname"
    install -Dm644 "./$_pkgname.conf" "$pkgdir/usr/share/$_pkgname/$_pkgname.conf"

    # Copy source to app's home directory
    parent_dir="$pkgdir/opt"  # /opt

    install -d "$pkgdir/opt/$_pkgname"
    install -d "$pkgdir/var/opt/$_pkgname"
    install -d "$pkgdir/var/opt/$_pkgname/data"

    # copy over files
    cp -R "$srcdir/${_pkgname}-${pkgver}/build/." "$pkgdir/opt/$_pkgname"

    # Fix permissions
    echo "Setting permissions for $pkgdiropt/$_pkgname"
    chmod 755 "$pkgdir/opt/$_pkgname"
    find "$pkgdir/opt/$_pkgname" -type d -exec chmod 755 {} \;
    find "$pkgdir/opt/$_pkgname" -type f -exec chmod 644 {} \;

    echo "Setting permissions for $pkgdirvar/opt/$_pkgname"
    chmod 700 "$pkgdir/var/opt/$_pkgname"
    find "$pkgdir/var/opt/$_pkgname" -type d -exec chmod 755 {} \;
    find "$pkgdir/var/opt/$_pkgname" -type f -exec chmod 664 {} \;

    cd "${_pkgname}-${pkgver}"
    python -m installer --destdir="$pkgdir" dist/*.whl
    rm -r "$pkgdir/usr/lib/python3.13/site-packages/data"
}