|
| 1 | +#!/bin/bash |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +# SPDX-FileCopyrightText: (c) 2022-2024 SUSE LLC |
| 4 | + |
| 5 | +set -euo pipefail |
| 6 | + |
| 7 | +test -f /.kconfig && . /.kconfig |
| 8 | +test -f /.profile && . /.profile |
| 9 | + |
| 10 | +echo "Configure image: [$kiwi_iname]..." |
| 11 | + |
| 12 | +#============================================ |
| 13 | +# Import repositories' keys if rpm is present |
| 14 | +#-------------------------------------------- |
| 15 | +if command -v rpm > /dev/null; then |
| 16 | + suseImportBuildKey |
| 17 | +fi |
| 18 | + |
| 19 | + |
| 20 | +echo "Configure image: [$kiwi_iname]..." |
| 21 | + |
| 22 | +#====================================== |
| 23 | +# Setup baseproduct link |
| 24 | +#-------------------------------------- |
| 25 | +suseSetupProduct |
| 26 | + |
| 27 | +#====================================== |
| 28 | +# Import repositories' keys |
| 29 | +#-------------------------------------- |
| 30 | +suseImportBuildKey |
| 31 | + |
| 32 | + |
| 33 | +# don't have duplicate licenses of the same type |
| 34 | +jdupes -1 -L -r /usr/share/licenses |
| 35 | + |
| 36 | +zypper --non-interactive rm -u jdupes |
| 37 | + |
| 38 | +# Not needed, but neither rpm nor libzypp handle rpmlib(X-CheckUnifiedSystemdir) yet |
| 39 | +# which would avoid it being installed by filesystem package |
| 40 | +rpm -q compat-usrmerge-tools && rpm -e compat-usrmerge-tools |
| 41 | + |
| 42 | +#====================================== |
| 43 | +# Disable recommends |
| 44 | +#-------------------------------------- |
| 45 | +sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf |
| 46 | + |
| 47 | +#====================================== |
| 48 | +# Exclude docs installation |
| 49 | +#-------------------------------------- |
| 50 | +sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf |
| 51 | + |
| 52 | +#====================================== |
| 53 | +# Configure SLE BCI repositories |
| 54 | +#-------------------------------------- |
| 55 | +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 |
| 56 | +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 |
| 57 | +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 |
| 58 | + |
| 59 | +#====================================== |
| 60 | +# Remove locale files |
| 61 | +#-------------------------------------- |
| 62 | +shopt -s globstar |
| 63 | +rm -f /usr/share/locale/**/*.mo |
| 64 | + |
| 65 | +#====================================== |
| 66 | +# Remove zypp uuid (bsc#1098535) |
| 67 | +#-------------------------------------- |
| 68 | +rm -f /var/lib/zypp/AnonymousUniqueId |
| 69 | + |
| 70 | +#========================================== |
| 71 | +# Clean up log files |
| 72 | +#------------------------------------------ |
| 73 | +# Remove various log files. Although possible to just rm -rf /var/log/*, that |
| 74 | +# would also remove some package owned directories (not %ghost) and some files |
| 75 | +# are actually wanted, like lastlog in the !docker case. |
| 76 | +# For those wondering about YaST2 here: Kiwi writes /etc/hosts, so the version |
| 77 | +# from the netcfg package ends up as /etc/hosts.rpmnew, which zypper writes a |
| 78 | +# letter about to /var/log/YaST2/config_diff_2022_03_06.log. Kiwi fixes this, |
| 79 | +# but the log file remains. |
| 80 | +rm -rf /var/log/{zypper.log,zypp/history,YaST2} |
| 81 | + |
| 82 | +# Remove the entire zypper cache content (not the dir itself, owned by libzypp) |
| 83 | +rm -rf /var/cache/zypp/* |
| 84 | + |
| 85 | +#========================================== |
| 86 | +# Hack! The go container management tools can't handle sparse files: |
| 87 | +# https://github.com/golang/go/issues/13548 |
| 88 | +# If lastlog doesn't exist, useradd doesn't attempt to reserve space, |
| 89 | +# also in derived containers. |
| 90 | +#------------------------------------------ |
| 91 | +rm -f /var/log/lastlog |
| 92 | + |
| 93 | +#====================================== |
| 94 | +# Remove locale files |
| 95 | +#-------------------------------------- |
| 96 | +find /usr/share/locale -name '*.mo' -delete |
| 97 | + |
| 98 | + |
| 99 | +#======================================= |
| 100 | +# Clean up after zypper if it is present |
| 101 | +#--------------------------------------- |
| 102 | +if command -v zypper > /dev/null; then |
| 103 | + zypper -n clean |
| 104 | +fi |
| 105 | + |
| 106 | +rm -rf /var/log/{lastlog,tallylog,zypper.log,zypp/history,YaST2} |
| 107 | + |
| 108 | +exit 0 |
0 commit comments