Skip to content

Commit f7e80d4

Browse files
committed
Check if curl package is installed.
1 parent 1a4a82d commit f7e80d4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/circleci-cli/install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,23 @@ if [[ "$VERSION" = "latest" ]]; then {
1010
unset VERSION
1111
} fi
1212

13+
apt_get_update()
14+
{
15+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
16+
echo "Running apt-get update..."
17+
apt-get update -y
18+
fi
19+
}
20+
21+
# Checks if packages are installed and installs them if not
22+
check_packages() {
23+
if ! dpkg -s "$@" > /dev/null 2>&1; then
24+
apt_get_update
25+
apt-get -y install --no-install-recommends "$@"
26+
fi
27+
}
28+
29+
export DEBIAN_FRONTEND=noninteractive
30+
check_packages curl
31+
1332
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash

src/exercism-cli/install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ if [[ -z "$VERSION" ]] || [[ "$VERSION" = "latest" ]]; then {
2323
VERSION=$(curl -sLI -o /dev/null -w '%{url_effective}' "$LATEST_URL" | cut -d "v" -f 2)
2424
} fi
2525

26+
apt_get_update()
27+
{
28+
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
29+
echo "Running apt-get update..."
30+
apt-get update -y
31+
fi
32+
}
33+
34+
# Checks if packages are installed and installs them if not
35+
check_packages() {
36+
if ! dpkg -s "$@" > /dev/null 2>&1; then
37+
apt_get_update
38+
apt-get -y install --no-install-recommends "$@"
39+
fi
40+
}
41+
42+
export DEBIAN_FRONTEND=noninteractive
43+
check_packages curl
44+
2645
echo "Installing exercism-cli: v${VERSION}"
2746

2847
RELEASE_URL="${GITHUB_BASE_URL}/releases/download/v${VERSION}/exercism-${VERSION}-${OS}-${ARCH}.tar.gz"

0 commit comments

Comments
 (0)