Skip to content

Commit fb82a3f

Browse files
committed
Generate the bci-base container via dockerfile generator as well
1 parent c067310 commit fb82a3f

5 files changed

Lines changed: 197 additions & 103 deletions

File tree

src/bci_build/package/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ class Package:
264264
#: The name of the package
265265
name: str
266266

267+
#: Optional: The name of the package this is replacing
268+
replaces: str | None = None
269+
267270
#: The package type. This parameter is only applicable for kiwi builds and
268271
#: defines into which ``<packages>`` element this package is inserted.
269272
pkg_type: PackageType = PackageType.IMAGE
@@ -930,6 +933,11 @@ def pkg_filter_func(p: str | Package) -> bool:
930933

931934
return pkg_filter_func
932935

936+
def pkg_listing_func(pkg: Package) -> str:
937+
if pkg.replaces:
938+
return f'<package name="{pkg}" replaces="rpm"/>'
939+
return f'<package name="{pkg}"/>'
940+
933941
PKG_TYPES = (
934942
PackageType.DELETE,
935943
PackageType.BOOTSTRAP,
@@ -950,8 +958,7 @@ def pkg_filter_func(p: str | Package) -> bool:
950958
res += (
951959
f""" <packages type="{pkg_type}">
952960
"""
953-
+ """
954-
""".join(f'<package name="{pkg}"/>' for pkg in pkg_list)
961+
+ "\n ".join(pkg_listing_func(pkg) for pkg in pkg_list)
955962
+ """
956963
</packages>
957964
"""
@@ -1513,7 +1520,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15131520
from .appcontainers import THREE_EIGHT_NINE_DS_CONTAINERS # noqa: E402
15141521
from .appcontainers import TOMCAT_CONTAINERS # noqa: E402
15151522
from .appcontainers import TRIVY_CONTAINERS # noqa: E402
1516-
from .basalt_base import BASALT_BASE # noqa: E402
1523+
from .basecontainers import BASE_CONTAINERS # noqa: E402
15171524
from .basecontainers import BUSYBOX_CONTAINERS # noqa: E402
15181525
from .basecontainers import FIPS_BASE_CONTAINERS # noqa: E402
15191526
from .basecontainers import GITEA_RUNNER_CONTAINER # noqa: E402
@@ -1538,7 +1545,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15381545
ALL_CONTAINER_IMAGE_NAMES: dict[str, BaseContainerImage] = {
15391546
f"{bci.uid}-{bci.os_version.pretty_print.lower()}": bci
15401547
for bci in (
1541-
BASALT_BASE,
1548+
*BASE_CONTAINERS,
15421549
PYTHON_3_12_CONTAINERS,
15431550
*PYTHON_3_6_CONTAINERS,
15441551
*PYTHON_3_11_CONTAINERS,

src/bci_build/package/basalt_base.py

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/bci_build/package/base/LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Permission is hereby granted, free of charge, to any person obtaining a copy
2+
of this software and associated documentation files (the "Software"), to deal
3+
in the Software without restriction, including without limitation the rights
4+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5+
copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in
9+
all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
SOFTWARE.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# {{ image.title }}
2+
{% include 'badges.j2' %}
3+
4+
## Description
5+
6+
SUSE Linux Enterprise Base Container Images (SLE BCI) provide truly open,
7+
flexible, and secure container images and application development tools. The
8+
images consist of container environments based on SUSE Linux Enterprise and
9+
designed to be a secure base for any containerized workload.
10+
11+
SLE BCI is freely available, re-distributable, and supported across many
12+
different environments. These templates and tools address modern, containerized
13+
application development and CI/CD application containerization. They can be
14+
used immediately by developers and integrators without the “lock-in” imposed by
15+
other offerings.
16+
17+
SLE BCI inherits industry-leading security and compliance from SUSE Linux
18+
within your container build process. The container images are designed to be a
19+
secure base for any application workload. SUSE ensures that compliance
20+
standards are applied consistently and continuously improves security-related
21+
capabilities.
22+
23+
SLE BCI is lightweight and easy to adopt, with the ability to run with any
24+
Linux OS. Avoid lock-in imposed by other vendors and get exactly what you need,
25+
fast. SLE BCI delivers a flexible developer experience that accounts for,
26+
integrates with, and supports language-native tools and workflows.
27+
28+
## Usage
29+
30+
{% include 'licensing_and_eula.j2' %}

src/bci_build/package/basecontainers.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,145 @@ def _get_eula_package_names(os_version: OsVersion) -> tuple[str, ...]:
3535
return ("skelcd-EULA-bci",)
3636

3737

38+
def _get_base_config_sh_script(os_version: OsVersion) -> str:
39+
return textwrap.dedent(
40+
r"""
41+
echo "Configure image: [$kiwi_iname]..."
42+
43+
#======================================
44+
# Setup baseproduct link
45+
#--------------------------------------
46+
suseSetupProduct
47+
48+
#======================================
49+
# Import repositories' keys
50+
#--------------------------------------
51+
suseImportBuildKey
52+
53+
54+
# don't have duplicate licenses of the same type
55+
jdupes -1 -L -r /usr/share/licenses
56+
57+
zypper --non-interactive rm -u jdupes
58+
59+
# Not needed, but neither rpm nor libzypp handle rpmlib(X-CheckUnifiedSystemdir) yet
60+
# which would avoid it being installed by filesystem package
61+
rpm -e compat-usrmerge-tools
62+
63+
#======================================
64+
# Disable recommends
65+
#--------------------------------------
66+
sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf
67+
68+
#======================================
69+
# Exclude docs installation
70+
#--------------------------------------
71+
sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf
72+
73+
#======================================
74+
# Configure SLE BCI repositories
75+
#--------------------------------------
76+
zypper -n ar --refresh --gpgcheck --priority 100 --enable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product/' SLE_BCI
77+
zypper -n ar --refresh --gpgcheck --priority 100 --disable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product_debug/' SLE_BCI_debug
78+
zypper -n ar --refresh --gpgcheck --priority 100 --disable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product_source/' SLE_BCI_source
79+
80+
#======================================
81+
# Remove locale files
82+
#--------------------------------------
83+
shopt -s globstar
84+
rm -f /usr/share/locale/**/*.mo
85+
86+
#======================================
87+
# Remove zypp uuid (bsc#1098535)
88+
#--------------------------------------
89+
rm -f /var/lib/zypp/AnonymousUniqueId
90+
91+
# Remove various log files. Although possible to just rm -rf /var/log/*, that
92+
# would also remove some package owned directories (not %ghost) and some files
93+
# are actually wanted, like lastlog in the !docker case.
94+
# For those wondering about YaST2 here: Kiwi writes /etc/hosts, so the version
95+
# from the netcfg package ends up as /etc/hosts.rpmnew, which zypper writes a
96+
# letter about to /var/log/YaST2/config_diff_2022_03_06.log. Kiwi fixes this,
97+
# but the log file remains.
98+
rm -rf /var/log/{zypper.log,zypp/history,YaST2}
99+
100+
# Remove the entire zypper cache content (not the dir itself, owned by libzypp)
101+
rm -rf /var/cache/zypp/*
102+
103+
#==========================================
104+
# Hack! The go container management tools can't handle sparse files:
105+
# https://github.com/golang/go/issues/13548
106+
# If lastlog doesn't exist, useradd doesn't attempt to reserve space,
107+
# also in derived containers.
108+
#------------------------------------------
109+
rm -f /var/log/lastlog
110+
111+
#======================================
112+
# Remove locale files
113+
#--------------------------------------
114+
find /usr/share/locale -name '*.mo' -delete
115+
116+
exit 0
117+
"""
118+
)
119+
120+
121+
BASE_CONTAINERS = [
122+
OsContainer(
123+
name="base",
124+
pretty_name="Base Container Image",
125+
package_name="sles15-image" if os_ver.is_sle15 else "base-image",
126+
logo_url="https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg",
127+
build_recipe_type=BuildType.KIWI,
128+
from_image=None,
129+
os_version=os_ver,
130+
is_latest=True,
131+
package_list=[
132+
Package(name=pkg_name, pkg_type=PackageType.IMAGE)
133+
for pkg_name in (
134+
"bash",
135+
"ca-certificates-mozilla",
136+
"ca-certificates",
137+
"container-suseconnect",
138+
"coreutils",
139+
"curl",
140+
"findutils",
141+
"glibc-locale-base",
142+
"gzip",
143+
"lsb-release",
144+
"netcfg",
145+
"openssl",
146+
"skelcd-EULA-bci",
147+
"sle-module-basesystem-release",
148+
"sle-module-server-applications-release",
149+
"sle-module-python3-release",
150+
"suse-build-key",
151+
"tar",
152+
"timezone",
153+
)
154+
]
155+
+ [
156+
Package(name=pkg_name, pkg_type=PackageType.BOOTSTRAP)
157+
for pkg_name in (
158+
"aaa_base",
159+
"cracklib-dict-small",
160+
"filesystem",
161+
"jdupes",
162+
"kubic-locale-archive",
163+
"patterns-base-fips",
164+
"patterns-base-minimal_base",
165+
"shadow",
166+
"sles-release",
167+
"zypper",
168+
)
169+
]
170+
+ [Package(name="rpm-ndb", pkg_type=PackageType.BOOTSTRAP, replaces="rpm")],
171+
config_sh_script=_get_base_config_sh_script(os_ver),
172+
)
173+
for os_ver in ALL_BASE_OS_VERSIONS
174+
]
175+
176+
38177
MICRO_CONTAINERS = [
39178
OsContainer(
40179
name="micro",

0 commit comments

Comments
 (0)