File: build-systemd-image

package info (click to toggle)
podman 5.4.2%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 23,124 kB
  • sloc: sh: 6,119; perl: 2,710; python: 2,258; ansic: 1,556; makefile: 1,022; xml: 121; ruby: 42; awk: 12; csh: 8
file content (76 lines) | stat: -rwxr-xr-x 2,074 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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:39
LABEL created_by="$create_script @ $create_script_rev"
LABEL created_at=$create_time_z
RUN microdnf install -y systemd 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