!360 修复在qt 5.11 的编译问题

Merge pull request !360 from shenmo/dev
This commit is contained in:
shenmo 2025-09-05 13:57:08 +00:00 committed by Gitee
commit cf276efd10
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 64 additions and 60 deletions

View File

@ -1,4 +1,5 @@
#include "applistmodel.h" #include "applistmodel.h"
#include <QDebug>
AppListModel::AppListModel(QObject *parent) : QAbstractListModel(parent) {} AppListModel::AppListModel(QObject *parent) : QAbstractListModel(parent) {}

View File

@ -24,7 +24,7 @@ QStringList aptssUpdater::getUpdateablePackages()
} }
QString output = process.readAllStandardOutput(); QString output = process.readAllStandardOutput();
QStringList lines = output.split('\n', Qt::SkipEmptyParts); QStringList lines = output.split('\n', QString::SkipEmptyParts);
// 创建临时文件 // 创建临时文件
QTemporaryFile tempFile; QTemporaryFile tempFile;
@ -131,7 +131,7 @@ QStringList aptssUpdater::getDesktopAppNames()
// 获取包文件列表 // 获取包文件列表
dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); dpkgProcess.start("dpkg", QStringList() << "-L" << packageName);
dpkgProcess.waitForFinished(); dpkgProcess.waitForFinished();
QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', QString::SkipEmptyParts);
// 先检查常规应用目录 // 先检查常规应用目录
QStringList regularDesktopFiles = files.filter("/usr/share/applications/"); QStringList regularDesktopFiles = files.filter("/usr/share/applications/");
@ -237,7 +237,7 @@ QStringList aptssUpdater::getPackageIcons()
// 获取包文件列表 // 获取包文件列表
dpkgProcess.start("dpkg", QStringList() << "-L" << packageName); dpkgProcess.start("dpkg", QStringList() << "-L" << packageName);
dpkgProcess.waitForFinished(); dpkgProcess.waitForFinished();
QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', Qt::SkipEmptyParts); QStringList files = QString(dpkgProcess.readAllStandardOutput()).split('\n', QString::SkipEmptyParts);
// 查找.desktop文件 // 查找.desktop文件
QStringList desktopFiles = files.filter(QRegularExpression("/(usr/share|opt/apps)/.*\\.desktop$")); QStringList desktopFiles = files.filter(QRegularExpression("/(usr/share|opt/apps)/.*\\.desktop$"));

View File

