mirror of
https://github.com/tw93/Mole.git
synced 2026-02-15 06:25:09 +00:00
fix: clean update packages with SIP enabled
This commit is contained in:
@@ -19,24 +19,22 @@ clean_deep_system() {
|
|||||||
safe_sudo_find_delete "/private/var/log" "*.gz" "$MOLE_LOG_AGE_DAYS" "f" || true
|
safe_sudo_find_delete "/private/var/log" "*.gz" "$MOLE_LOG_AGE_DAYS" "f" || true
|
||||||
log_success "System logs"
|
log_success "System logs"
|
||||||
if [[ -d "/Library/Updates" && ! -L "/Library/Updates" ]]; then
|
if [[ -d "/Library/Updates" && ! -L "/Library/Updates" ]]; then
|
||||||
if ! is_sip_enabled; then
|
local updates_cleaned=0
|
||||||
local updates_cleaned=0
|
while IFS= read -r -d '' item; do
|
||||||
while IFS= read -r -d '' item; do
|
if [[ -z "$item" ]] || [[ ! "$item" =~ ^/Library/Updates/[^/]+$ ]]; then
|
||||||
if [[ -z "$item" ]] || [[ ! "$item" =~ ^/Library/Updates/[^/]+$ ]]; then
|
debug_log "Skipping malformed path: $item"
|
||||||
debug_log "Skipping malformed path: $item"
|
continue
|
||||||
continue
|
fi
|
||||||
fi
|
local item_flags
|
||||||
local item_flags
|
item_flags=$($STAT_BSD -f%Sf "$item" 2> /dev/null || echo "")
|
||||||
item_flags=$($STAT_BSD -f%Sf "$item" 2> /dev/null || echo "")
|
if [[ "$item_flags" == *"restricted"* ]]; then
|
||||||
if [[ "$item_flags" == *"restricted"* ]]; then
|
continue
|
||||||
continue
|
fi
|
||||||
fi
|
if safe_sudo_remove "$item"; then
|
||||||
if safe_sudo_remove "$item"; then
|
((updates_cleaned++))
|
||||||
((updates_cleaned++))
|
fi
|
||||||
fi
|
done < <(find /Library/Updates -mindepth 1 -maxdepth 1 -print0 2> /dev/null || true)
|
||||||
done < <(find /Library/Updates -mindepth 1 -maxdepth 1 -print0 2> /dev/null || true)
|
[[ $updates_cleaned -gt 0 ]] && log_success "System library updates"
|
||||||
[[ $updates_cleaned -gt 0 ]] && log_success "System library updates"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [[ -d "/macOS Install Data" ]]; then
|
if [[ -d "/macOS Install Data" ]]; then
|
||||||
local mtime=$(get_file_mtime "/macOS Install Data")
|
local mtime=$(get_file_mtime "/macOS Install Data")
|
||||||
|
|||||||
Reference in New Issue
Block a user