diff --git a/README.md b/README.md new file mode 100644 index 0000000..1bd2ec1 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# 微信 AppImage + +使用 AppImage 运行 Linux 原生微信 + +- 无需安装 +- 规避原微信的不可卸载特性 +- 无需更改系统的 `lsb-release` 等 `/etc` 内的文件 +- 无需 sudo +- 限制读写目录,以防在操作系统里到处乱放文件 + +## 使用前提 + +- 需要安装 bwrap(常见发行版都有) +- 需要有 XDG 用户目录(常见发行版都有) + - 查看 `~/.config/user-dirs.dirs`(必须有这个文件) + - 里面要有 `XDG_DESKTOP_DIR`、`XDG_DOWNLOAD_DIR` 和 `XDG_DOCUMENTS_DIR` + - 运行时,在用户目录下,微信只能读写这三个目录、微信数据库文件(放在 `${XDG_DOCUMENTS_DIR}/xwechat_files` 下,原生微信是 `~/xwechat_files`)、微信配置文件(`~/.xwechat`)和字体配置文件。 + +## 获取 AppImage 文件 + +### 从 release 下载 + +在本仓库 release 下载 x86_64 版,该版本基于[吾爱破解](https://www.52pojie.cn/thread-1896902-1-1.html)给出的 238 版构建。下载后记得给执行权限。 + +### 自行构建 + +以下构建方式仅测试过 238 的 x86_64 版。 + +下载本仓库,同时下载一个微信 Linux 版本的 deb 包。 + +解包 deb,移植文件: + +```bash +# pwd 为仓库根目录 +dpkg -X your_wechat.deb /tmp/out +cp -r /tmp/out/opt src # 大部分文件 +cp -r /tmp/out/usr/lib src/usr # 应该只有 libactivation.so +``` + +安装 appimagetool(自己上网搜) + +打包 appimage: + +```bash +# pwd 为仓库根目录上一级 +appimagetool ./wechat-appimage +``` + +可以取得 `wechat-x86_64.AppImage` + +## 运行方法 + +已经测试在 Debian 和 kali 运行过。 + +注:实际测试中有极少时候第一次扫码之后没反应,此时可以关闭重新启动扫码。 + +### 简单运行 + +直接双击此文件或者命令行启动即可。 + +### 安装运行 + +```bash +sudo mv wechat-x86_64.AppImage /usr/bin/wechat +sudo wechat --install # 安装图标 +``` + +然后你可以在桌面添加类似的启动器图标。 + +### 更多功能 + +```bash +# 帮助 +wechat-x86_64.AppImage --help +# 进入 bwrap 的 shell(bash) +wechat-x86_64.AppImage --debug +# 关闭微信进程(早期版本无法退出,现在应该没了) +wechat-x86_64.AppImage --kill +# 安装图标 +sudo wechat-x86_64.AppImage --install +``` + +## 声明 + +未经过严格测试,使用本仓库造成的一切后果由使用者负责。 diff --git a/src/AppRun b/src/AppRun new file mode 100755 index 0000000..705a167 --- /dev/null +++ b/src/AppRun @@ -0,0 +1,85 @@ +#!/bin/bash +export PATH="$APPDIR/opt/wechat-beta:$PATH" +export LD_LIBRARY_PATH="$APPDIR/opt/wechat-beta:$APPDIR/usr/lib" +export LANG=zh_CN.UTF-8 +EXEC="wechat" +if [ $# -eq 1 ]; then + if [ "$1" = "help" -o "$1" = "--help" ]; then + echo "Run wechat without options" + echo "Options:" + echo " --debug return a shell but not wechat" + echo " --kill to kill wechat process" + echo " --install(root required) to install desktop file to /usr/share/applications" + exit $? + fi + if [ "$1" = "--debug" ]; then + EXEC="bash" + fi + if [ "$1" = "--kill" ]; then + kill $(ps -e | grep wechat | grep -v "wechat-" | awk '{print $1}') + exit $? + fi + if [ "$1" = "--install" ]; then + cp $APPDIR/usr/share/applications/wechat.desktop /usr/share/applications + cp $APPDIR/usr/share/icons/hicolor/256x256/apps/wechat.png /usr/share/icons/hicolor/256x256/apps + exit $? + fi +fi +# wechat-beta only support xcb +BWRAP_ENV_APPEND="--setenv QT_QPA_PLATFORM xcb " +if [ -z ${QT_IM_MODULE} ]; then + BWRAP_ENV_APPEND="${BWRAP_ENV_APPEND} --setenv QT_IM_MODULE fcitx" +fi +if [ -z ${GTK_USE_PORTAL} ]; then + BWRAP_ENV_APPEND="${BWRAP_ENV_APPEND} --setenv GTK_USE_PORTAL 1" +fi +# append user config file +BWRAP_FILE_APPEND="" +if [ -e ~/.config/user-dirs.dirs ]; then + source ~/.config/user-dirs.dirs + WECHAT_CFG_DIR=${XDG_DOCUMENTS_DIR}/xwechat_files + mkdir -p ${WECHAT_CFG_DIR} + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DESKTOP_DIR} ${XDG_DESKTOP_DIR} " + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DOCUMENTS_DIR} ${XDG_DOCUMENTS_DIR} " + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${XDG_DOWNLOAD_DIR} ${XDG_DOWNLOAD_DIR} " + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${WECHAT_CFG_DIR} $HOME/xwechat_files " +else + echo ">>>>> WARNING: no xdg config file (~/.config/user-dirs.dirs) found." + echo ">>>>> YOU SHOULD CONFIG IT but now wechat will try continue to run." +fi +FONT1=$HOME/.cache/fontconfig +FONT2=$HOME/.config/fontconfig +if [ -e ${FONT1} ]; then + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${FONT1} ${FONT1} " +fi +if [ -e ${FONT2} ]; then + BWRAP_FILE_APPEND="${BWRAP_FILE_APPEND} --bind ${FONT2} ${FONT2} " +fi +mkdir -p $HOME/.xwechat +bwrap --die-with-parent \ + --ro-bind / / \ + --tmpfs /sys --tmpfs /home --tmpfs /etc --proc /proc \ + --tmpfs /run --tmpfs /usr/lib --tmpfs /tmp --dev /dev \ + --ro-bind $APPDIR $APPDIR \ + --ro-bind $APPDIR/etc/os-release /etc/os-release \ + --ro-bind $APPDIR/etc/lsb-release /etc/lsb-release \ + --ro-bind $APPDIR/etc/.kyact /etc/.kyact \ + --ro-bind $APPDIR/etc/LICENSE /etc/LICENSE \ + --ro-bind /etc/alternatives /etc/alternatives \ + --ro-bind /etc/fonts /etc/fonts \ + --ro-bind /etc/hostname /etc/hostname \ + --ro-bind /etc/hosts /etc/hosts \ + --ro-bind /etc/ld.so.cache /etc/ld.so.cache \ + --ro-bind /etc/localtime /etc/localtime \ + --ro-bind /etc/passwd /etc/passwd \ + --ro-bind /etc/resolv.conf /etc/resolv.conf \ + --ro-bind $APPDIR/usr/lib/libactivation.so /usr/lib/libactivation.so \ + --ro-bind /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu \ + --ro-bind /usr/lib/udev /usr/lib/udev \ + --ro-bind /run/user/$UID /run/user/$UID \ + --bind $HOME/.xwechat $HOME/.xwechat \ + ${BWRAP_FILE_APPEND} \ + ${BWRAP_ENV_APPEND} \ + ${EXEC} +# refer: https://blog.lilydjwg.me/2021/8/12/using-bwrap.215869.html +# refer: https://github.com/lfift/wechat-beta-bwrap/blob/main/wechat.sh diff --git a/src/etc/.kyact b/src/etc/.kyact new file mode 100644 index 0000000..5af4b92 --- /dev/null +++ b/src/etc/.kyact @@ -0,0 +1,5 @@ +systemuuid=25ef0280-ec82-42b0-8fb6-10adccc67c02 +netmac=00:07:3e:9c:2e:43 +registernum=WCYU-3AS2-Q7LP-HWH6-SJPZ +serialnum=27734012 +harddisk=WDC-PC-SN530-SDBPNPZ-512G_204485805972 diff --git a/src/etc/LICENSE b/src/etc/LICENSE new file mode 100644 index 0000000..b795523 --- /dev/null +++ b/src/etc/LICENSE @@ -0,0 +1,19 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +TO:麒麟软件内部版本 +SERIAL:100000 +TERM:2021-08-29 +CLASS:desktop +VERSION:Desktop +PLATFORM:x86_64 +OSNAME:Kylin V10 SP1 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v2.0.14 (GNU/Linux) + +iJwEAQECAAYFAmEDwk8ACgkQLRr+uL6cqPu6xAP/QRty0END7q0VxbbwgoKYefHk +VJF9F7SFSU5FGVUyR0pLmKzAMAmi+9xhbGw5tGp2XLIBOJHayK6TGhdpgvP+wT6s +0QLrh3c7HZhM0maoo6ZNR07bYzXXPcrMt6qTgaSRQnV+zfARn9+e2Ub5xfBfphtk +KHL1Nd4NRj0aICyjlys= +=6SEp +-----END PGP SIGNATURE----- diff --git a/src/etc/lsb-release b/src/etc/lsb-release new file mode 100644 index 0000000..25aaa17 --- /dev/null +++ b/src/etc/lsb-release @@ -0,0 +1,7 @@ +DISTRIB_ID=Kylin +DISTRIB_RELEASE=V10 +DISTRIB_CODENAME=kylin +DISTRIB_DESCRIPTION="Kylin V10 SP1" +DISTRIB_KYLIN_RELEASE=V10 +DISTRIB_VERSION_TYPE=enterprise +DISTRIB_VERSION_MODE=normal diff --git a/src/etc/os-release b/src/etc/os-release new file mode 100644 index 0000000..b67486e --- /dev/null +++ b/src/etc/os-release @@ -0,0 +1,6 @@ +NAME="Kylin Linux Advanced Server" +VERSION="V10 (Tercel)" +ID="kylin" +VERSION_ID="V10" +PRETTY_NAME="Kylin Linux Advanced Server V10 (Tercel)" +ANSI_COLOR="0;31" diff --git a/src/usr/share/applications/wechat.desktop b/src/usr/share/applications/wechat.desktop new file mode 100644 index 0000000..c534cfc --- /dev/null +++ b/src/usr/share/applications/wechat.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=微信 +Exec=wechat %U +StartupNotify=true +Terminal=false +Icon=/usr/share/icons/hicolor/256x256/apps/wechat.png +Type=Application +Categories=Utility; +Comment=微信桌面版 diff --git a/src/usr/share/icons/hicolor/256x256/apps/wechat.png b/src/usr/share/icons/hicolor/256x256/apps/wechat.png new file mode 100644 index 0000000..9133e9f Binary files /dev/null and b/src/usr/share/icons/hicolor/256x256/apps/wechat.png differ diff --git a/src/wechat.desktop b/src/wechat.desktop new file mode 100755 index 0000000..f735bff --- /dev/null +++ b/src/wechat.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=wechat +StartupNotify=true +Terminal=false +Icon=wechat +Type=Application +Categories=Utility; +Comment=微信桌面版 diff --git a/src/wechat.png b/src/wechat.png new file mode 100644 index 0000000..9133e9f Binary files /dev/null and b/src/wechat.png differ