update tool/apt-fast/ss-apt-fast.

Signed-off-by: shenmo <jifengshenmo@outlook.com>
This commit is contained in:
2026-05-09 15:04:46 +00:00
committed by Gitee
parent c50655c106
commit 8c8b53fc29
+8 -22
View File
@@ -83,6 +83,9 @@ cleanup_aptfast()
if [ -n "$LISTTEMP" ] && [ -d "$LISTTEMP" ]; then if [ -n "$LISTTEMP" ] && [ -d "$LISTTEMP" ]; then
rm -rf "$LISTTEMP" rm -rf "$LISTTEMP"
fi fi
if [ -n "$tmpdir" ] && [ -d "$tmpdir" ]; then
rm -rf "$tmpdir"
fi
} }
exit_cleanup_state() exit_cleanup_state()
{ {
@@ -120,11 +123,8 @@ _create_lock()
# unlock and remove the lock file # unlock and remove the lock file
_remove_lock() _remove_lock()
{ {
# Only unlock if lock file exists (was created by _create_lock) flock -u "$LCK_FD" 2>/dev/null
if [ -f "$LCK_FILE.lock" ]; then rm -f "$LCK_FILE.lock"
flock -u "$LCK_FD" 2>/dev/null
rm -f "$LCK_FILE.lock"
fi
} }
# Search for known options and decide if root privileges are needed. # Search for known options and decide if root privileges are needed.
@@ -134,7 +134,6 @@ 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"
@@ -313,6 +312,9 @@ https_proxy=
[ "$TMP_http_proxy" = "$TMP_RANDOM" ] || http_proxy="$TMP_http_proxy" [ "$TMP_http_proxy" = "$TMP_RANDOM" ] || http_proxy="$TMP_http_proxy"
[ "$TMP_https_proxy" = "$TMP_RANDOM" ] || https_proxy="$TMP_https_proxy" [ "$TMP_https_proxy" = "$TMP_RANDOM" ] || https_proxy="$TMP_https_proxy"
if [ "$option" == "install" ]; then
_create_lock
fi
# Disable colors if not executed in terminal. # Disable colors if not executed in terminal.
if [ ! -t 1 ]; then if [ ! -t 1 ]; then
@@ -456,21 +458,11 @@ get_uris(){
exit "$CLEANUP_STATE" exit "$CLEANUP_STATE"
fi fi
prepare_auth prepare_auth
local tmpdir
tmpdir=$(mktemp -d) || { tmpdir=$(mktemp -d) || {
msg "Failed to create tmp dir" "warning" msg "Failed to create tmp dir" "warning"
msg "无法创建临时目录" "warning" msg "无法创建临时目录" "warning"
exit 1 exit 1
} }
cleanup_tmpdir() {
if [ -n "$tmpdir" ] && [ -d "$tmpdir" ]; then
rm -rf "$tmpdir"
fi
}
trap cleanup_tmpdir EXIT
## --print-uris format is: ## --print-uris format is:
# 'fileurl' filename filesize checksum_hint:filechecksum # 'fileurl' filename filesize checksum_hint:filechecksum
@@ -824,9 +816,6 @@ elif [ "$option" == "download" ]; then
"${_APTMGR}" "$@" "${_APTMGR}" "$@"
fi fi
# Clean up temporary directory for download command
cleanup_aptfast
elif [ "$option" == "source" ]; then elif [ "$option" == "source" ]; then
msg msg
msg "Working... this may take a while." "normal" msg "Working... this may take a while." "normal"
@@ -853,9 +842,6 @@ elif [ "$option" == "source" ]; then
# dpkg-source -x "$(basename "$srcfile")" # dpkg-source -x "$(basename "$srcfile")"
#done < "$DLLIST" #done < "$DLLIST"
# Clean up temporary directory for source command
cleanup_aptfast
# Execute package manager directly if unknown options are passed. # Execute package manager directly if unknown options are passed.
else else
"${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@" "${_APTMGR}" "${APT_SCRIPT_WARNING[@]}" "$@"