Skip to content

Commit d223369

Browse files
committed
Remove util-linux from the tomcat containers
This is only needed for the runuser command in the post script and not needed in the final container.
1 parent 73ab954 commit d223369

File tree

4 files changed

+46
-7
lines changed

4 files changed

+46
-7
lines changed

src/bci_build/package/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,29 @@ def packages(self) -> str:
864864
:command:`zypper in`.
865865
866866
"""
867+
packages_to_install: list[str] = []
867868
for pkg in self.package_list:
868-
if isinstance(pkg, Package) and pkg.pkg_type != PackageType.IMAGE:
869+
if isinstance(pkg, Package) and pkg.pkg_type not in (
870+
PackageType.IMAGE,
871+
PackageType.DELETE,
872+
):
869873
raise ValueError(
870874
f"Cannot add a package of type {pkg.pkg_type} into a Dockerfile based build."
871875
)
872-
return " ".join(str(pkg) for pkg in self.package_list)
876+
if isinstance(pkg, Package) and pkg.pkg_type == PackageType.DELETE:
877+
continue
878+
packages_to_install.append(str(pkg))
879+
return " ".join(packages_to_install)
880+
881+
@property
882+
def packages_to_delete(self) -> str:
883+
"""The list of packages joined that can be passed to zypper -n rm after an install`."""
884+
packages_to_delete: list[str] = [
885+
str(pkg)
886+
for pkg in self.package_list
887+
if (isinstance(pkg, Package) and pkg.pkg_type == PackageType.DELETE)
888+
]
889+
return " ".join(packages_to_delete)
873890

874891
@overload
875892
def _kiwi_volumes_expose(

src/bci_build/package/apache_tomcat.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from bci_build.package import DOCKERFILE_RUN
77
from bci_build.package import OsContainer
88
from bci_build.package import OsVersion
9+
from bci_build.package import Package
10+
from bci_build.package import PackageType
911
from bci_build.package import Replacement
1012
from bci_build.package import _build_tag_prefix
1113

@@ -82,6 +84,7 @@ def _get_sac_supported_until(
8284
"curl",
8385
# currently needed by custom_end
8486
"sed",
87+
Package("util-linux", PackageType.DELETE),
8588
]
8689
+ [f"java-{jre_version}-openjdk", f"java-{jre_version}-openjdk-headless"],
8790
replacements_via_service=[

src/bci_build/templates.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@
4343
COPY --from=target / /target
4444
{%- endif %}
4545
46-
{% if image.packages %}{{ DOCKERFILE_RUN }} zypper{% if image.from_target_image %} --installroot /target --gpg-auto-import-keys {% endif %} -n in {% if image.no_recommends %}--no-recommends {% endif %}{{ image.packages }}; zypper -n clean; {{ LOG_CLEAN }}{% endif %}
46+
{% if image.packages %}{{ DOCKERFILE_RUN }} \\
47+
zypper -n {%- if image.from_target_image %} --installroot /target --gpg-auto-import-keys {%- endif %} install {% if image.no_recommends %}--no-recommends {% endif %}{{ image.packages }}; \\
48+
{%- if image.packages_to_delete %}
49+
zypper -n {%- if image.from_target_image %} --installroot /target {%- endif %} remove {{ image.packages_to_delete }}; \\
50+
{%- endif %}
51+
zypper -n clean; \\
52+
{{ LOG_CLEAN }}
53+
{%- endif %}
4754
{% if image.from_target_image %}FROM {{ image.dockerfile_from_target_ref }}
4855
COPY --from=builder /target /{% endif %}
4956
# Define labels according to https://en.opensuse.org/Building_derived_containers

tests/test_build_recipe.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
#!BuildVersion: 15.6.27
3131
FROM bci/bci-base:15.6
3232
33-
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
33+
RUN \\
34+
zypper -n install --no-recommends gcc emacs; \\
35+
zypper -n clean; \\
36+
##LOGCLEAN##
3437
3538
# Define labels according to https://en.opensuse.org/Building_derived_containers
3639
# labelprefix=com.suse.bci.test
@@ -140,7 +143,10 @@
140143
#!BuildVersion: 15.5
141144
FROM bci/bci-base:15.5
142145
143-
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
146+
RUN \\
147+
zypper -n install --no-recommends gcc emacs; \\
148+
zypper -n clean; \\
149+
##LOGCLEAN##
144150
145151
# Define labels according to https://en.opensuse.org/Building_derived_containers
146152
# labelprefix=com.suse.bci.test
@@ -241,7 +247,10 @@
241247
#!BuildVersion: 15.6.29
242248
FROM bci/bci-base:15.6
243249
244-
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
250+
RUN \\
251+
zypper -n install --no-recommends gcc emacs; \\
252+
zypper -n clean; \\
253+
##LOGCLEAN##
245254
246255
# Define labels according to https://en.opensuse.org/Building_derived_containers
247256
# labelprefix=com.suse.bci.test
@@ -348,7 +357,10 @@
348357
349358
FROM suse/base:18
350359
351-
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
360+
RUN \\
361+
zypper -n install --no-recommends gcc emacs; \\
362+
zypper -n clean; \\
363+
##LOGCLEAN##
352364
353365
# Define labels according to https://en.opensuse.org/Building_derived_containers
354366
# labelprefix=org.opensuse.bci.test

0 commit comments

Comments
 (0)