3 QQ_HOTUPDATE_VERSION
="__CURRENT_VER__"
5 function command_exists
() {
7 command -v "${command}" >/dev
/null
2>&1
10 function show_error_dialog
() {
11 title
="linuxqq-nt-bwrap"
12 if command_exists kdialog
; then
13 kdialog
--error "$1" --title "$title" --icon qq
14 elif command_exists zenity
; then
15 zenity
--error --title "$title" --icon-name qq
--text "$1"
17 all_off
="$(tput sgr0)"
18 bold
="${all_off}$(tput bold)"
19 blue
="${bold}$(tput setaf 4)"
20 yellow
="${bold}$(tput setaf 3)"
21 printf "${blue}==>${yellow} ${bold} $1${all_off}\n"
26 if [ ! -e "/etc/localtime" ]; then
27 show_error_dialog
"/etc/localtime 未找到。\n请先设置系统时区。"
31 USER_RUN_DIR
="/run/user/$(id -u)"
32 XAUTHORITY
="${XAUTHORITY:-$HOME/.Xauthority}"
33 XDG_CONFIG_HOME
="${XDG_CONFIG_HOME:-$HOME/.config}"
34 FONTCONFIG_HOME
="${XDG_CONFIG_HOME}/fontconfig"
35 QQ_APP_DIR
="${XDG_CONFIG_HOME}/QQ"
36 if [ -z "${QQ_DOWNLOAD_DIR}" ]; then
37 if [ -z "${XDG_DOWNLOAD_DIR}" ]; then
38 XDG_DOWNLOAD_DIR
="$(xdg-user-dir DOWNLOAD)"
40 QQ_DOWNLOAD_DIR
="${XDG_DOWNLOAD_DIR:-$HOME/Downloads}"
46 flags_file
="${XDG_CONFIG_HOME}/qq-electron-flags.conf"
49 if [[ -f "${flags_file}" ]]; then
50 mapfile
-t <"${flags_file}"
53 for line
in "${MAPFILE[@]}"; do
54 if [[ ! "${line}" =~ ^
[[:space
:]]*#.* ]]; then
59 QQ_HOTUPDATE_DIR
="${QQ_APP_DIR}/versions"
61 # 在「下载」目录不存在的时候,自动使用 ~/Downloads
63 if [ "${QQ_DOWNLOAD_DIR%*/}" == "${HOME}" ]; then
64 QQ_DOWNLOAD_DIR
="${HOME}/Downloads"
68 HOTUPDATE_VERSION_DIR
="${QQ_HOTUPDATE_DIR}/${QQ_HOTUPDATE_VERSION}"
69 install -d "${QQ_HOTUPDATE_DIR}"
70 if [ ! -d "${HOTUPDATE_VERSION_DIR}" ] && [ ! -L "${HOTUPDATE_VERSION_DIR}" ]; then
71 ln -sfd "/opt/QQ/resources/app" "${HOTUPDATE_VERSION_DIR}"
75 rm -rf "${QQ_HOTUPDATE_DIR}/"**".zip"
76 is_hotupdated_version
=0 # 正在运行的版本是否经过热更新?
78 find "${QQ_HOTUPDATE_DIR}/"*[-_]* -maxdepth 1 -type "d,l" |
while read path
; do
79 this_version
="$(basename "$path")"
80 if [ "$(/opt/QQ/workarounds/vercmp.sh "${this_version}" lt "${QQ_HOTUPDATE_VERSION//_/-}")" == "true" ]; then
82 echo "rm $this_version"
85 is_hotupdated_version
=1
89 if [ "$is_hotupdated_version" == "0" ]; then
90 cp "/opt/QQ/workarounds/config.json" "${QQ_HOTUPDATE_DIR}/config.json"
93 bwrap
--new-session --cap-drop ALL
--unshare-user-try --unshare-pid --unshare-cgroup-try \
95 --ro-bind /lib64
/lib64 \
99 --ro-bind /opt
/QQ
/workarounds
/xdg-open.sh
/usr
/bin
/xdg-open \
100 --ro-bind /usr
/lib
/snapd-xdg-open
/xdg-open
/snapd-xdg-open \
101 --ro-bind /usr
/lib
/flatpak-xdg-utils
/xdg-open
/flatpak-xdg-open \
102 --ro-bind /etc
/machine-id
/etc
/machine-id \
103 --ro-bind /etc
/ld.so.cache
/etc
/ld.so.cache \
104 --dev-bind /dev
/dev \
105 --ro-bind /sys
/sys \
106 --ro-bind /etc
/passwd
/etc
/passwd \
107 --ro-bind /etc
/nsswitch.conf
/etc
/nsswitch.conf \
108 --ro-bind-try /run
/systemd
/userdb
/run
/systemd
/userdb \
109 --ro-bind /etc
/resolv.conf
/etc
/resolv.conf \
110 --ro-bind /etc
/localtime
/etc
/localtime \
112 --dev-bind /run
/dbus
/run
/dbus \
113 --bind "${USER_RUN_DIR}" "${USER_RUN_DIR}" \
114 --ro-bind-try /etc
/fonts
/etc
/fonts \
115 --dev-bind /tmp
/tmp \
116 --bind-try "${HOME}/.pki" "${HOME}/.pki" \
117 --ro-bind-try "${XAUTHORITY}" "${XAUTHORITY}" \
118 --bind-try "${QQ_DOWNLOAD_DIR}" "${QQ_DOWNLOAD_DIR}" \
119 --setenv QQ_APP_DIR
"${QQ_APP_DIR}" \
120 --bind "${QQ_APP_DIR}" "${QQ_APP_DIR}" \
121 --ro-bind-try "${FONTCONFIG_HOME}" "${FONTCONFIG_HOME}" \
122 --ro-bind-try "${HOME}/.icons" "${HOME}/.icons" \
123 --ro-bind-try "${HOME}/.local/share/.icons" "${HOME}/.local/share/.icons" \
124 --ro-bind-try "${XDG_CONFIG_HOME}/gtk-3.0" "${XDG_CONFIG_HOME}/gtk-3.0" \
125 --ro-bind /etc
/nsswitch.conf
/etc
/nsswitch.conf \
126 --ro-bind-try /run
/systemd
/userdb
/ /run
/systemd
/userdb
/ \
127 --setenv IBUS_USE_PORTAL
1 \
128 --setenv QQNTIM_HOME
"${QQ_APP_DIR}/QQNTim" \
129 --setenv LITELOADERQQNT_PROFILE
"${QQ_APP_DIR}/LiteLoaderQQNT" \
130 /opt
/QQ
/qq
"${flags[@]}" "$@"
133 # 如果需要向腾讯反馈 bug,请注释掉如下几行
134 rm -rf ${QQ_APP_DIR}/crash_files
135 touch ${QQ_APP_DIR}/crash_files
136 if [ -d "${QQ_APP_DIR}/log" ]; then
137 rm -rf "${QQ_APP_DIR}/log"
139 for nt_qq_userdata
in "${QQ_APP_DIR}/nt_qq_"*; do
140 if [ -d "${nt_qq_userdata}/log" ]; then
141 rm -rf "${nt_qq_userdata}/log"
143 if [ -d "${nt_qq_userdata}/log-cache" ]; then
144 rm -rf "${nt_qq_userdata}/log-cache"
147 if [ -d "${QQ_APP_DIR}/Crashpad" ]; then
148 rm -rf "${QQ_APP_DIR}/Crashpad"