Skip to content

Commit 72646de

Browse files
committed
Refactor BPG tools installation in CI workflows to create a local bin directory, improve dependency checks, and enhance error handling during compilation.
1 parent fcc6d28 commit 72646de

File tree

2 files changed

+72
-30
lines changed

2 files changed

+72
-30
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,57 @@ jobs:
4848
run: |
4949
echo "🔧 Installing BPG (Better Portable Graphics) tools..."
5050
51+
# Create local bin directory for BPG tools
52+
BPG_BIN_DIR="$HOME/.local/bin"
53+
mkdir -p "$BPG_BIN_DIR"
54+
55+
# Add to PATH for this session and future steps
56+
echo "$BPG_BIN_DIR" >> $GITHUB_PATH
57+
export PATH="$BPG_BIN_DIR:$PATH"
58+
5159
# Check if BPG tools are already installed
5260
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
5361
echo "✅ BPG tools already installed"
5462
bpgenc 2>&1 | head -n 3 || true
5563
else
5664
echo "📦 Installing BPG tools from source..."
5765
58-
# Install required dependencies
59-
sudo apt-get update
60-
sudo apt-get install -y build-essential cmake libjpeg-dev libpng-dev libtiff-dev
66+
# Check if build tools are available, skip dependency installation if not root
67+
if ! command -v gcc &> /dev/null || ! command -v make &> /dev/null; then
68+
echo "⚠️ Build tools not available, attempting to continue without installing dependencies..."
69+
echo "🔍 Available compilers:"
70+
which gcc || echo "gcc not found"
71+
which clang || echo "clang not found"
72+
which make || echo "make not found"
73+
fi
6174
6275
# Download and compile BPG
6376
cd /tmp
6477
wget -q https://bellard.org/bpg/bpg-0.9.8.tar.gz
6578
tar xzf bpg-0.9.8.tar.gz
6679
cd bpg-0.9.8
6780
68-
# Compile BPG tools
69-
make
70-
71-
# Install to system
72-
sudo cp bpgenc bpgdec /usr/local/bin/
73-
sudo chmod +x /usr/local/bin/bpgenc /usr/local/bin/bpgdec
74-
75-
# Verify installation
76-
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
77-
echo "✅ BPG tools installed successfully"
78-
bpgenc 2>&1 | head -n 3 || true
81+
# Try to compile BPG tools
82+
echo "🔨 Compiling BPG tools..."
83+
if make; then
84+
echo "✅ BPG compilation successful"
85+
86+
# Install to user bin directory
87+
cp bpgenc bpgdec "$BPG_BIN_DIR/"
88+
chmod +x "$BPG_BIN_DIR/bpgenc" "$BPG_BIN_DIR/bpgdec"
89+
90+
# Verify installation
91+
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
92+
echo "✅ BPG tools installed successfully to $BPG_BIN_DIR"
93+
bpgenc 2>&1 | head -n 3 || true
94+
else
95+
echo "❌ BPG tools installation failed - not found in PATH"
96+
exit 1
97+
fi
7998
else
80-
echo "❌ BPG tools installation failed"
99+
echo "❌ BPG compilation failed"
100+
echo "🔍 Checking for required dependencies..."
101+
pkg-config --exists libjpeg libpng libtiff-4 || echo "Some image libraries may be missing"
81102
exit 1
82103
fi
83104
fi

.github/workflows/tests.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,57 @@ jobs:
4646
run: |
4747
echo "🔧 Installing BPG (Better Portable Graphics) tools..."
4848
49+
# Create local bin directory for BPG tools
50+
BPG_BIN_DIR="$HOME/.local/bin"
51+
mkdir -p "$BPG_BIN_DIR"
52+
53+
# Add to PATH for this session and future steps
54+
echo "$BPG_BIN_DIR" >> $GITHUB_PATH
55+
export PATH="$BPG_BIN_DIR:$PATH"
56+
4957
# Check if BPG tools are already installed
5058
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
5159
echo "✅ BPG tools already installed"
5260
bpgenc 2>&1 | head -n 3 || true
5361
else
5462
echo "📦 Installing BPG tools from source..."
5563
56-
# Install required dependencies
57-
sudo apt-get update
58-
sudo apt-get install -y build-essential cmake libjpeg-dev libpng-dev libtiff-dev
64+
# Check if build tools are available, skip dependency installation if not root
65+
if ! command -v gcc &> /dev/null || ! command -v make &> /dev/null; then
66+
echo "⚠️ Build tools not available, attempting to continue without installing dependencies..."
67+
echo "🔍 Available compilers:"
68+
which gcc || echo "gcc not found"
69+
which clang || echo "clang not found"
70+
which make || echo "make not found"
71+
fi
5972
6073
# Download and compile BPG
6174
cd /tmp
6275
wget -q https://bellard.org/bpg/bpg-0.9.8.tar.gz
6376
tar xzf bpg-0.9.8.tar.gz
6477
cd bpg-0.9.8
6578
66-
# Compile BPG tools
67-
make
68-
69-
# Install to system
70-
sudo cp bpgenc bpgdec /usr/local/bin/
71-
sudo chmod +x /usr/local/bin/bpgenc /usr/local/bin/bpgdec
72-
73-
# Verify installation
74-
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
75-
echo "✅ BPG tools installed successfully"
76-
bpgenc 2>&1 | head -n 3 || true
79+
# Try to compile BPG tools
80+
echo "🔨 Compiling BPG tools..."
81+
if make; then
82+
echo "✅ BPG compilation successful"
83+
84+
# Install to user bin directory
85+
cp bpgenc bpgdec "$BPG_BIN_DIR/"
86+
chmod +x "$BPG_BIN_DIR/bpgenc" "$BPG_BIN_DIR/bpgdec"
87+
88+
# Verify installation
89+
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
90+
echo "✅ BPG tools installed successfully to $BPG_BIN_DIR"
91+
bpgenc 2>&1 | head -n 3 || true
92+
else
93+
echo "❌ BPG tools installation failed - not found in PATH"
94+
exit 1
95+
fi
7796
else
78-
echo "❌ BPG tools installation failed"
97+
echo "❌ BPG compilation failed"
98+
echo "🔍 Checking for required dependencies..."
99+
pkg-config --exists libjpeg libpng libtiff-4 || echo "Some image libraries may be missing"
79100
exit 1
80101
fi
81102
fi

0 commit comments

Comments
 (0)