@ -20,6 +20,13 @@ shopt -s nullglob
# third argument are piped to stderr. # third argument are piped to stderr.
THREADS=$(nproc 2>/dev/null || echo 4) THREADS=$(nproc 2>/dev/null || echo 4)
# Set color variables.
cGreen='\e[0;32m'
cRed='\e[0;31m'
cBlue='\e[0;34m'
endColor='\e[0m'
msg(){ msg(){
msg_options=() msg_options=()
case "$2" in case "$2" in
@ -36,6 +43,51 @@ msg(){
echo -e "${msg_options[@]}" "${aptfast_prefix}${beginColor}$1${endColor}" >&2 echo -e "${msg_options[@]}" "${aptfast_prefix}${beginColor}$1${endColor}" >&2
fi fi
} }
msg_already_running()
{
msg "Other aptss is running. Waited $timer senconds..." "normal"
msg "有其他的aptss正在运行。已经等待了$timer秒" "normal"
}
# Check if a lock file exists.
#if [ -f "$LCK_FILE.lock" ]; then
# msg_already_running
# exit 1
#fi
LCK_FD=99
# create the lock file and lock it, die on failure
_create_lock()
{
eval "exec $LCK_FD>\"$LCK_FILE.lock\""
# 设置 trap 来清理资源
trap "cleanup_aptfast" EXIT
trap "cleanup_aptfast; exit 1" INT TERM
timer=0
max_wait=180 # 最大等待时间为180秒3分钟
until $(flock -xn $LCK_FD); do
msg_already_running
sleep 1
let timer+=1
if [ $timer -ge $max_wait ]; then
echo "timeout"
exit 1
fi
done
unset timer
}
# unlock and remove the lock file
_remove_lock()
{
flock -u "$LCK_FD" 2>/dev/null
rm -f "$LCK_FILE.lock"
}
# Search for known options and decide if root privileges are needed. # Search for known options and decide if root privileges are needed.
root=$# root=$#
@ -44,6 +96,7 @@ for argument in "$@"; do
case "$argument" in case "$argument" in
upgrade | full-upgrade | install | dist-upgrade | build-dep) upgrade | full-upgrade | install | dist-upgrade | build-dep)
option="install" option="install"
_create_lock
;; ;;
clean | autoclean) clean | autoclean)
option="clean" option="clean"
@ -122,7 +175,7 @@ LCK_FILE="/tmp/apt-fast-in-container.lock"
else else
LCK_FILE="/tmp/apt-fast.lock" LCK_FILE="/tmp/apt-fast.lock"
fi fi
LCK_FD=99
# Set default package manager, APT cache, temporary download dir, # Set default package manager, APT cache, temporary download dir,
# temporary download list file, and maximal parallel downloads # temporary download list file, and maximal parallel downloads
@ -145,11 +198,9 @@ if [ -f "$NETRC" ]; then
fi fi
APTAUTHFILES+=("$NETRCDIR"*) APTAUTHFILES+=("$NETRCDIR"*)
if [ "$IS_ACE_ENV" != "" ];then LISTTEMP=$(mktemp -d)
DLLIST="/tmp/apt-fast-in-container.list" DLLIST="${LISTTEMP}/apt-fast.list"
else
DLLIST="/tmp/apt-fast.list"
fi
@ -164,11 +215,7 @@ MIRRORS=()
aptfast_prefix= aptfast_prefix=
# aptfast_prefix="$(date '+%b %_d %T.%N') apt-fast: " # aptfast_prefix="$(date '+%b %_d %T.%N') apt-fast: "
# Set color variables.
cGreen='\e[0;32m'
cRed='\e[0;31m'
cBlue='\e[0;34m'
endColor='\e[0m'
# Set timout value for apt-fast download confirmation dialog. # Set timout value for apt-fast download confirmation dialog.
# Value is in seconds. # Value is in seconds.
@ -240,51 +287,7 @@ if [ ! -t 1 ]; then
fi fi
msg_already_running()
{
msg "Other aptss is running. Waited $timer senconds..." "normal"
msg "有其他的aptss正在运行。已经等待了$timer秒" "normal"
}
# Check if a lock file exists.
#if [ -f "$LCK_FILE.lock" ]; then
# msg_already_running
# exit 1
#fi
# create the lock file and lock it, die on failure
_create_lock()
{
eval "exec $LCK_FD>\"$LCK_FILE.lock\""
# 设置 trap 来清理资源
trap "cleanup_aptfast" EXIT
trap "cleanup_aptfast; exit 1" INT TERM
timer=0
max_wait=180 # 最大等待时间为180秒3分钟
until $(flock -xn $LCK_FD); do
msg_already_running
sleep 1
let timer+=1
if [ $timer -ge $max_wait ]; then
echo "timeout"
exit 1
fi
done
unset timer
}
# unlock and remove the lock file
_remove_lock()
{
flock -u "$LCK_FD" 2>/dev/null
rm -f "$LCK_FILE.lock"
}
# Move download file away so missing permissions won't stop usage. # Move download file away so missing permissions won't stop usage.
CLEANUP_STATE=0 CLEANUP_STATE=0
@ -294,7 +297,7 @@ cleanup_dllist()
then then
if ! mv -- "$DLLIST{,.old}" 2>/dev/null if ! mv -- "$DLLIST{,.old}" 2>/dev/null
then then
if ! rm -f -- "$DLLIST" 2>/dev/null if ! rm -fr -- "${LISTTEMP}" 2>/dev/null
then then
msg "Could not clean up download list file." "warning" msg "Could not clean up download list file." "warning"
msg "无法清除下载列表文件." "warning" msg "无法清除下载列表文件." "warning"
@ -608,7 +611,7 @@ display_downloadfile(){
# Create and insert a PID number to lockfile. # Create and insert a PID number to lockfile.
_create_lock
# Make sure aria2c (in general first parameter from _DOWNLOADER) is available. # Make sure aria2c (in general first parameter from _DOWNLOADER) is available.
CMD="$(echo "$_DOWNLOADER" | sed 's/^\s*\([^ ]\+\).*$/\1/')" CMD="$(echo "$_DOWNLOADER" | sed 's/^\s*\([^ ]\+\).*$/\1/')"