mirror of
https://github.com/archlinux/aur.git
synced 2026-02-13 20:13:31 +01:00
[fix] bwrap flags & wait slirp to launch
This commit is contained in:
parent
904e53bcf0
commit
06d8814573
4 changed files with 41 additions and 33 deletions
6
.SRCINFO
6
.SRCINFO
|
|
@ -1,7 +1,7 @@
|
|||
pkgbase = linuxqq-nt-bwrap
|
||||
pkgdesc = New Linux QQ based on Electron, with bubblewrap sandbox and some tweaks
|
||||
pkgver = 3.2.8_23873
|
||||
pkgrel = 3
|
||||
pkgrel = 4
|
||||
url = https://im.qq.com/linuxqq/index.shtml
|
||||
install = linuxqq-nt-bwrap.install
|
||||
arch = x86_64
|
||||
|
|
@ -38,8 +38,8 @@ pkgbase = linuxqq-nt-bwrap
|
|||
source = config.json
|
||||
source = resolv.conf
|
||||
source = xdg-open.sh
|
||||
sha256sums = b80f808b69a930f49a0a59e5441abfa920e302caa30d87e0053a1420e1719b91
|
||||
sha256sums = 0215ba3592428a1bd351181436fc8ae5462c841132169d3420a6676a13c43449
|
||||
sha256sums = 92f5cd9f279dd998af3cd63643aa8591bed8afd203dff09ae518417a965d2c38
|
||||
sha256sums = 3c78b576aa5d07e4cacde95d1088530503478bb0d43d19371c5da56f675d9861
|
||||
sha256sums = bb2ec0f104da4da7422d9b0f51c71d0ab38ed2a21764a7a643ab42689e098e4b
|
||||
sha256sums = cc002ee0eb2e8702c97d16f4ce628841cd5fe10195875a075432e92248741424
|
||||
sha256sums = f1c778b5a8b23bc77fd8e5e89056fea07309794c9a44ec38134a176cf1f7b675
|
||||
|
|
|
|||
6
PKGBUILD
6
PKGBUILD
|
|
@ -7,7 +7,7 @@ _update_pkgver=${_base_pkgver}
|
|||
_md5=96fbb21f
|
||||
pkgname=linuxqq-nt-bwrap
|
||||
pkgver="${_update_pkgver//-/_}"
|
||||
pkgrel=3
|
||||
pkgrel=4
|
||||
pkgdesc="New Linux QQ based on Electron, with bubblewrap sandbox and some tweaks"
|
||||
arch=('x86_64' 'aarch64' 'loong64')
|
||||
url='https://im.qq.com/linuxqq/index.shtml'
|
||||
|
|
@ -29,8 +29,8 @@ source_x86_64=("https://dldir1.qq.com/qqfile/qq/QQNT/${_md5}/linuxqq_${_base_pkg
|
|||
source_aarch64=("https://dldir1.qq.com/qqfile/qq/QQNT/${_md5}/linuxqq_${_base_pkgver}_arm64.deb")
|
||||
source_loong64=("https://dldir1.qq.com/qqfile/qq/QQNT/${_md5}/linuxqq_${_base_pkgver}_loongarch64.deb")
|
||||
source=('start.sh' '_start.sh' 'config.json' 'resolv.conf' 'xdg-open.sh')
|
||||
sha256sums=('b80f808b69a930f49a0a59e5441abfa920e302caa30d87e0053a1420e1719b91' # start.sh
|
||||
'0215ba3592428a1bd351181436fc8ae5462c841132169d3420a6676a13c43449' # _start.sh
|
||||
sha256sums=('92f5cd9f279dd998af3cd63643aa8591bed8afd203dff09ae518417a965d2c38' # start.sh
|
||||
'3c78b576aa5d07e4cacde95d1088530503478bb0d43d19371c5da56f675d9861' # _start.sh
|
||||
'bb2ec0f104da4da7422d9b0f51c71d0ab38ed2a21764a7a643ab42689e098e4b' # config.json
|
||||
'cc002ee0eb2e8702c97d16f4ce628841cd5fe10195875a075432e92248741424' # resolv.conf
|
||||
'f1c778b5a8b23bc77fd8e5e89056fea07309794c9a44ec38134a176cf1f7b675') # xdg-open.sh
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@
|
|||
|
||||
trap 'kill $(jobs -p)' EXIT
|
||||
|
||||
echo $$ > ${INFO_FILE}
|
||||
echo $$ > "${INFO_FILE}"
|
||||
echo "PID written."
|
||||
|
||||
# wait for the file to be deleted
|
||||
while [ -f ${INFO_FILE} ]; do
|
||||
while [ -f "${INFO_FILE}" ]; do
|
||||
sleep 0.01
|
||||
done
|
||||
sleep 0.01
|
||||
# clear proxy settings
|
||||
unset http_proxy
|
||||
unset https_proxy
|
||||
|
|
|
|||
55
start.sh
55
start.sh
|
|
@ -43,13 +43,12 @@ fi
|
|||
# 从 flags 文件中加载参数
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
electron_flags_file="${XDG_CONFIG_HOME}/qq-electron-flags.conf"
|
||||
declare -a electron_flags
|
||||
|
||||
if [[ -f "${electron_flags_file}" ]]; then
|
||||
mapfile -t ELECTRON_FLAGS_MAPFILE <"${electron_flags_file}"
|
||||
fi
|
||||
|
||||
for line in "${ELECTRON_FLAGS_MAPFILE[@]}"; do
|
||||
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]]; then
|
||||
electron_flags+=("${line}")
|
||||
|
|
@ -58,17 +57,18 @@ done
|
|||
|
||||
bwrap_flags_file="${XDG_CONFIG_HOME}/qq-bwrap-flags.conf"
|
||||
declare -a bwrap_flags
|
||||
|
||||
if [[ -f "${bwrap_flags_file}" ]]; then
|
||||
mapfile -t BWRAP_FLAGS_MAPFILE <"${bwrap_flags_file}"
|
||||
while IFS= read -r line; do
|
||||
if [[ ! "${line}" =~ ^[[:space:]]*# ]] && [[ -n "${line}" ]]; then
|
||||
eval "expanded_line=\"$line\""
|
||||
read -ra parts <<< "$expanded_line"
|
||||
for part in "${parts[@]}"; do
|
||||
bwrap_flags+=("$part")
|
||||
done
|
||||
fi
|
||||
done < "${bwrap_flags_file}"
|
||||
fi
|
||||
|
||||
for line in "${BWRAP_FLAGS_MAPFILE[@]}"; do
|
||||
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]]; then
|
||||
bwrap_flags+=("${line}")
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
# read the mac address from .qq_mac, if not exist, generate a random one
|
||||
if [ -f "${QQ_APP_DIR}/.qq_mac" ]; then
|
||||
|
|
@ -114,7 +114,6 @@ fi
|
|||
|
||||
INFO_DIR=$(mktemp -d)
|
||||
INFO_FILE=$INFO_DIR/info
|
||||
touch $INFO_FILE
|
||||
|
||||
bwrap --new-session --unshare-user-try --unshare-cgroup-try \
|
||||
--unshare-user \
|
||||
|
|
@ -162,24 +161,30 @@ bwrap --new-session --unshare-user-try --unshare-cgroup-try \
|
|||
"${bwrap_flags[@]}" \
|
||||
/opt/QQ/_start.sh "${electron_flags[@]}" "$@" /opt/QQ/resources/app &
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
rm $INFO_FILE
|
||||
if [ "$?" -ne 0 ]; then
|
||||
rm "$INFO_FILE"
|
||||
echo "bwrap failed"
|
||||
exit 1
|
||||
fi
|
||||
while [ ! -s $INFO_FILE ]; do
|
||||
while [ ! -s "$INFO_FILE" ]; do
|
||||
sleep 0.01
|
||||
done
|
||||
PID=$(cat $INFO_FILE)
|
||||
|
||||
PID="$(cat "$INFO_FILE")"
|
||||
echo "SubProcess PID: $PID"
|
||||
|
||||
SLIRP_API_SOCKET=$INFO_DIR/slirp.sock
|
||||
slirp4netns --configure --mtu=65520 --disable-host-loopback --enable-ipv6 $PID eth0 --macaddress $qq_mac --api-socket $SLIRP_API_SOCKET &
|
||||
slirp4netns --configure --mtu=65520 --disable-host-loopback --enable-ipv6 "$PID" eth0 --macaddress "$qq_mac" --api-socket "$SLIRP_API_SOCKET" &
|
||||
SLIRP_PID=$!
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
while [ ! -S "$SLIRP_API_SOCKET" ]; do
|
||||
sleep 0.01
|
||||
done
|
||||
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "slirp4netns failed"
|
||||
kill $PID
|
||||
rm -rf ${INFO_DIR:?}
|
||||
kill "$PID"
|
||||
rm -rf "${INFO_DIR:?}"
|
||||
exit 1
|
||||
fi
|
||||
add_hostfwd() {
|
||||
|
|
@ -201,10 +206,12 @@ https_ports=(4301 4303 4305 4307 4309)
|
|||
http_ports=(4310 4308 4306 4304 4302)
|
||||
add_hostfwd "tcp" 94301 "${https_ports[@]}"
|
||||
add_hostfwd "tcp" 94310 "${http_ports[@]}"
|
||||
rm $INFO_FILE
|
||||
rm "$INFO_FILE"
|
||||
# 启动步骤结束
|
||||
tail --pid=$PID -f /dev/null
|
||||
kill -TERM $SLIRP_PID
|
||||
# wait $SLIRP_PID
|
||||
rm -rf ${INFO_DIR:?}
|
||||
tail --pid="$PID" -f /dev/null
|
||||
echo "Cleaning up..."
|
||||
set +e
|
||||
kill -TERM "$SLIRP_PID"
|
||||
wait "$SLIRP_PID"
|
||||
rm -rf "${INFO_DIR:?}"
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue