Files
podman/test/system/build-systemd-image
Paul Holzinger 34c258b419 libpod: fix timezone handling
The current way of bind mounting the host timezone file has problems.
Because /etc/localtime in the image may exist and is a symlink under
/usr/share/zoneinfo it will overwrite the targetfile. That confuses
timezone parses especially java where this approach does not work at
all. So we end up with an link which does not reflect the actual truth.

The better way is to just change the symlink in the image like it is
done on the host. However because not all images ship tzdata we cannot
rely on that either. So now we do both, when tzdata is installed then
use the symlink and if not we keep the current way of copying the host
timezone file in the container to /etc/localtime.

Also note that we need to rebuild the systemd image to include tzdata in
order to test this as our images do not contain the tzdata by default.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2149876

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-06-01 11:04:13 +02:00

78 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
#
# build-systemd-image - script for producing a test image with systemd
#
# Based on the build-testimage script. This script builds a fedora-based
# image with systemd in it, for use in systemd-based tests.
#
# Podman binary to use
PODMAN=${PODMAN:-$(pwd)/bin/podman}
# Tag for this new image
YMD=$(date +%Y%m%d)
# git-relative path to this script
create_script=$(cd $(dirname $0) && git ls-files --full-name $(basename $0))
if [ -z "$create_script" ]; then
create_script=$0
fi
create_script_rev=$(git describe --tags)
# Creation timestamp, Zulu time
create_time_t=$(date +%s)
create_time_z=$(env TZ=UTC date --date=@$create_time_t +'%Y-%m-%dT%H:%M:%SZ')
set -e
# We'll need to create a Containerfile plus various other files to add in
tmpdir=$(mktemp -t -d $(basename $0).tmp.XXXXXXX)
cd $tmpdir
echo $YMD >testimage-id
cat >Containerfile <<EOF
FROM registry.fedoraproject.org/fedora-minimal:38
LABEL created_by="$create_script @ $create_script_rev"
LABEL created_at=$create_time_z
# Note the reinstall of tzdata is required (https://bugzilla.redhat.com/show_bug.cgi?id=1870814)
RUN microdnf install -y systemd && microdnf reinstall -y tzdata && microdnf clean all && sed -i -e 's/.*LogColor.*/LogColor=no/' /etc/systemd/system.conf
ADD testimage-id /home/podman/
WORKDIR /home/podman
CMD ["/bin/echo", "This image is intended for podman CI testing"]
EOF
# Start from scratch
testimg_base=quay.io/libpod/systemd-image
testimg=${testimg_base}:$YMD
$PODMAN manifest rm $testimg &> /dev/null || true
$PODMAN rmi -f $testimg &> /dev/null || true
# Arch emulation on Fedora requires the qemu-user-static package.
declare -a arches=(amd64 arm64 ppc64le s390x)
n_arches=${#arches[*]}
i=0
while [[ $i -lt $n_arches ]]; do
arch=${arches[$i]}
i=$((i+1))
echo
echo "Building: $arch ($i of $n_arches)"
$PODMAN build \
--arch=$arch \
--squash-all \
--timestamp=$create_time_t \
--manifest=$testimg \
.
done
# Clean up
cd /tmp
rm -rf $tmpdir
# Tag image and push (all arches) to quay.
cat <<EOF
If you're happy with this image, run:
podman manifest push --all ${testimg} docker://${testimg}
EOF