Skip to content

Commit

Permalink
Merge pull request #2096 from SUSE/multi_package_sac_python
Browse files Browse the repository at this point in the history
Add SAC Python containers in addition to the normal python containers (jsc#PED-11663)
  • Loading branch information
dirkmueller authored Dec 4, 2024
2 parents fa6099b + 1d986ea commit 907652c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
21 changes: 18 additions & 3 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ class BaseContainerImage(abc.ABC):
#: contain arbitrary instructions valid for a :file:`Dockerfile`.
build_stage_custom_end: str | None = None

#: This string defines which build counter identifier should be used for this
#: container. can be an arbitrary string is used to derive the checkin-counter.
#: Defaults to the main package for packages with a flavor.
buildcounter_synctag: str | None = None

#: A script that is put into :file:`config.sh` if a kiwi image is
#: created. If a :file:`Dockerfile` based build is used then this script is
#: prependend with a :py:const:`~bci_build.package.DOCKERFILE_RUN` and added
Expand Down Expand Up @@ -356,6 +361,10 @@ def __post_init__(self) -> None:
):
self.support_level = SupportLevel.TECHPREVIEW

# set buildcounter to the package name if not set
if not self.buildcounter_synctag and self.package_name and self.build_flavor:
self.buildcounter_synctag = self.package_name

@abc.abstractmethod
def prepare_template(self) -> None:
"""Hook to do delayed expensive work prior template rendering"""
Expand Down Expand Up @@ -1226,7 +1235,13 @@ def _tag_variant(self) -> str:

@property
def uid(self) -> str:
return f"{self.name}-{self._tag_variant}" if self.version_in_uid else self.name
return (
f"{self.name}-{self._tag_variant}" if self.version_in_uid else self.name
) + (
"-sac"
if isinstance(self._publish_registry, ApplicationCollectionRegistry)
else ""
)

@property
def _stability_suffix(self) -> str:
Expand Down Expand Up @@ -1468,11 +1483,11 @@ def generate_disk_size_constraints(size_gb: int) -> str:
from .postfix import POSTFIX_CONTAINERS # noqa: E402
from .postgres import POSTGRES_CONTAINERS # noqa: E402
from .python import PYTHON_3_6_CONTAINERS # noqa: E402
from .python import PYTHON_3_9_CONTAINERS # noqa: E402
from .python import PYTHON_3_11_CONTAINERS # noqa: E402
from .python import PYTHON_3_12_CONTAINERS # noqa: E402
from .python import PYTHON_3_13_CONTAINERS # noqa: E402
from .python import PYTHON_TW_CONTAINERS # noqa: E402
from .python import SAC_PYTHON_CONTAINERS # noqa: E402
from .rmt import RMT_CONTAINERS # noqa: E402
from .ruby import RUBY_CONTAINERS # noqa: E402
from .rust import RUST_CONTAINERS # noqa: E402
Expand All @@ -1484,8 +1499,8 @@ def generate_disk_size_constraints(size_gb: int) -> str:
for bci in (
*BASE_CONTAINERS,
*COSIGN_CONTAINERS,
*SAC_PYTHON_CONTAINERS,
*PYTHON_3_6_CONTAINERS,
*PYTHON_3_9_CONTAINERS,
*PYTHON_3_11_CONTAINERS,
*PYTHON_3_12_CONTAINERS,
*PYTHON_3_13_CONTAINERS,
Expand Down
18 changes: 10 additions & 8 deletions src/bci_build/package/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def _get_python_kwargs(py3_ver: _PYTHON_VERSIONS, os_version: OsVersion):
return kwargs


SAC_PYTHON_CONTAINERS = [
PythonDevelopmentContainer(
**_get_python_kwargs(py_version, OsVersion.SP6),
package_name=f"sac-python-{py_version}-image",
buildcounter_synctag="sac-containers-python",
_publish_registry=publish_registry(OsVersion.SP6, app_collection=True),
)
for py_version in ("3.9", "3.11")
]

PYTHON_3_6_CONTAINERS = (
PythonDevelopmentContainer(
**_get_python_kwargs("3.6", os_version),
Expand All @@ -117,14 +127,6 @@ def _get_python_kwargs(py3_ver: _PYTHON_VERSIONS, os_version: OsVersion):
for os_version in (OsVersion.SP6,)
)

PYTHON_3_9_CONTAINERS = (
PythonDevelopmentContainer(
**_get_python_kwargs("3.9", os_version),
package_name="sac-python-3.9-image",
_publish_registry=publish_registry(os_version, app_collection=True),
)
for os_version in (OsVersion.SP6,)
)

_PYTHON_TW_VERSIONS: tuple[_PYTHON_VERSIONS, ...] = ("3.10", "3.12", "3.13", "3.11")
PYTHON_TW_CONTAINERS = (
Expand Down
2 changes: 1 addition & 1 deletion src/bci_build/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{% endfor -%}
{%- if image.publish_registry.force_multiversion -%}#!ForceMultiVersion
{% endif -%}
{%- if image.crate and image.build_flavor %}#!BcntSyncTag: {{ image.package_name }}
{%- if image.buildcounter_synctag %}#!BcntSyncTag: {{ image.buildcounter_synctag }}
{% endif -%}
{% if image.build_version %}#!BuildName: {{ image.build_name }}
#!BuildVersion: {{ image.build_version }}
Expand Down

0 comments on commit 907652c

Please sign in to comment.