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

_appprefix="/opt"
_appdataprefix="/var/opt"

pkgname=open-webui
pkgver=0.3.35
pkgrel=2
pkgdesc="Web UI and OpenAI API for various LLM runners, including Ollama"
arch=('any')
url="https://github.com/open-webui/open-webui"
license=('MIT')
depends=('python' 'nodejs-lts-iron')
makedepends=('npm')
conflicts=('open-webui-git')
source=("${pkgname}-${pkgver}.tar.gz"::"${url}/archive/refs/tags/v${pkgver}.tar.gz"
    "open-webui.service"
    "open-webui.conf")

install="${pkgname}.install"
sha1sums=('9113d481119c3133942c5012ec74805af878bc8f'
          '9b789adb8d91f15ece2187af4aec810847d4b0b2'
          'fb015c224b9529988823f0e24d65ab4a004d30c0')
options=(!strip !debug)

build() {
    cd "${pkgname}-${pkgver}"
    export NODE_OPTIONS="--max_old_space_size=4096"
    npm install
    npm run format
    npm run i18n:parse
    npm run build
}

check() {
    cd "${pkgname}-${pkgver}"
    export NODE_OPTIONS="--max_old_space_size=4096"
    npm run test:frontend
}

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/${_appprefix}"  # /opt

    install -d "$pkgdir/${_appprefix}/$pkgname"
    install -d "$pkgdir/${_appdataprefix}/$pkgname"

    # copy over files
    cp -R "$srcdir/${pkgname}-${pkgver}/." "$pkgdir/${_appprefix}/$pkgname"

    # clean up stuff we don't need
    rm -rf "$pkgdir/${_appprefix}/$pkgname/node_modules"
    rm -rf "$pkgdir/${_appprefix}/$pkgname/.git"

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

    echo "Setting permissions for $pkgdir${_appdataprefix}/$pkgname"
    chmod 755 "$pkgdir/${_appdataprefix}/$pkgname"
    find "$pkgdir/${_appdataprefix}/$pkgname" -type d -exec chmod 775 {} \;
    find "$pkgdir/${_appdataprefix}/$pkgname" -type f -exec chmod 664 {} \;
}