summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9df28e7220e85589db76463818a1ac97049009a0 (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
# Maintainer: Levi Zim <rsworktech at outlook dot com>
# Contributor: zxp19821005 <zxp19821005 at 163 dot com>
pkgname=affine
_pkgname=AFFiNE
pkgver=0.18.2
_electronversion=33
pkgrel=1
pkgdesc="There can be more than Notion and Miro. AFFiNE is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use."
arch=('x86_64')
url="https://affine.pro/"
_ghurl="https://github.com/toeverything/AFFiNE"
license=(
    'LicenseRef-custom'
    'MIT'
)
provides=("${pkgname}=${pkgver}")
depends=(
    "electron${_electronversion}"
)
makedepends=(
    # https://github.com/toeverything/AFFiNE/blob/canary/docs/BUILDING.md#prerequisites
    nodejs-lts-iron yarn
    # node gyp
    python
    # electron-packager
    zip unzip
    # Rust
    cargo
    # Misc
    git jq
)
source=(
    "${_pkgname}::git+https://github.com/toeverything/AFFiNE#tag=v${pkgver}"
    "${pkgname}.sh"
    "${pkgname}.desktop"
)
sha256sums=('1ed6689ebbcacdc3ad9cb4773ccad0b0358c8fb32f636d581a1aa740ea0caf3b'
            '291f50480f5a61bc9c68db7d44cd0412071128706baa868a9cb854f8779a1980'
            '18724474ab2351ed00965f9fe9adea04967458dec810866b572cf44ca8185b5b')

case "${CARCH}" in
    x86_64)
        _arch=x64
        ;;
    *)
        _arch="${CARCH}"
esac

prepare() {
    cd "$_pkgname"
    export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 ELECTRON_SKIP_BINARY_DOWNLOAD=1 SENTRYCLI_SKIP_DOWNLOAD=1
    yarn install
}

build() {
    # https://github.com/toeverything/AFFiNE/blob/canary/docs/building-desktop-client-app.md
    cd "$_pkgname"
    # https://github.com/toeverything/AFFiNE/blob/v0.18.2/.github/actions/setup-version/action.yml
    export APP_VERSION="${pkgver}"
    ./scripts/set-version.sh $APP_VERSION
    CFLAGS+=' -ffat-lto-objects' # https://github.com/launchbadge/sqlx/issues/3149
    yarn workspace @affine/native build
    export BUILD_TYPE=stable
    SKIP_NX_CACHE=1 yarn workspace @affine/electron generate-assets
    yarn config set nmMode classic
    yarn config set nmHoistingLimits workspaces
    find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
    yarn install
    SKIP_WEB_BUILD=1 SKIP_BUNDLE=1 HOIST_NODE_MODULES=1 DEBUG='*' yarn workspace @affine/electron make --platform=linux --arch="${_arch}"
    unzip packages/frontend/apps/electron/out/stable/make/zip/linux/${_arch}/${_pkgname}-linux-${_arch}-${pkgver}.zip
}

package() {
    sed -e "
        s/@electronversion@/${_electronversion}/g
        s/@appname@/${pkgname}/g
        s/@runname@/app.asar/g
        s/@cfgdirname@/${_pkgname}/g
        s/@options@/env ELECTRON_OZONE_PLATFORM_HINT=auto/g
    " -i "${srcdir}/${pkgname}.sh"
    install -Dm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
    cd "$_pkgname/${_pkgname}-linux-${_arch}"
    install -Dm755 -d "${pkgdir}/usr/lib/${pkgname}"
    cp -r resources/* "${pkgdir}/usr/lib/${pkgname}"
    install -Dm644 "../LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -Dm644 "../LICENSE-MIT" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT"
    install -Dm644 "../packages/frontend/apps/electron/resources/icons/icon_stable_64x64.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
    install -Dm644 "${srcdir}/${pkgname}.desktop" -t "${pkgdir}/usr/share/applications"
}