Skip to content

Commit c593fa7

Browse files
authored
feat: add advanced dpkg/apt lock fixer script for Termux (#6)
* Add French translation and fix STATE_FILE in explain.sh * feat: add advanced dpkg/apt lock fixer script for Termux Description On some Termux environments (especially non-rooted recent Android versions like Android 13/14 on Xiaomi/Redmi devices), the standard tdoc fix routine might fail to completely release or detect stale dpkg or apt frontend locks. This script provides a safe, automated, and strict fallback method: It checks if an actual apt or dpkg process is running to prevent breaking active installations. If no active PID is found, it forcefully removes the standard orphan lock files (lock, lock-frontend, etc.). It triggers a final verification via tdoc doctor. Environment tested: Termux 0.118.3 Device: Xiaomi Redmi Note 13 Pro+ 5G (Android 13 / SDK 33, non-rooted) Feel free to integrate this logic into the main core or keep it as a standalone helper script (tdocfix.sh). * Fix dependabot labels
1 parent 6449729 commit c593fa7

2 files changed

Lines changed: 43 additions & 3 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ updates:
77
day: "monday"
88
time: "09:00"
99
timezone: "Asia/Jakarta"
10-
labels:
11-
- "dependencies"
12-
- "github-actions"
1310
commit-message:
1411
prefix: "ci"
1512
reviewers:

tdocfix.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/data/data/com.termux/files/usr/bin/bash
2+
# -- Authors: Jean-Luc NAIL & Gemini
3+
# -- Version: 1.01
4+
# -- Description: Automatic and strict cleanup of orphan dpkg/apt locks
5+
6+
# 1. Security check: is there any active process?
7+
ACTIVE_PROCS=$(ps aux | grep -E "apt|dpkg" | grep -v -E "grep|docfix.sh" | wc -l)
8+
9+
if [ "$ACTIVE_PROCS" -gt 0 ]; then
10+
echo "[-] Error: An apt or dpkg process is currently running."
11+
echo " Please wait or terminate the task cleanly."
12+
exit 1
13+
fi
14+
15+
echo "[+] No active process detected. Cleaning up residual locks..."
16+
17+
# 2. List of potential lock files
18+
LOCKS=(
19+
"$PREFIX/var/lib/dpkg/lock"
20+
"$PREFIX/var/lib/dpkg/lock-frontend"
21+
"$PREFIX/var/cache/apt/archives/lock"
22+
)
23+
24+
DELETED_COUNT=0
25+
26+
for LOCK_FILE in "${LOCKS[@]}"; do
27+
if [ -f "$LOCK_FILE" ]; then
28+
rm "$LOCK_FILE" && echo " [✔] Removed: $(basename "$LOCK_FILE")"
29+
((DELETED_COUNT++))
30+
fi
31+
done
32+
33+
if [ "$DELETED_COUNT" -eq 0 ]; then
34+
echo "[~] No orphan lock files found. The system is already clean."
35+
else
36+
echo "[+] $DELETED_COUNT lock(s) cleaned up."
37+
# Give the system a brief moment to release descriptors
38+
sleep 0.5
39+
fi
40+
41+
# 3. Final validation with tdoc
42+
echo "[+] Validating global status:"
43+
tdoc doctor --json | grep -E "dpkglock|broken"

0 commit comments

Comments
 (0)