Skip to content

Commit

Permalink
fall back to ubuntu 22.04 LTS package when kcov is not available on l…
Browse files Browse the repository at this point in the history
…atest
  • Loading branch information
susitsm authored and Matyas Susits committed Jan 20, 2025
1 parent d3745e9 commit d4b4800
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ jobs:

- name: Install kcov
shell: bash
run: |
sudo apt-get update
sudo apt-get install kcov
run: ./build/ci-install-pkg-fallback-to-ubuntu-2204-LTS.sh kcov

- name: Build and test
shell: bash
Expand Down
43 changes: 43 additions & 0 deletions build/ci-install-pkg-fallback-to-ubuntu-2204-LTS.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive

# Check if the package name is provided
if [ -z "$1" ]; then
echo "Usage: $0 <package-name>"
exit 1
fi

PACKAGE=$1
apt-get update

# Check if the package is available on the current system
if apt-cache show "$PACKAGE" > /dev/null 2>&1; then
echo "Package '$PACKAGE' is available in the current repository. Installing..."
apt-get update
apt-get install -y "$PACKAGE"
exit 0
else
echo "Package '$PACKAGE' is not available in the current repository."
echo "Adding the Ubuntu 22.04 (Jammy) repository..."
fi

# Add the Ubuntu 22.04 (Jammy) repository
echo "deb http://archive.ubuntu.com/ubuntu jammy main universe" | tee /etc/apt/sources.list.d/ubuntu-jammy.list

# Update the package list
apt-get update

# Try to install the package
if apt-get install -y "$PACKAGE"; then
echo "Package '$PACKAGE' installed successfully from the Ubuntu 22.04 repository."
else
echo "Failed to install '$PACKAGE'. It might have unresolved dependencies."
fi

# Clean up: Remove the Ubuntu 22.04 repository
echo "Cleaning up the Ubuntu 22.04 repository..."
rm /etc/apt/sources.list.d/ubuntu-jammy.list
apt-get update

exit 0

0 comments on commit d4b4800

Please sign in to comment.