Skip to content

Commit bd267e7

Browse files
author
Clement Cheung
committed
Fix typo and clean up stale packages
1 parent f5dca3e commit bd267e7

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

install.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,43 @@ if [ "$VERSION" == "latest" ]; then
66
fi
77
MAJOR_VERSION=${VERSION%%.*}
88

9+
# Function to run apt-get if needed
10+
apt_get_update_if_needed()
11+
{
12+
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
13+
echo "Running apt-get update..."
14+
apt-get update
15+
else
16+
echo "Skipping apt-get update."
17+
fi
18+
}
19+
920
# Checks if packages are installed and installs them if not
1021
check_packages() {
11-
if ! dpkg -s "$@" > /dev/null 2>&1; then
12-
apt_get_update
13-
apt-get -y install --no-install-recommends "$@"
14-
fi
22+
if ! dpkg -s "$@" > /dev/null 2>&1; then
23+
apt_get_update_if_needed
24+
apt-get -y install --no-install-recommends "$@"
25+
fi
1526
}
1627

1728
check_packages lsb-release wget software-properties-common gnupg
1829

30+
# Remove any previous LLVM that may be in the base image
31+
# LLVM packages packaged by Ubuntu may get picked over us and
32+
# cause problems later.
33+
if dpkg -s llvm > /dev/null 2>&1; then
34+
apt-get purge -y llvm && apt-get autoremove -y
35+
fi
36+
1937
cd /tmp
2038
wget https://apt.llvm.org/llvm.sh
2139
chmod +x llvm.sh
2240
./llvm.sh $VERSION all
2341
rm llvm.sh
2442

43+
# Remove downloads to keep Docker layer small
44+
apt-get clean -y && rm -rf /var/lib/apt/lists/
45+
2546
ln -sf /usr/bin/clang-${MAJOR_VERSION} /usr/bin/clang
2647
ln -sf /usr/bin/clang++-${MAJOR_VERSION} /usr/bin/clang++
2748
ln -sf /usr/bin/lld-${MAJOR_VERSION} /usr/bin/lld

0 commit comments

Comments
 (0)