fix: move dep checks into scripts/check_deps.sh for robustness
Replaces fragile one-liner Makefile chain with a proper shell script. Tries: sudo -n apt → python3 -m pip --user → get-pip.py bootstrap. Prints a clear manual-install message if all automated paths fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -39,19 +39,7 @@ help:
|
|||||||
|
|
||||||
# Setup commands
|
# Setup commands
|
||||||
check-deps:
|
check-deps:
|
||||||
@echo "Checking system dependencies..."
|
@sh scripts/check_deps.sh
|
||||||
@which python3 >/dev/null 2>&1 || \
|
|
||||||
{ echo "Installing python3..." && sudo -n apt-get install -y python3 2>/dev/null || \
|
|
||||||
{ echo "ERROR: python3 not found. Run: sudo apt-get install -y python3" ; exit 1 ; } ; }
|
|
||||||
@python3 -c "import cryptography" 2>/dev/null || { \
|
|
||||||
echo "Installing python3-cryptography..." ; \
|
|
||||||
sudo -n apt-get install -y python3-cryptography 2>/dev/null || \
|
|
||||||
python3 -m pip install --user cryptography 2>/dev/null || \
|
|
||||||
{ python3 -m ensurepip --upgrade 2>/dev/null && python3 -m pip install --user cryptography 2>/dev/null ; } || \
|
|
||||||
{ echo "ERROR: Cannot install python3-cryptography. Run: sudo apt-get install python3-cryptography" ; exit 1 ; } ; }
|
|
||||||
@python3 -c "import cryptography" >/dev/null 2>&1 || \
|
|
||||||
{ echo "ERROR: python3-cryptography still not found. Run: sudo apt-get install python3-cryptography" ; exit 1 ; }
|
|
||||||
@echo "Dependencies OK."
|
|
||||||
|
|
||||||
setup: check-deps
|
setup: check-deps
|
||||||
@echo "Setting up Personal Internet Cell..."
|
@echo "Setting up Personal Internet Cell..."
|
||||||
|
|||||||
Executable
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Install Python dependencies needed by setup_cell.py
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Checking system dependencies..."
|
||||||
|
|
||||||
|
# Ensure python3 is available
|
||||||
|
if ! command -v python3 >/dev/null 2>&1; then
|
||||||
|
echo "Installing python3..."
|
||||||
|
sudo apt-get install -y python3 || { echo "ERROR: python3 not found and could not install it."; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if cryptography is already importable
|
||||||
|
if python3 -c "import cryptography" 2>/dev/null; then
|
||||||
|
echo "Dependencies OK."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing python3-cryptography..."
|
||||||
|
|
||||||
|
# 1. Try apt (works if sudo is passwordless or interactive TTY is available)
|
||||||
|
if sudo -n apt-get install -y python3-cryptography 2>/dev/null; then
|
||||||
|
echo "Dependencies OK."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Try pip (module form, covers both pip3 and python3 -m pip)
|
||||||
|
if python3 -m pip install --user cryptography 2>/dev/null; then
|
||||||
|
echo "Dependencies OK."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. Bootstrap pip via get-pip.py, then install
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
curl -sSL https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py 2>/dev/null \
|
||||||
|
&& python3 /tmp/get-pip.py --user -q 2>/dev/null \
|
||||||
|
&& python3 -m pip install --user cryptography 2>/dev/null \
|
||||||
|
&& { echo "Dependencies OK."; exit 0; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. No automated path worked — ask the user to install manually
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: Could not install python3-cryptography automatically."
|
||||||
|
echo "Please run the following command and then retry:"
|
||||||
|
echo ""
|
||||||
|
echo " sudo apt-get install -y python3-cryptography"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
Reference in New Issue
Block a user