@@ -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+
38177MICRO_CONTAINERS = [
39178 OsContainer (
40179 name = "micro" ,
0 commit comments