1 # Copyright 2024 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
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
="8ee52cb9ff6e00a0a6910e1863cac9bf4c2d386f"
16 amd64? ( ${URL_ROOT}/${DEB_STEM}_amd64.deb )
17 arm64? ( ${URL_ROOT}/${DEB_STEM}_arm64.deb )
18 loong? ( ${URL_ROOT}/${DEB_STEM}_loongarch64.deb )
19 https://github.com/7Ji-PKGBUILDs/wechat-universal-bwrap/archive/${AUR_REPO_REF}.tar.gz -> wechat-universal-bwrap-${AUR_REPO_REF}.tar.gz
23 LICENSE
="all-rights-reserved GPL-2"
25 KEYWORDS
="-* ~amd64 ~arm64 ~loong"
26 RESTRICT
="bindist strip mirror"
28 # the sonames are gathered with the following trick
30 # objdump -p /path/weixin | grep NEEDED | awk '{print $2}' | xargs equery b | sort | uniq
32 app-accessibility/at-spi2-core:2
37 dev-libs/openssl-compat:1.1.1
44 media-libs/tiff-compat:4
51 x11-libs/libXcomposite
59 x11-libs/xcb-util-image
60 x11-libs/xcb-util-keysyms
61 x11-libs/xcb-util-renderutil
69 x11-misc/flatpak-xdg-utils
70 x11-misc/xdg-user-dirs
71 loong? ( virtual/loong-ow-compat )
73 BDEPEND
="dev-util/patchelf"
78 elog
"Start patch wechat-universal.sh about launcher fs layout"
79 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev
/null
80 eapply
"${FILESDIR}/adjust-launcher-fs-layout-2.patch"
87 local cc
="$(tc-getCC)"
98 einfo
"Fixing blob RUNPATHs"
99 pushd "${S}/opt/apps/${APP_NAME}/files" > /dev
/null
100 # originally $ORIGIN:$ORIGIN
101 call_patchelf
--set-rpath '$ORIGIN' RadiumWMPF
/runtime
/WeChatAppEx
102 # orginally /data/devops-xwechat/workspace/translib_linux_test/linux/3rd_x86_64/lib
103 call_patchelf
--set-rpath '$ORIGIN' libwxtrans.so
104 # originally $ORIGIN:/home/ubuntu/.wconan2/ilink/fcafc08e_1712581517/libs/Release/clang-llvm-12.0.0/libs
105 call_patchelf
--set-rpath '$ORIGIN' RadiumWMPF
/runtime
/libilink2.so
106 # originally /home/ubuntu/.wconan2/ilink_network/7fd99102_1712579641/ilink-network/libs/Release/clang-llvm-12.0.0/libs:
107 call_patchelf
--set-rpath '$ORIGIN' RadiumWMPF
/runtime
/libilink_network.so
108 # originally ./ (!!!)
109 call_patchelf
--remove-rpath libvoipChannel.so
110 call_patchelf
--remove-rpath libvoipCodec.so
111 call_patchelf
--remove-rpath libconfService.so
113 call_patchelf
--remove-rpath libilink2.so
114 call_patchelf
--remove-rpath libilink_network.so
115 # look like without meaning, same lib on my system
116 call_patchelf
--remove-needed libbz2.so
.1.0 wechat
117 call_patchelf
--add-needed libbz2.so
.1 wechat
119 einfo
'Stripping executable permission of non-ELF files...'
121 for _file
in $
(find -type f
-perm /111); do
122 readelf
-h "${_file}" &>/dev
/null
&& continue || true
123 stat
--printf ' %A => ' "${_file}"
124 chmod u-x
,g-x
,o-x
"${_file}"
125 stat
--format '%A %n' "${_file}"
130 einfo
"Building stub libuosdevicea.so"
131 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev
/null
132 call_cc
-fPIC -shared ${CFLAGS} ${LDFLAGS} -o libuosdevicea.so libuosdevicea.c || die
137 LIB_DIR
=/usr
/lib
/wechat-universal
138 pushd "${S}/wechat-universal-bwrap-${AUR_REPO_REF}" > /dev
/null
139 domenu wechat-universal.desktop
140 exeinto
/usr
/lib
/wechat-universal
141 newexe wechat-universal.sh start.sh
142 newexe wechat-universal.sh stop.sh
144 exeinto
${LIB_DIR}/usr
/bin
145 newexe fake_dde-file-manager dde-file-manager
147 insinto
/opt
/wechat-universal
148 doins libuosdevicea.so
149 insinto
${LIB_DIR}/usr
/lib
/license
150 doins libuosdevicea.so
153 # needed on the host side for bwrap to be able to do the bind-mount
154 keepdir
/usr
/lib
/license
156 insinto
${LIB_DIR}/etc
157 newins
"${FILESDIR}/stub-uos-release" lsb-release
159 insinto
/opt
/wechat-universal
160 doins
-r "${S}/opt/apps/${APP_NAME}/files/"*
161 fperms
0755 /opt
/wechat-universal
/{crashpad_handler
,wechat
,wxocr
,wxplayer
}
162 fperms
0755 /opt
/wechat-universal
/RadiumWMPF
/runtime
/WeChatAppEx
{,_crashpad_handler
}
164 einfo
"Installing icons..."
165 for i
in 16 32 64 128 256; do
166 png_file
="${S}/opt/apps/${APP_NAME}/entries/icons/hicolor/${i}x${i}/apps/${APP_NAME}.png"
167 if [ -e "${png_file}" ]; then
168 newicon
-s "${i}" -c apps
"${png_file}" "wechat-universal.png"
174 if [[ "$LANG" == "zh_CN.UTF-8" ]]; then
175 elog
'>> 注意!升级至4.0版本后,环境变量已统一至WECHAT_ 前缀'
176 elog
'>> 执行 `wechat-universal --help` 来查看相关帮助信息'
178 elog
'>> Warning! After updating to v4.0, all environment variables are unified to be prefixed with WECHAT_'
179 elog
'>> Run `wechat-universal --help` to check for the help message'