forked from dotnet/dotnet-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.linux.remove-pkgs
More file actions
42 lines (37 loc) · 1.3 KB
/
Dockerfile.linux.remove-pkgs
File metadata and controls
42 lines (37 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{{
_ ARGS:
pkgs: list of packages to remove
pkg-mgr (optional): package manager to use
pkg-mgr-opts (optional): additional options to pass to the package manager
noninteractive (optional): whether to use noninteractive mode
no-clean (optional): skip package manager cleanup after install ^
set isAlpine to find(OS_VERSION, "alpine") >= 0 ^
set isAzureLinux to find(OS_VERSION, "azurelinux") >= 0 ^
set isDnf to ARGS["pkg-mgr"] = "dnf" ^
set isTdnf to ARGS["pkg-mgr"] = "tdnf" || (!isDnf && isAzureLinux) ^
set isApk to ARGS["pkg-mgr"] = "apk" || isAlpine ^
set isApt to ARGS["pkg-mgr"] = "apt-get" || (!isDnf && !isTdnf && !isApk) ^
set removeCmd to
when(isApk,
"apk del",
when(isDnf,
"dnf remove -y",
when(isTdnf,
"tdnf autoremove -y",
when (ARGS["noninteractive"],
"DEBIAN_FRONTEND=noninteractive apt-get remove -y",
"apt-get remove -y"
)))) ^
set cleanCmd to
when(isApk,
"apk del",
when(isTdnf,
"tdnf clean all",
"apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*"))
}}{{
removeCmd}}{{ARGS["pkg-mgr-opts"]}} \{{
for index, pkg in ARGS["pkgs"]:
{{pkg}} \}}{{
if !no-clean:
&& {{cleanCmd}}}}