net-im/tencent-qq: bump version to 3.2.15_p241224
[gentoo-zh.git] / net-im / wechat-universal-bwrap / wechat-universal-bwrap-4.0.0.21.ebuild
blob6b6bb1efa4143f738c0d7d989d28ff0eae573693
1 # Copyright 2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
6 inherit desktop toolchain-funcs unpacker xdg
8 DESCRIPTION="WeChat (Universal) with bwrap sandbox"
9 HOMEPAGE="https://weixin.qq.com https://github.com/7Ji-PKGBUILDs/wechat-universal-bwrap"
11 APP_NAME="com.tencent.wechat"
12 URL_ROOT="https://home-store-packages.uniontech.com/appstore/pool/appstore/c/${APP_NAME}"
13 DEB_STEM="${APP_NAME}_${PV}"
14 AUR_REPO_REF="e0982191c6940f1bdcae87786cf8e5badfaf65c9"
15 SRC_URI="
16 amd64? ( ${URL_ROOT}/${DEB_STEM}_amd64.deb )
17 arm64? ( ${URL_ROOT}/${DEB_STEM}_arm64.deb )
18 loong? ( ${URL_ROOT}/${DEB_STEM}_loongarch64.deb ) https://github.com/7Ji-PKGBUILDs/wechat-universal-bwrap/archive/${AUR_REPO_REF}.tar.gz -> wechat-universal-bwrap-${AUR_REPO_REF}.tar.gz
21 S="${WORKDIR}"
22 LICENSE="all-rights-reserved GPL-2"
23 SLOT="0"
24 KEYWORDS="-* ~amd64 ~arm64 ~loong"
25 RESTRICT="bindist strip mirror"
27 # the sonames are gathered with the following trick
29 # objdump -p /path/weixin | grep NEEDED | awk '{print $2}' | xargs equery b | sort | uniq
30 BLOB_RDEPEND="
31 app-accessibility/at-spi2-core:2
32 dev-libs/expat
33 dev-libs/glib:2
34 dev-libs/nspr
35 dev-libs/nss
36 dev-libs/openssl-compat:1.1.1
37 dev-libs/wayland
38 media-libs/alsa-lib
39 media-libs/fontconfig
40 media-libs/freetype
41 media-libs/libglvnd
42 media-libs/mesa
43 media-libs/tiff-compat:4
44 sys-apps/dbus
45 sys-libs/zlib
46 x11-libs/cairo
47 x11-libs/libdrm
48 x11-libs/libX11
49 x11-libs/libxcb
50 x11-libs/libXcomposite
51 x11-libs/libXdamage
52 x11-libs/libXext
53 x11-libs/libXfixes
54 x11-libs/libxkbcommon
55 x11-libs/libXrandr
56 x11-libs/libXrender
57 x11-libs/pango
58 x11-libs/xcb-util-image
59 x11-libs/xcb-util-keysyms
60 x11-libs/xcb-util-renderutil
61 x11-libs/xcb-util-wm
64 RDEPEND="
65 ${BLOB_RDEPEND}
66 sys-apps/bubblewrap
67 sys-apps/lsb-release
68 x11-misc/flatpak-xdg-utils
69 x11-misc/xdg-user-dirs
70 loong? ( virtual/loong-ow-compat )
72 BDEPEND="dev-util/patchelf"
74 QA_PREBUILT="*"
76 src_prepare() {
77 elog "Start patch wechat-universal.sh about launcher fs layout"
78 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev/null
79 eapply "${FILESDIR}/adjust-launcher-fs-layout-1.patch"
80 popd > /dev/null
82 default
85 call_cc() {
86 local cc="$(tc-getCC)"
87 echo "$cc" "$@"
88 "$cc" "$@" || die
91 call_patchelf() {
92 echo patchelf "$@"
93 patchelf "$@" || die
96 src_compile() {
97 einfo "Fixing blob RUNPATHs"
98 pushd "${S}/opt/apps/${APP_NAME}/files" > /dev/null
99 # originally $ORIGIN:$ORIGIN
100 call_patchelf --set-rpath '$ORIGIN' RadiumWMPF/runtime/WeChatAppEx
101 # originally $ORIGIN:/home/ubuntu/.wconan2/ilink/fcafc08e_1712581517/libs/Release/clang-llvm-12.0.0/libs
102 call_patchelf --remove-rpath RadiumWMPF/runtime/libilink2.so
103 # originally /home/ubuntu/.wconan2/ilink_network/7fd99102_1712579641/ilink-network/libs/Release/clang-llvm-12.0.0/libs:
104 call_patchelf --remove-rpath RadiumWMPF/runtime/libilink_network.so
105 # originally ./ (!!!)
106 call_patchelf --remove-rpath libvoipChannel.so
107 call_patchelf --remove-rpath libvoipCodec.so
108 call_patchelf --remove-rpath libconfService.so
110 call_patchelf --remove-rpath libilink2.so
111 call_patchelf --remove-rpath libilink_network.so
112 # look like without meaning, same lib on my system
113 call_patchelf --remove-needed libbz2.so.1.0 wechat
114 call_patchelf --add-needed libbz2.so.1 wechat
115 popd > /dev/null
117 einfo "Building stub libuosdevicea.so"
118 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev/null
119 call_cc -fPIC -shared ${CFLAGS} ${LDFLAGS} -o libuosdevicea.so libuosdevicea.c || die
120 popd > /dev/null
123 src_install() {
124 LIB_DIR=/usr/lib/wechat-universal
125 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev/null
126 domenu wechat-universal.desktop
127 exeinto /usr/lib/wechat-universal
128 newexe wechat-universal.sh start.sh
129 newexe wechat-universal.sh stop.sh
131 exeinto ${LIB_DIR}/usr/bin
132 newexe fake_dde-file-manager dde-file-manager
134 insinto /opt/wechat-universal
135 doins libuosdevicea.so
136 insinto ${LIB_DIR}/usr/lib/license
137 doins libuosdevicea.so
138 popd > /dev/null
140 # needed on the host side for bwrap to be able to do the bind-mount
141 keepdir /usr/lib/license
143 insinto ${LIB_DIR}/etc
144 newins "${FILESDIR}/stub-uos-release" lsb-release
146 insinto /opt/wechat-universal
147 doins -r "${S}/opt/apps/${APP_NAME}/files/"*
148 fperms 0755 /opt/wechat-universal/{crashpad_handler,wechat,wxocr,wxplayer}
149 fperms 0755 /opt/wechat-universal/RadiumWMPF/runtime/WeChatAppEx{,_crashpad_handler}
151 einfo "Installing icons..."
152 for i in 16 32 64 128 256; do
153 png_file="${S}/opt/apps/${APP_NAME}/entries/icons/hicolor/${i}x${i}/apps/${APP_NAME}.png"
154 if [ -e "${png_file}" ]; then
155 newicon -s "${i}" -c apps "${png_file}" "wechat-universal.png"
157 done
160 pkg_postinst() {
161 if [[ "$LANG" == "zh_CN.UTF-8" ]]; then
162 elog '>> 注意!升级至4.0版本后,环境变量已统一至WECHAT_ 前缀'
163 elog '>> 执行 `wechat-universal --help` 来查看相关帮助信息'
164 else
165 elog '>> Warning! After updating to v4.0, all environment variables are unified to be prefixed with WECHAT_'
166 elog '>> Run `wechat-universal --help` to check for the help message'