File config.sh of Package kiwi-nginx-container

#!/bin/bash
#
# Copyright (c) 2025, Ilmi Solutions Oy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Description:
# Config.sh for docker
#

CONTAINER_LOCALE=fi_FI
CONTAINER_CHARENC=UTF-8
CONTAINER_TIMEZONE="Europe/Helsinki"

#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile

set -euxo pipefail

#======================================
# Greeting...
#--------------------------------------
if [ -z "$kiwi_iname" ]; then
	kiwi_iname="unknown"
fi
echo "Configure image: [$kiwi_iname]..."

#======================================
# Import repositories' keys
#--------------------------------------
suseImportBuildKey

#======================================
# don't have multiple licenses of the same type
#--------------------------------------
jdupes -1 -L -r /usr/share/licenses
zypper --non-interactive rm -u jdupes

#======================================
# Not needed, but neither rpm nor libzypp handle
# rpmlib(X-CheckUnifiedSystemdir) yet
# which would avoid it being installed by
# the filesystem package
#--------------------------------------
rpm -e compat-usrmerge-tools

#======================================
# Disable recommends
#--------------------------------------
sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf

#======================================
# Exclude docs intallation
#--------------------------------------
sed -i 's/.*rpm.install.excludedocs.*/# rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf

#======================================
# Remove locale files
#--------------------------------------
shopt -s globstar
rm -f /usr/share/locale/**/*.mo

#======================================
# Remove zypp uuid (bsc#1098535)
#--------------------------------------
rm -f /var/lib/zypp/AnonymousUniqueId

#======================================
# Remove various log files. While it's possible to just rm -rf /var/log/*, that
# would also remove some package owned directories (not %ghost) and some files
# are actually wanted, like lastlog in the !docker case.
# For those wondering about YaST2 here: Kiwi writes /etc/hosts, so the version
# from the netcfg package ends up as /etc/hosts.rpmnew, which zypper writes a
# letter about to /var/log/YaST2/config_diff_2022_03_06.log. Kiwi fixes this,
# but the log file remains.
#--------------------------------------
rm -rf /var/log/{zypper.log,zypp/history,YaST2}

#======================================
# Remove the entire zypper cache content (not the dir itself, owned by libzypp)
#--------------------------------------
rm -rf /var/cache/zypp/*

#======================================
# Make sure that time zone is correct
#--------------------------------------
# ln -sf "/usr/share/zoneinfo/$CONTAINER_TIMEZONE" /etc/localtime

if [[ "$kiwi_profiles" == *"docker"* ]]; then
	# Hack! The go container management tools can't handle sparse files:
	# https://github.com/golang/go/issues/13548
	# When lastlog doesn't exist, useradd doesn't attempt to reserve space.
	rm -f /var/log/lastlog
fi

exit 0
openSUSE Build Service is sponsored by