|
| 1 | +""" The base container image is the base image with zypper included.""" |
| 2 | + |
| 3 | +import textwrap |
| 4 | + |
| 5 | +from bci_build.package import ALL_BASE_OS_VERSIONS |
| 6 | +from bci_build.package import OsVersion |
| 7 | +from bci_build.package import OsContainer |
| 8 | +from bci_build.package import BuildType |
| 9 | +from bci_build.package import SupportLevel |
| 10 | +from bci_build.package import Package |
| 11 | +from bci_build.package import PackageType |
| 12 | +from bci_build.package import CAN_BE_LATEST_OS_VERSION |
| 13 | + |
| 14 | +def _get_base_config_sh_script(os_version: OsVersion) -> str: |
| 15 | + return textwrap.dedent( |
| 16 | + r""" |
| 17 | +echo "Configure image: [$kiwi_iname]..." |
| 18 | +
|
| 19 | +#====================================== |
| 20 | +# Setup baseproduct link |
| 21 | +#-------------------------------------- |
| 22 | +suseSetupProduct |
| 23 | +
|
| 24 | +#====================================== |
| 25 | +# Import repositories' keys |
| 26 | +#-------------------------------------- |
| 27 | +suseImportBuildKey |
| 28 | +
|
| 29 | +
|
| 30 | +# don't have duplicate licenses of the same type |
| 31 | +jdupes -1 -L -r /usr/share/licenses |
| 32 | +
|
| 33 | +zypper --non-interactive rm -u jdupes |
| 34 | +
|
| 35 | +# Not needed, but neither rpm nor libzypp handle rpmlib(X-CheckUnifiedSystemdir) yet |
| 36 | +# which would avoid it being installed by filesystem package |
| 37 | +rpm -e compat-usrmerge-tools |
| 38 | +
|
| 39 | +#====================================== |
| 40 | +# Disable recommends |
| 41 | +#-------------------------------------- |
| 42 | +sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf |
| 43 | +
|
| 44 | +#====================================== |
| 45 | +# Exclude docs installation |
| 46 | +#-------------------------------------- |
| 47 | +sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf |
| 48 | +
|
| 49 | +#====================================== |
| 50 | +# Configure SLE BCI repositories |
| 51 | +#-------------------------------------- |
| 52 | +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 |
| 53 | +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 |
| 54 | +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 |
| 55 | +
|
| 56 | +#====================================== |
| 57 | +# Remove locale files |
| 58 | +#-------------------------------------- |
| 59 | +shopt -s globstar |
| 60 | +rm -f /usr/share/locale/**/*.mo |
| 61 | +
|
| 62 | +#====================================== |
| 63 | +# Remove zypp uuid (bsc#1098535) |
| 64 | +#-------------------------------------- |
| 65 | +rm -f /var/lib/zypp/AnonymousUniqueId |
| 66 | +
|
| 67 | +# Remove various log files. Although possible to just rm -rf /var/log/*, that |
| 68 | +# would also remove some package owned directories (not %ghost) and some files |
| 69 | +# are actually wanted, like lastlog in the !docker case. |
| 70 | +# For those wondering about YaST2 here: Kiwi writes /etc/hosts, so the version |
| 71 | +# from the netcfg package ends up as /etc/hosts.rpmnew, which zypper writes a |
| 72 | +# letter about to /var/log/YaST2/config_diff_2022_03_06.log. Kiwi fixes this, |
| 73 | +# but the log file remains. |
| 74 | +rm -rf /var/log/{zypper.log,zypp/history,YaST2} |
| 75 | +
|
| 76 | +# Remove the entire zypper cache content (not the dir itself, owned by libzypp) |
| 77 | +rm -rf /var/cache/zypp/* |
| 78 | +
|
| 79 | +#========================================== |
| 80 | +# Hack! The go container management tools can't handle sparse files: |
| 81 | +# https://github.com/golang/go/issues/13548 |
| 82 | +# If lastlog doesn't exist, useradd doesn't attempt to reserve space, |
| 83 | +# also in derived containers. |
| 84 | +#------------------------------------------ |
| 85 | +rm -f /var/log/lastlog |
| 86 | +
|
| 87 | +#====================================== |
| 88 | +# Remove locale files |
| 89 | +#-------------------------------------- |
| 90 | +find /usr/share/locale -name '*.mo' -delete |
| 91 | +
|
| 92 | +exit 0 |
| 93 | +""" |
| 94 | + ) |
| 95 | + |
| 96 | + |
| 97 | +BASE_CONTAINERS = [ |
| 98 | + OsContainer( |
| 99 | + name="base", |
| 100 | + pretty_name="Base Container Image", |
| 101 | + package_name="sles15-image" if os_ver.is_sle15 else "base-image", |
| 102 | + logo_url="https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg", |
| 103 | + build_recipe_type=BuildType.KIWI, |
| 104 | + from_image=None, |
| 105 | + os_version=os_ver, |
| 106 | + support_level=SupportLevel.L3, |
| 107 | + is_latest=os_ver in CAN_BE_LATEST_OS_VERSION, |
| 108 | + package_list=[ |
| 109 | + Package(name=pkg_name, pkg_type=PackageType.IMAGE) |
| 110 | + for pkg_name in ( |
| 111 | + "bash", |
| 112 | + "ca-certificates-mozilla", |
| 113 | + "ca-certificates", |
| 114 | + "container-suseconnect", |
| 115 | + "coreutils", |
| 116 | + "curl", |
| 117 | + "findutils", |
| 118 | + "glibc-locale-base", |
| 119 | + "gzip", |
| 120 | + "lsb-release", |
| 121 | + "netcfg", |
| 122 | + "openssl", |
| 123 | + "skelcd-EULA-bci", |
| 124 | + "sle-module-basesystem-release", |
| 125 | + "sle-module-server-applications-release", |
| 126 | + "sle-module-python3-release", |
| 127 | + "suse-build-key", |
| 128 | + "tar", |
| 129 | + "timezone", |
| 130 | + ) |
| 131 | + ] |
| 132 | + + [ |
| 133 | + Package(name=pkg_name, pkg_type=PackageType.BOOTSTRAP) |
| 134 | + for pkg_name in ( |
| 135 | + "aaa_base", |
| 136 | + "cracklib-dict-small", |
| 137 | + "filesystem", |
| 138 | + "jdupes", |
| 139 | + "kubic-locale-archive", |
| 140 | + "patterns-base-fips", |
| 141 | + "patterns-base-minimal_base", |
| 142 | + "rpm-ndb", |
| 143 | + "shadow", |
| 144 | + "sles-release", |
| 145 | + "zypper", |
| 146 | + ) |
| 147 | + ], |
| 148 | + config_sh_script=_get_base_config_sh_script(os_ver), |
| 149 | + ) |
| 150 | + for os_ver in ALL_BASE_OS_VERSIONS |
| 151 | +] |
0 commit comments