File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -6,22 +6,43 @@ if [ "$VERSION" == "latest" ]; then
6
6
fi
7
7
MAJOR_VERSION=${VERSION%% .* }
8
8
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
+
9
20
# Checks if packages are installed and installs them if not
10
21
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
15
26
}
16
27
17
28
check_packages lsb-release wget software-properties-common gnupg
18
29
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
+
19
37
cd /tmp
20
38
wget https://apt.llvm.org/llvm.sh
21
39
chmod +x llvm.sh
22
40
./llvm.sh $VERSION all
23
41
rm llvm.sh
24
42
43
+ # Remove downloads to keep Docker layer small
44
+ apt-get clean -y && rm -rf /var/lib/apt/lists/
45
+
25
46
ln -sf /usr/bin/clang-${MAJOR_VERSION} /usr/bin/clang
26
47
ln -sf /usr/bin/clang++-${MAJOR_VERSION} /usr/bin/clang++
27
48
ln -sf /usr/bin/lld-${MAJOR_VERSION} /usr/bin/lld
You can’t perform that action at this time.
0 commit comments