1# Maintainer: Lindsay Zhou <i@lin.moe>2maintainer="Lindsay Zhou <i@lin.moe>"3_pkgname="wechat-universal"4_upstream_gitref="df08de953e4f2e51b3c7b97e8ecd19b20082cd8d"5_upstream_name="wechat"6_deb_url_common='https://dldir1v6.qq.com/weixin/Universal/Linux/WeChatLinux_'7_lib_uos='libuosdevicea'8pkgname="$_pkgname-bwrap"9pkgver='4.1.1.4'10pkgrel=011pkgdesc="WeChat (Universal) with bwrap sandbox"12arch="loongarch64"13url="https://linux.weixin.qq.com/"14license="LicenseRef-wechat-license"15install="${pkgname}.post-install"16depends="liblol-bin flatpak-xdg-utils"17makedepends="binutils cmd:bsdtar patchelf"18source="19 ${_pkgname}-${pkgver}-loong64.deb::${_deb_url_common}LoongArch.deb20 $pkgname-$pkgver-$_upstream_gitref.tar.gz::https://github.com/7Ji-PKGBUILDs/wechat-universal-bwrap/archive/${_upstream_gitref}.tar.gz21 fix-bwrap-bind-path.patch22 "2324builddir="$srcdir"25_upstreamdir="$srcdir/$pkgname-$_upstream_gitref"26options="!fhs !tracedeps !check textrels"2728prepare(){29 ( builddir=$_upstreamdir default_prepare)3031 echo 'Extracting data from deb...'32 bsdtar --extract --to-stdout --file "${_pkgname}-${pkgver}-loong64.deb" ./data.tar.xz |33 xz --to-stdout --decompress --threads 0 |34 tar --strip-components 2 --extract ./opt/"${_upstream_name}" ./usr/share/icons/hicolor3536 mv share/icons/hicolor icons37 rm -rf share "${_upstream_name}"/libuosdevicea.so3839 echo 'Stripping executable permission of non-ELF files...'40 cd "${_upstream_name}"41 local _file42 find . -type f -perm /111 | while read _file; do43 if [[ "$(file --brief "${_file}")" == 'ELF '* ]]; then44 continue45 fi46 stat -c ' %A => ' "${_file}"47 chmod u-x,g-x,o-x "${_file}"48 stat -c $'%A %n\n' "${_file}"49 done5051 echo 'Patching rpath...'52 patchelf --set-rpath '$ORIGIN' 'libwxtrans.so'53 patchelf --set-rpath '$ORIGIN' 'libroam_migration.so'54 echo " '\$ORIGIN' <= libwxtrans.so"55 cd vlc_plugins56 find . -type f | while read _file; do57 echo " '\$ORIGIN:\$ORIGIN/../..' <= vlc_plugins/${_file}"58 patchelf --set-rpath '$ORIGIN:$ORIGIN/../..' "${_file}"59 done6061}6263build() {64 cd "$_upstreamdir"65 echo "Building ${_lib_uos}.so stub by Zephyr Lykos..."66 mv libuosdevicea.Makefile Makefile67 make68}6970package() {71 echo 'Popupating pkgdir with earlier extracted data...'72 mkdir -p "$pkgdir"/opt73 cp -r --preserve=mode "$_upstream_name" "$pkgdir/opt/$_pkgname"7475 echo 'Installing icons...'76 for res in 16 32 48 64 128 256; do77 install -Dm644 \78 "icons/${res}x${res}/apps/$_upstream_name.png" \79 "$pkgdir/usr/share/icons/hicolor/${res}x${res}/apps/$_pkgname.png"80 done8182 local _wechat_root="$pkgdir/usr/lib/$_pkgname"8384 cd $_upstreamdir8586 echo 'Fixing licenses...'87 install -dm755 "${pkgdir}"/usr/lib/license # This is needed if /usr/lib/license/${_lib_uos}.so needs to be mounted in sandbox88 install -Dm755 "${_lib_uos}.so" "${_wechat_root}"/usr/lib/license/"${_lib_uos}.so"89 echo 'DISTRIB_ID=uos' |90 install -Dm755 /dev/stdin "${_wechat_root}"/etc/lsb-release9192 echo 'Installing scripts...'93 install -Dm755 wechat-universal.sh "${_wechat_root}"/common.sh94 ln -s common.sh "${_wechat_root}"/start.sh95 ln -s common.sh "${_wechat_root}"/stop.sh96 mkdir -p "${pkgdir}"/usr/bin97 ln -s ../lib/"${_pkgname}"/common.sh "${pkgdir}"/usr/bin/"${_pkgname}"9899 echo 'Installing desktop files...'100 install -Dm644 "${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop"101102 echo 'Installing license...'103 install -Dm644 wechat-license "${pkgdir}/usr/share/licenses/${_pkgname}/"wechat-license104}105106sha512sums="10707a74569477ba87552d4ccf0bbc6c44b1a495a637f79a9852d2b674b2a99e0152418099f721921d5c24b7951ac37020f488f462decb864b6341f55d5c638262b wechat-universal-4.1.1.4-loong64.deb1085dbd13604851f586e68e46cc2376fd74a3b8703763eceb5b36c4d6946fc4e3ea9cda2b9fc681780e2da3b2a767eae03893a47d159a2c5a967772fbbf07697789 wechat-universal-bwrap-4.1.1.4-df08de953e4f2e51b3c7b97e8ecd19b20082cd8d.tar.gz109cb0c781963a3b829427f0a14a64fbfcf2d459affb936f84709e5d7a7d66bbfff7fd0e8150677d9f57e89e8a90f5a6ad41bb3e5c69f477ec43357dc31e61234d0 fix-bwrap-bind-path.patch110"