Skip to content

Commit c9859df

Browse files
committed
Fix dependency check and enhance alternative suggestions in build scripts
1 parent 932af8c commit c9859df

File tree

3 files changed

+83
-12
lines changed

3 files changed

+83
-12
lines changed

EXTERNAL_BUILD_SCRIPT.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ This ensures you always get the latest build logic without waiting for Docker im
7777

7878
To prevent infinite recursion, the system works as follows:
7979

80-
1. **Local script** checks if `--no-fetch` is present
81-
2. **If not present**: Fetches latest version and executes it with `--no-fetch`
82-
3. **Fetched script**: Sees `--no-fetch` and skips fetching, runs normally
80+
1. **Local script** stores `--no-fetch` flag in `NO_FETCH` variable during argument parsing
81+
2. **If `NO_FETCH` is false**: Fetches latest version and executes it with `--no-fetch`
82+
3. **Fetched script**: Processes `--no-fetch` and sets `NO_FETCH=true`, skips fetching
8383
4. **Result**: Only one fetch per execution, no infinite loops
8484

85+
**Fixed**: Previously there was a bug where `--no-fetch` was consumed during argument parsing, causing infinite recursion. This has been resolved by properly storing the flag before processing arguments.
86+
8587
```
8688
Execution Flow:
8789
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐

assets/build

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,28 @@ build_package() {
223223
# Check for missing dependencies first
224224
if [[ -f "/usr/bin/check-deps.sh" ]]; then
225225
echo "Checking build dependencies..."
226+
# Ensure the script has execute permissions
227+
chmod +x /usr/bin/check-deps.sh || true
226228
/usr/bin/check-deps.sh || {
227229
echo "Dependency check failed. Attempting to install anyway..."
228230
}
229231
fi
230232

231233
# Try to install build dependencies using mk-build-deps
234+
echo "Installing build dependencies using mk-build-deps..."
232235
if ! mk-build-deps -t "apt-get --no-install-recommends -y" -ir; then
233236
echo "Failed to install build dependencies using mk-build-deps."
234237
echo "This usually means there are missing packages in the distribution repositories."
235-
echo "Please check the debian/control file and ensure all Build-Depends are available."
236238
echo ""
237-
echo "You can run the dependency checker manually:"
238-
echo " /usr/bin/check-deps.sh"
239+
echo "Checking which packages are missing..."
240+
if [[ -f "/usr/bin/check-deps.sh" ]]; then
241+
chmod +x /usr/bin/check-deps.sh || true
242+
/usr/bin/check-deps.sh
243+
fi
244+
echo ""
245+
echo "You can also check manually:"
246+
echo " apt-cache policy <package-name>"
247+
echo " apt-cache search <package-name>"
239248
return 1
240249
fi
241250

assets/check-deps.sh

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,47 @@ suggest_alternatives() {
2525
echo " 💡 Alternative: python3-appdirs might be available as python3-appdirs2 or similar"
2626
echo " 💡 Or you can add it to debian/control as a conditional dependency"
2727
;;
28+
python3-appdirs2)
29+
echo " 💡 Alternative: python3-appdirs2 might be available as python3-appdirs or similar"
30+
echo " 💡 Or you can add it to debian/control as a conditional dependency"
31+
;;
2832
python3-requests)
2933
echo " 💡 Alternative: python3-urllib3 or python3-httplib2"
3034
;;
35+
python3-cachecontrol)
36+
echo " 💡 Alternative: python3-cachecontrol might not be available in this distribution"
37+
echo " 💡 Consider using python3-requests-cache or similar"
38+
;;
39+
python3-bs4)
40+
echo " 💡 Alternative: python3-beautifulsoup4"
41+
;;
42+
python3-beautifulsoup4)
43+
echo " 💡 Alternative: python3-bs4"
44+
;;
45+
python3-html5lib)
46+
echo " 💡 Alternative: python3-html5lib might not be available in this distribution"
47+
echo " 💡 Consider using python3-lxml or similar"
48+
;;
49+
python3-lxml)
50+
echo " 💡 Alternative: python3-html5lib"
51+
;;
52+
python3-cachecontrol)
53+
echo " 💡 Alternative: python3-cachecontrol might not be available in this distribution"
54+
echo " 💡 Consider using python3-requests-cache or similar"
55+
;;
56+
python3-requests-cache)
57+
echo " 💡 Alternative: python3-cachecontrol"
58+
;;
59+
pandoc)
60+
echo " 💡 Alternative: pandoc might not be available in this distribution"
61+
echo " 💡 Consider making it optional or using python3-docutils"
62+
;;
63+
python3-docutils)
64+
echo " 💡 Alternative: pandoc"
65+
;;
3166
*)
3267
echo " 💡 Check if this package has a different name in this distribution"
68+
echo " 💡 Try: apt-cache search $package"
3369
;;
3470
esac
3571
}
@@ -46,12 +82,36 @@ if [[ -f "debian/control" ]]; then
4682
while IFS= read -r dep; do
4783
# Skip empty lines and version constraints for now
4884
if [[ -n "$dep" && ! "$dep" =~ ^[[:space:]]*$ ]]; then
49-
# Extract package name (remove version constraints)
50-
package=$(echo "$dep" | sed 's/[[:space:]]*([^)]*)[[:space:]]*$//')
51-
52-
if ! check_package "$package"; then
53-
missing_packages+=("$package")
54-
suggest_alternatives "$package"
85+
# Handle conditional dependencies (e.g., "package1 | package2")
86+
if [[ "$dep" == *"|"* ]]; then
87+
# Split by | and check each alternative
88+
alternatives=$(echo "$dep" | tr '|' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
89+
found_alternative=false
90+
91+
while IFS= read -r alt; do
92+
# Extract package name (remove version constraints)
93+
package=$(echo "$alt" | sed 's/[[:space:]]*([^)]*)[[:space:]]*$//')
94+
95+
if check_package "$package"; then
96+
echo "✅ Found alternative: $package (for: $dep)"
97+
found_alternative=true
98+
break
99+
fi
100+
done <<< "$alternatives"
101+
102+
if [[ "$found_alternative" == "false" ]]; then
103+
echo "❌ No alternatives found for: $dep"
104+
missing_packages+=("$dep")
105+
suggest_alternatives "$(echo "$dep" | cut -d'|' -f1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
106+
fi
107+
else
108+
# Extract package name (remove version constraints)
109+
package=$(echo "$dep" | sed 's/[[:space:]]*([^)]*)[[:space:]]*$//')
110+
111+
if ! check_package "$package"; then
112+
missing_packages+=("$package")
113+
suggest_alternatives "$package"
114+
fi
55115
fi
56116
fi
57117
done <<< "$build_deps"

0 commit comments

Comments
 (0)