blob: 5d40abbfc251085ed9550d735ff2133cafabb086 (
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
|
# Maintainer: zxp19821005 <zxp19821005 at 163 dot com>
# Contributor: Xiaozhu1337 <nihaoaheheda@gmail.com>
pkgname=siyuan
pkgver=3.1.20
_electronversion=32
_nodeversion=20
pkgrel=1
pkgdesc="A privacy-first, self-hosted, fully open source personal knowledge management software, written in typescript and golang.(Use system-wide electron)"
arch=(
'aarch64'
'x86_64'
)
url="https://b3log.org/siyuan"
_ghurl="https://github.com/siyuan-note/siyuan"
license=('AGPL-3.0-only')
conflicts=(
"${pkgname}"
"${pkgname}-note"
)
provides=("${pkgname}")
depends=(
"electron${_electronversion}"
)
makedepends=(
'gendesk'
'curl'
'nvm'
'npm'
'go'
'pnpm'
)
source=(
"${pkgname}-${pkgver}.tar.gz::${_ghurl}/archive/refs/tags/v${pkgver}.tar.gz"
"${pkgname}.sh"
)
sha256sums=('60c168d96574183d5c1e362b3b478e7537a85373c37d9b43d14b9053bf0021da'
'291f50480f5a61bc9c68db7d44cd0412071128706baa868a9cb854f8779a1980')
_ensure_local_nvm() {
local NVM_DIR="${srcdir}/.nvm"
source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
nvm install "${_nodeversion}"
nvm use "${_nodeversion}"
}
prepare() {
sed -e "
s/@electronversion@/${_electronversion}/g
s/@appname@/${pkgname}/g
s/@runname@/app/g
s/@cfgdirname@/SiYuan-Electron/g
s/@options@/env ELECTRON_OZONE_PLATFORM_HINT=auto/g
" -i "${srcdir}/${pkgname}.sh"
_ensure_local_nvm
gendesk -q -f -n --pkgname="${pkgname}" --pkgdesc="${pkgdesc}" --categories="Office" --name="${pkgname}" --exec="${pkgname} %U"
sed "2i\Name[zh_CN]=思源笔记" -i "${srcdir}/${pkgname}.desktop"
cd "${srcdir}/${pkgname}-${pkgver}/app"
export CGO_ENABLED=1
export GO111MODULE=on
export GOOS=linux
export GOCACHE="${srcdir}/go-build"
export GOMODCACHE="${srcdir}/go/pkg/mod"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
export SYSTEM_ELECTRON_VERSION="$(electron${_electronversion} -v | sed 's/v//g')"
electronDist="/usr/lib/electron${_electronversion}"
HOME="${srcdir}/.electron-gyp"
{
echo -e '\n'
#echo 'build_from_source=true'
echo 'link-workspace-packages=true'
echo 'fetch-retry-maxtimeout=10000'
echo "cache-dir="${srcdir}"/.pnpm_cache"
echo "store-dir="${srcdir}"/.pnpm_store"
} >> .npmrc
if [[ "$(curl -s ipinfo.io/country)" == *"CN"* ]]; then
{
echo 'registry=https://registry.npmmirror.com'
echo 'electron_mirror=https://registry.npmmirror.com/-/binary/electron/'
echo 'electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/'
} >> .npmrc
go env -w GOPROXY=https://goproxy.cn,direct
fi
sed -i "/build:mobile/d;s/\"electron\": \"\([^\"]*\)\"/\"electron\": \"${SYSTEM_ELECTRON_VERSION}\"/g" package.json
NODE_ENV=development pnpm install --no-frozen-lockfile
}
build() {
cd "${srcdir}/${pkgname}-${pkgver}/app"
NODE_ENV=production pnpm run build
cd "${srcdir}/${pkgname}-${pkgver}/kernel"
go build --tags fts5 -o "../app/kernel-linux/SiYuan-Kernel" -v -ldflags "-s -w -X github.com/siyuan-note/siyuan/kernel/util.Mode=prod"
cd "${srcdir}/${pkgname}-${pkgver}/app"
case "${CARCH}" in
aarch64)
_CFG_FILE=electron-builder-linux-arm64.yml
;;
x86_64)
_CFG_FILE=electron-builder-linux.yml
;;
esac
NODE_ENV=production pnpm -c exec "electron-builder --linux dir -c.electronDist=${electronDist} --config ${_CFG_FILE} "
}
package() {
install -Dm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
install -Dm644 "${srcdir}/${pkgname}-${pkgver}/app/build/linux-"*/resources/pandoc.zip -t "${pkgdir}/usr/lib/${pkgname}"
cp -Pr --no-preserve=ownership "${srcdir}/${pkgname}-${pkgver}/app/build/linux-"*/resources/{app,appearance,changelogs,guide,kernel,stage} "${pkgdir}/usr/lib/${pkgname}"
install -Dm644 "${srcdir}/${pkgname}-${pkgver}/app/src/assets/icon.png" "${pkgdir}/usr/share/pixmaps/${pkgname}.png"
install -Dm644 "${srcdir}/${pkgname}.desktop" -t "${pkgdir}/usr/share/applications"
}
|