-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean-debian.sh
More file actions
executable file
·131 lines (110 loc) · 4.17 KB
/
Copy pathclean-debian.sh
File metadata and controls
executable file
·131 lines (110 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# Comprehensive clean script for Debian packaging artifacts
set -e
echo "=== Debian Package Clean Script ==="
echo ""
# Function to safely remove files/directories with sudo fallback
safe_remove() {
local target="$1"
local description="$2"
if [ -e "$target" ] || [ -d "$target" ]; then
echo "Removing $description..."
if rm -rf "$target" 2>/dev/null; then
echo " Removed: $target"
elif sudo rm -rf "$target" 2>/dev/null; then
echo " Removed (with sudo): $target"
else
echo " Failed to remove: $target"
fi
else
echo " Not found: $target"
fi
}
echo "Starting comprehensive clean..."
echo ""
# Clean debian build artifacts
echo "Cleaning debian build artifacts:"
safe_remove "debian/pythonico/" "debian package staging directory"
safe_remove "debian/.debhelper/" "debhelper cache directory"
safe_remove "debian/debhelper-build-stamp" "debhelper build stamp"
safe_remove "debian/files" "debian files list"
# Clean debian log and temporary files
echo ""
echo "Cleaning debian temporary files:"
find debian/ -name "*.substvars" -type f 2>/dev/null | while read -r file; do
safe_remove "$file" "substvars file"
done
find debian/ -name "*.debhelper.log" -type f 2>/dev/null | while read -r file; do
safe_remove "$file" "debhelper log file"
done
find debian/ -name "*.debhelper" -type d 2>/dev/null | while read -r dir; do
safe_remove "$dir" "debhelper directory"
done
safe_remove "debian/tmp" "debian temporary directory"
# Clean parent directory package artifacts
echo ""
echo "Cleaning package files from parent directory:"
safe_remove "../pythonico_*.deb" "debian package files"
safe_remove "../pythonico_*.changes" "changes files"
safe_remove "../pythonico_*.dsc" "source description files"
safe_remove "../pythonico_*.tar.*" "source tar files"
safe_remove "../pythonico_*.build*" "build files"
safe_remove "../pythonico_*.buildinfo" "build info files"
# Use find for pattern-based cleanup in parent directory
echo ""
echo "Searching for remaining package artifacts:"
cd ..
for pattern in "pythonico_*"; do
find . -maxdepth 1 -name "$pattern" -type f 2>/dev/null | while read -r file; do
safe_remove "$file" "package artifact"
done
done
cd - >/dev/null
# Clean Python artifacts
echo ""
echo "Cleaning Python build artifacts:"
safe_remove "build/" "Python build directory"
safe_remove "build-venv/" "Python venv build directory"
safe_remove "dist/" "Python dist directory"
safe_remove ".pybuild/" "pybuild directory"
# Clean egg-info directories
find . -name "*.egg-info" -type d 2>/dev/null | while read -r dir; do
safe_remove "$dir" "Python egg-info directory"
done
# Clean Python cache files
echo ""
echo "Cleaning Python cache files:"
echo "Removing .pyc files..."
find . -name "*.pyc" -type f -delete 2>/dev/null && echo " Removed .pyc files" || echo " No .pyc files found"
echo "Removing __pycache__ directories..."
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null && echo " Removed __pycache__ directories" || echo " No __pycache__ directories found"
# Clean editor and system temporary files
echo ""
echo "Cleaning editor and system temporary files:"
safe_remove ".*.swp" "vim swap files"
safe_remove ".*.swo" "vim backup files"
safe_remove "*~" "editor backup files"
safe_remove ".DS_Store" "macOS system files"
safe_remove "Thumbs.db" "Windows thumbnail cache"
# Clean any residual locks or temporary files
echo ""
echo "Cleaning locks and temporary files:"
find . -name "*.lock" -type f 2>/dev/null | while read -r file; do
safe_remove "$file" "lock file"
done
find . -name ".tmp*" -type f 2>/dev/null | while read -r file; do
safe_remove "$file" "temporary file"
done
echo ""
echo "Clean complete!"
echo ""
echo "Summary of cleaned items:"
echo " - Debian build artifacts and staging directories"
echo " - Package files (.deb, .changes, .dsc, .tar.*)"
echo " - Python build artifacts (build/, dist/, *.egg-info/)"
echo " - Python cache files (.pyc, __pycache__/)"
echo " - Editor temporary files"
echo " - System temporary files"
echo ""
echo "The project is now clean and ready for a fresh build."
echo "Run './build-deb.sh' to build the Debian package."