diff --git a/wechat/license/etc/lsb-release b/wechat/license/etc/lsb-release new file mode 100644 index 0000000..0c83ec8 --- /dev/null +++ b/wechat/license/etc/lsb-release @@ -0,0 +1,4 @@ +DISTRIB_ID=uos +DISTRIB_RELEASE=20 +DISTRIB_DESCRIPTION="UnionTech OS 20" +DISTRIB_CODENAME=plum diff --git a/wechat/license/etc/os-release b/wechat/license/etc/os-release new file mode 100644 index 0000000..714c4e5 --- /dev/null +++ b/wechat/license/etc/os-release @@ -0,0 +1,8 @@ +PRETTY_NAME="UnionTech OS Desktop 20 Home" +NAME="uos" +VERSION_ID="20 Home" +VERSION="20 Home" +ID=uos +HOME_URL="https://www.chinauos.com/" +BUG_REPORT_URL="http://bbs.chinauos.com" +VERSION_CODENAME=eagle diff --git a/wechat/license/libuosdevicea.so b/wechat/license/libuosdevicea.so new file mode 100755 index 0000000..f066c2b Binary files /dev/null and b/wechat/license/libuosdevicea.so differ diff --git a/wechat/license/var/lib/uos-license/.license.json b/wechat/license/var/lib/uos-license/.license.json new file mode 100644 index 0000000..73ff2e5 --- /dev/null +++ b/wechat/license/var/lib/uos-license/.license.json @@ -0,0 +1,15 @@ +{ + "confCustomHeadindex": 0, + "confCustomUrl": "", + "confDefault": true, + "confDefaultIndex": 0, + "defaultUrl": [ + "https://license.chinauos.com", + "https://license1.chinauos.com" + ], + "options": [ + {"protocol": "https://", "address": ""}, + {"protocol": "http://", "address": ""}, + {"protocol": "kms://","address": ""} + ] +} diff --git a/wechat/license/var/uos/.license.key b/wechat/license/var/uos/.license.key new file mode 100644 index 0000000..c13b03d Binary files /dev/null and b/wechat/license/var/uos/.license.key differ diff --git a/wechat/package.sh b/wechat/package.sh new file mode 100755 index 0000000..3540c7d --- /dev/null +++ b/wechat/package.sh @@ -0,0 +1,176 @@ +#!/bin/bash + +app_name="wechat" +tmp_dir="/tmp/${app_name}_tmp" +version="1.0.0.145" +release="1.0.0.145" + +deb_url="https://cdn4.cnxclm.com/uploads/2024/03/05/3VDyAc0x_wechat-beta_1.0.0.145_amd64.deb" +# 创建临时目录, 用于下载官方包 +if [ -d $tmp_dir ]; then + # echo "" + rm -rf $tmp_dir +fi + +if [ -d "./unpack" ]; then + sudo rm -rf ./unpack +fi + +if [ -f "./${app_name}_${version}.deb" ]; then + rm "./${app_name}_${version}.deb" +fi + + +mkdir $tmp_dir + +# 创建临时待打包目录 +echo "创建待打包目录..." +mkdir -p "./unpack/DEBIAN" +mkdir -p "./unpack/usr/bin" +mkdir -p "./unpack/usr/lib/license" +mkdir -p "./unpack/usr/share/wechat-uos" +mkdir -p "./unpack/usr/share/icons/hicolor/256x256/apps" + +echo "下载官方原包..." +wget $deb_url -O "${tmp_dir}/${app_name}.deb" + + +echo "下载完成, 解包中..." +dpkg-deb -R "${tmp_dir}/${app_name}.deb" "${tmp_dir}/${app_name}" + +echo "解包完成, 复制到待打包目录..." +cp -r "${tmp_dir}/${app_name}/opt" "./unpack/" +cp -r "${tmp_dir}/${app_name}/usr" "./unpack/" + +mv ./unpack/opt/wechat-beta/icons/wechat.png ./unpack/usr/share/icons/hicolor/256x256/apps/wechat.png +rm -rf ./unpack/opt/wechat-beta/icons + +rm -rf $tmp_dir + +echo "复制uos环境文件..." +cp -r ./license/etc ./unpack/usr/share/wechat-uos/ +cp -r ./license/var ./unpack/usr/share/wechat-uos/ +cp ./license/libuosdevicea.so ./unpack/usr/lib/license/libuosdevicea.so + +echo "复制完成, 创建可执行文件及程序桌面入口文件..." + +echo """ +[Desktop Entry] +Name=WeChat +Name[zh_CN]=微信 +Exec=wechat %u +Icon=wechat +Categories=Utility;Network;InstantMessaging;Chat; +Terminal=false +Type=Application +StartupWMClass=WeChat +X-GNOME-SingleWindow=true +SingleMainWindow=true +""" > "./unpack/usr/share/applications/wechat.desktop" + + +echo """ +#!/bin/bash + +# wechat only support xcb +BWRAP_ENV_APPEND=\"--setenv QT_QPA_PLATFORM xcb \" +WECHAT_HOME_DIR=\"\${HOME}/Documents/WeChat_Data\" + +if [ -z \${QT_IM_MODULE} ]; then + BWRAP_ENV_APPEND=\"\${BWRAP_ENV_APPEND} --setenv QT_IM_MODULE fcitx\" +fi + +case \"\$XDG_CURRENT_DESKTOP\" in + KDE) + SCALE_FACTOR=\$(kreadconfig6 --group KScreen --key ScaleFactor --default 1.0) + BWRAP_ENV_APPEND=\"\${BWRAP_ENV_APPEND} --setenv QT_SCALE_FACTOR \${SCALE_FACTOR}\" + ;; + *) + BWRAP_ENV_APPEND=\"\${BWRAP_ENV_APPEND} --setenv QT_AUTO_SCREEN_SCALE_FACTOR \${QT_AUTO_SCREEN_SCALE_FACTOR:-1}\" + ;; +esac + +if [ -z \${GTK_USE_PORTAL} ]; then + BWRAP_ENV_APPEND=\"\${BWRAP_ENV_APPEND} --setenv GTK_USE_PORTAL 1\" +fi + +if [ ! -d \"\${WECHAT_HOME_DIR}\" ]; then + mkdir -p \${WECHAT_HOME_DIR} +fi + +exec bwrap \\ + --dev-bind / / \\ + --bind \"\${WECHAT_HOME_DIR}\" \"\${HOME}\" \\ + --ro-bind /usr/share/wechat-uos/var/ /var/ \\ + --ro-bind /usr/share/wechat-uos/etc/os-release /etc/os-release \\ + --ro-bind /usr/share/wechat-uos/etc/lsb-release /etc/lsb-release \\ + \${BWRAP_ENV_APPEND} \\ + /opt/wechat-beta/wechat \$@ + + +""" > ./unpack/usr/bin/wechat + +chmod +x ./unpack/usr/bin/wechat + + +echo "修正完成, 计算文件md5..." + +cd ./unpack + +# opt目录中有文件名中带有空格, ;xargs需要处理一下 +find opt/ -type f | xargs -I {} md5sum {} > DEBIAN/md5sums +find usr/ -type f | xargs md5sum >> DEBIAN/md5sums + +IFS=$'\t' read -ra size <<< "$(du -d 0)" + +echo """ +Package: ${app_name} +Version: ${version} +Architecture: amd64 +Maintainer: Yutent +Installed-Size: ${size[0]} +Depends: bubblewrap, libssl1.1 +Section: non-free/chat +Priority: optional +Homepage: https://weixin.qq.com +Description: linux wechat +""" > DEBIAN/control + +echo """ +#!/bin/bash -e + +set -e + +if [ ! -f /etc/lsb-release ]; then + touch /etc/lsb-release +fi + +""" > DEBIAN/postinst + +echo """ +#!/bin/bash -e + +set -e + +if [ -f /etc/lsb-release ]; then + _cont=\"\$(cat /etc/lsb-release)\" + + if [ \$_cont == \"\" ]; then + rm -f /etc/lsb-release + fi +fi + +""" > DEBIAN/prerm + +chmod +x DEBIAN/postinst +chmod +x DEBIAN/prerm + +echo '计算文件md5完成, 打包中...' + +cd .. +sudo chown -R root:root unpack + +dpkg-deb -b ./unpack "./${app_name}_${version}.deb" + +sudo rm -rf ./unpack +echo "打包完成 :)" \ No newline at end of file