summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0f1ece5da3a18a10eb836e955e0a3105775e11ac (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
# Maintainer: Kimiblock Moe
# Contributor: Astro Benzene <universebenzene at sina dot com>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ouyang Jun <ouyangjun1999@gmail.com>
# Contributor: Jove Yu <yushijun110 [at] gmail.com>
# Contributor: Ariel AxionL <axionl at aosc dot io>
# Contributor: v71
# Contributor: witt <1989161762 at qq dot com>

pkgbase=wps-office-cn-bwrap
pkgname=('wps-office-cn-bwrap')
pkgver=12.1.0.17900
pkgrel=1
pkgdesc="Kingsoft Office (WPS Office) CN version - an office productivity suite"
makedepends+=(desktop-file-utils)
arch=('x86_64')
license=('LicenseRef-WPS-EULA')
url="https://linux.wps.cn"
options=('!emptydirs')

# https://gitlab.com/cwittlut/wps-tsk/-/blob/main/tsk.sh?ref_type=heads by Ryan Tsien
# https://pastebin.com/29TeRUMj by Asuka Minato
_get_source_url() {
    url="https://wps-linux-personal.wpscdn.cn/wps/download/ep/Linux2023/${pkgver##*.}/wps-office_${pkgver}_$1.deb"
    uri="${url#https://wps-linux-personal.wpscdn.cn}"
    secrityKey='7f8faaaa468174dc1c9cd62e5f218a5b'
    timestamp10=$(date '+%s')
    md5hash=$(echo -n "${secrityKey}${uri}${timestamp10}" | md5sum)
    url+="?t=${timestamp10}&k=${md5hash%% *}"
    echo "$url"
}

source_x86_64=("wps-office_${pkgver}_amd64.deb::$(_get_source_url amd64)")
source=('fix-wps-python-parse.patch::https://aur.archlinux.org/cgit/aur.git/plain/fix-wps-python-parse.patch?h=wps-office-cn' "portable-config" "wps-helper")
sha1sums=("SKIP" "SKIP" "SKIP")
sha1sums_x86_64=('SKIP')

prepare() {
    bsdtar -xpf data.tar.xz
    cd "${srcdir}/usr/bin"
    sed -i 's|/opt/kingsoft/wps-office|/usr/lib|' *
    cd "${srcdir}"
    patch -Np1 -i "${srcdir}/fix-wps-python-parse.patch"
}

package_wps-office-cn-bwrap() {
    depends=('fontconfig' 'xorg-mkfontscale' 'libxrender' 'desktop-file-utils' 'shared-mime-info' 'xdg-utils' 'glu' 'sdl2' 'libpulse' 'hicolor-icon-theme' 'libxss' 'sqlite' 'libtool' 'libxslt' 'libjpeg-turbo' "portable")
    optdepends=('cups: Printing support'
                'libjpeg-turbo: JPEG image codec support'
                'pango: for complex (right-to-left) text support'
                'curl: An URL retrieval utility and library'
                'ttf-wps-fonts: Symbol fonts required by wps-office'
                'ttf-ms-fonts: Microsft Fonts recommended for wps-office'
                'wps-office-fonts: FZ TTF fonts provided by wps community'
                'wps-office-mime-cn: Use mime files provided by Kingsoft'
                'wps-office-mui-zh-cn: zh_CN support for WPS Office')
    conflicts=('kingsoft-office' 'wps-office' "wps-office-cn")
    provides=('wps-office' "wps-office-cn")
    cd "${srcdir}/opt/kingsoft/wps-office/"

    install -d "${pkgdir}/usr/lib"
    cp -r office6 "${pkgdir}/usr/lib"
    # Fix for icu>=71.1
    rm "${pkgdir}/usr/lib/office6/libstdc++.so"*
    # Use system libjpeg
    rm "${pkgdir}/usr/lib/office6/libjpeg.so"*
    [[ "$CARCH" = "aarch64" ]] && rm "${pkgdir}"/usr/lib/office6/libfreetype.so*
    install -Dm644 -t "${pkgdir}/usr/share/licenses/${pkgname}" office6/mui/default/*.html
    rm -r "${pkgdir}/usr/lib/office6/mui/en_US/resource/help"
    rm -r "${pkgdir}/usr/lib/office6/mui/zh_CN"

    install -d "${pkgdir}/usr/bin"
    cd "${srcdir}/usr/bin"
    install -m755 * "${pkgdir}/usr/bin"

    cd "${srcdir}/usr/share"

    # Avoid .desktop leaking
    #install -d "${pkgdir}/usr/share/applications"
    #cp -r applications/* "${pkgdir}/usr/share/applications"

    install -d "${pkgdir}/usr/share/desktop-directories"
    cp -r desktop-directories/* "${pkgdir}/usr/share/desktop-directories"

    install -d "${pkgdir}/usr/share/icons"
    cp -r icons/* "${pkgdir}/usr/share/icons"

    install -Dm644 -t "${pkgdir}/usr/share/fonts/wps-office" fonts/wps-office/*
    install -Dm755 "${srcdir}/portable-config" "${pkgdir}/usr/lib/portable/info/cn.wps.wps/config"
    sed -i 's|cn.wps.app|cn.wps.wps|g' \
	"${pkgdir}/usr/lib/portable/info/cn.wps.wps/config"
	sed -i 's|WPS-Generic|WPS-WPS|g' \
		"${pkgdir}/usr/lib/portable/info/cn.wps.wps/config"
    install -Dm755 "${srcdir}/portable-config" "${pkgdir}/usr/lib/portable/info/cn.wps.wpp/config"

    sed -i 's|cn.wps.app|cn.wps.wpp|g' \
	"${pkgdir}/usr/lib/portable/info/cn.wps.wpp/config"
	sed -i 's|WPS-Generic|WPS-WPP|g' \
		"${pkgdir}/usr/lib/portable/info/cn.wps.wpp/config"
    install -Dm755 "${srcdir}/portable-config" "${pkgdir}/usr/lib/portable/info/cn.wps.prometheus/config"
    sed -i 's|cn.wps.app|cn.wps.prometheus|g' \
	"${pkgdir}/usr/lib/portable/info/cn.wps.prometheus/config"
	sed -i 's|WPS-Generic|WPS-Prometheus|g' \
		"${pkgdir}/usr/lib/portable/info/cn.wps.prometheus/config"
    install -Dm755 "${srcdir}/portable-config" "${pkgdir}/usr/lib/portable/info/cn.wps.pdf/config"
    sed -i 's|cn.wps.app|cn.wps.pdf|g' \
	"${pkgdir}/usr/lib/portable/info/cn.wps.pdf/config"
	sed -i 's|WPS-Generic|WPS-PDF|g' \
		"${pkgdir}/usr/lib/portable/info/cn.wps.pdf/config"
    install -Dm755 "${srcdir}/portable-config" "${pkgdir}/usr/lib/portable/info/cn.wps.et/config"
    sed -i 's|cn.wps.app|cn.wps.et|g' \
	"${pkgdir}/usr/lib/portable/info/cn.wps.et/config"
	sed -i 's|WPS-Generic|WPS-ET|g' \
		"${pkgdir}/usr/lib/portable/info/cn.wps.et/config"

	install -Dm644 \
		"${srcdir}/usr/share/applications/wps-office-wps.desktop" \
		"${pkgdir}/usr/share/applications/cn.wps.wps.desktop"
	desktop-file-edit \
		--set-key=Exec \
		--set-value='env _portableConfig=cn.wps.wps /usr/bin/wps-helper /usr/bin/wps %u' \
		"${pkgdir}/usr/share/applications/cn.wps.wps.desktop"

	install -Dm644 \
		"${srcdir}/usr/share/applications/wps-office-wpp.desktop" \
		"${pkgdir}/usr/share/applications/cn.wps.wpp.desktop"
	desktop-file-edit \
		--set-key=Exec \
		--set-value='env _portableConfig=cn.wps.wpp /usr/bin/wps-helper /usr/bin/wpp %u' \
		"${pkgdir}/usr/share/applications/cn.wps.wpp.desktop"

	install -Dm644 \
		"${srcdir}/usr/share/applications/wps-office-prometheus.desktop" \
		"${pkgdir}/usr/share/applications/cn.wps.prometheus.desktop"
	desktop-file-edit \
		--set-key=Exec \
		--set-value='env _portableConfig=cn.wps.prometheus /usr/bin/wps-helper /usr/bin/wps %u' \
		"${pkgdir}/usr/share/applications/cn.wps.prometheus.desktop"

	install -Dm644 \
		"${srcdir}/usr/share/applications/wps-office-pdf.desktop" \
		"${pkgdir}/usr/share/applications/cn.wps.pdf.desktop"
	desktop-file-edit \
		--set-key=Exec \
		--set-value='env _portableConfig=cn.wps.pdf /usr/bin/wps-helper /usr/bin/wpspdf %u' \
		"${pkgdir}/usr/share/applications/cn.wps.pdf.desktop"

	install -Dm644 \
		"${srcdir}/usr/share/applications/wps-office-et.desktop" \
		"${pkgdir}/usr/share/applications/cn.wps.et.desktop"
	desktop-file-edit \
		--set-key=Exec \
		--set-value='env _portableConfig=cn.wps.et /usr/bin/wps-helper /usr/bin/et %u' \
		"${pkgdir}/usr/share/applications/cn.wps.et.desktop"

	ln -sf /usr/bin/true "${pkgdir}/usr/bin/wpscloudsvr"
	install -Dm755 "${srcdir}/wps-helper" "${pkgdir}/usr/bin/wps-helper"
}