aports

Custom Alpine Linux aports

git clone git://git.lin.moe/aports.git

  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=0
 11pkgdesc="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.deb
 20	$pkgname-$pkgver-$_upstream_gitref.tar.gz::https://github.com/7Ji-PKGBUILDs/wechat-universal-bwrap/archive/${_upstream_gitref}.tar.gz
 21	fix-bwrap-bind-path.patch 
 22	"
 23
 24builddir="$srcdir"
 25_upstreamdir="$srcdir/$pkgname-$_upstream_gitref"
 26options="!fhs !tracedeps !check textrels"
 27
 28prepare(){
 29	( builddir=$_upstreamdir default_prepare)
 30	
 31	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/hicolor
 35	
 36	mv share/icons/hicolor icons
 37	rm -rf share "${_upstream_name}"/libuosdevicea.so
 38
 39	echo 'Stripping executable permission of non-ELF files...'
 40	cd "${_upstream_name}"
 41	local _file
 42	find . -type f -perm /111 | while read _file; do
 43		if [[ "$(file --brief "${_file}")" == 'ELF '* ]]; then
 44			continue
 45		fi
 46		stat -c '  %A => ' "${_file}"
 47		chmod u-x,g-x,o-x "${_file}"
 48		stat -c $'%A %n\n' "${_file}"
 49	done
 50
 51	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_plugins
 56	find . -type f | while read _file; do
 57		echo "  '\$ORIGIN:\$ORIGIN/../..' <= vlc_plugins/${_file}"
 58		patchelf --set-rpath '$ORIGIN:$ORIGIN/../..' "${_file}"
 59	done
 60
 61}
 62
 63build() {
 64	cd "$_upstreamdir"
 65	echo "Building ${_lib_uos}.so stub by Zephyr Lykos..."
 66	mv libuosdevicea.Makefile Makefile
 67	make
 68}
 69
 70package() {
 71	echo 'Popupating pkgdir with earlier extracted data...'
 72	mkdir -p "$pkgdir"/opt
 73	cp -r --preserve=mode "$_upstream_name" "$pkgdir/opt/$_pkgname"
 74	
 75	echo 'Installing icons...'
 76	for res in 16 32 48 64 128 256; do
 77		install -Dm644 \
 78			"icons/${res}x${res}/apps/$_upstream_name.png" \
 79			"$pkgdir/usr/share/icons/hicolor/${res}x${res}/apps/$_pkgname.png"
 80	done
 81
 82	local _wechat_root="$pkgdir/usr/lib/$_pkgname"
 83
 84	cd $_upstreamdir
 85	
 86	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 sandbox
 88	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-release
 91
 92	echo 'Installing scripts...'
 93	install -Dm755 wechat-universal.sh "${_wechat_root}"/common.sh
 94	ln -s common.sh "${_wechat_root}"/start.sh
 95	ln -s common.sh "${_wechat_root}"/stop.sh
 96	mkdir -p "${pkgdir}"/usr/bin
 97	ln -s ../lib/"${_pkgname}"/common.sh "${pkgdir}"/usr/bin/"${_pkgname}"
 98
 99	echo 'Installing desktop files...'
100	install -Dm644 "${_pkgname}.desktop" "${pkgdir}/usr/share/applications/${_pkgname}.desktop"
101	
102	echo 'Installing license...'
103	install -Dm644 wechat-license "${pkgdir}/usr/share/licenses/${_pkgname}/"wechat-license
104}
105
106sha512sums="
10707a74569477ba87552d4ccf0bbc6c44b1a495a637f79a9852d2b674b2a99e0152418099f721921d5c24b7951ac37020f488f462decb864b6341f55d5c638262b  wechat-universal-4.1.1.4-loong64.deb
1085dbd13604851f586e68e46cc2376fd74a3b8703763eceb5b36c4d6946fc4e3ea9cda2b9fc681780e2da3b2a767eae03893a47d159a2c5a967772fbbf07697789  wechat-universal-bwrap-4.1.1.4-df08de953e4f2e51b3c7b97e8ecd19b20082cd8d.tar.gz
109cb0c781963a3b829427f0a14a64fbfcf2d459affb936f84709e5d7a7d66bbfff7fd0e8150677d9f57e89e8a90f5a6ad41bb3e5c69f477ec43357dc31e61234d0  fix-bwrap-bind-path.patch
110"